@@ -1080,6 +1080,15 @@ impl fmt::Display for ExitStatus {
10801080 }
10811081}
10821082
1083+ /// This is ridiculously unstable, as it's a completely-punted-upon part
1084+ /// of the `?`-in-`main` RFC. It's here only to allow experimenting with
1085+ /// returning a code directly from main. It will definitely change
1086+ /// drastically before being stabilized, if it doesn't just get deleted.
1087+ #[ doc( hidden) ]
1088+ #[ derive( Clone , Copy , Debug ) ]
1089+ #[ unstable( feature = "process_exitcode_placeholder" , issue = "43301" ) ]
1090+ pub struct ExitCode ( pub i32 ) ;
1091+
10831092impl Child {
10841093 /// Forces the child to exit. This is equivalent to sending a
10851094 /// SIGKILL on unix platforms.
@@ -1428,7 +1437,7 @@ impl Termination for () {
14281437}
14291438
14301439#[ unstable( feature = "termination_trait_lib" , issue = "43301" ) ]
1431- impl < T : Termination , E : fmt:: Debug > Termination for Result < T , E > {
1440+ impl < E : fmt:: Debug > Termination for Result < ( ) , E > {
14321441 fn report ( self ) -> i32 {
14331442 match self {
14341443 Ok ( val) => val. report ( ) ,
@@ -1442,20 +1451,23 @@ impl<T: Termination, E: fmt::Debug> Termination for Result<T, E> {
14421451
14431452#[ unstable( feature = "termination_trait_lib" , issue = "43301" ) ]
14441453impl Termination for ! {
1445- fn report ( self ) -> i32 { unreachable ! ( ) ; }
1454+ fn report ( self ) -> i32 { self }
14461455}
14471456
14481457#[ unstable( feature = "termination_trait_lib" , issue = "43301" ) ]
1449- impl Termination for bool {
1458+ impl < E : fmt :: Debug > Termination for Result < ! , E > {
14501459 fn report ( self ) -> i32 {
1451- if self { exit:: SUCCESS } else { exit:: FAILURE }
1460+ let Err ( err) = self ;
1461+ eprintln ! ( "Error: {:?}" , err) ;
1462+ exit:: FAILURE
14521463 }
14531464}
14541465
14551466#[ unstable( feature = "termination_trait_lib" , issue = "43301" ) ]
1456- impl Termination for i32 {
1467+ impl Termination for ExitCode {
14571468 fn report ( self ) -> i32 {
1458- self
1469+ let ExitCode ( code) = self ;
1470+ code
14591471 }
14601472}
14611473
0 commit comments