@@ -1080,6 +1080,15 @@ impl fmt::Display for ExitStatus {
1080
1080
}
1081
1081
}
1082
1082
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
+
1083
1092
impl Child {
1084
1093
/// Forces the child to exit. This is equivalent to sending a
1085
1094
/// SIGKILL on unix platforms.
@@ -1428,7 +1437,7 @@ impl Termination for () {
1428
1437
}
1429
1438
1430
1439
#[ 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 > {
1432
1441
fn report ( self ) -> i32 {
1433
1442
match self {
1434
1443
Ok ( val) => val. report ( ) ,
@@ -1442,20 +1451,23 @@ impl<T: Termination, E: fmt::Debug> Termination for Result<T, E> {
1442
1451
1443
1452
#[ unstable( feature = "termination_trait_lib" , issue = "43301" ) ]
1444
1453
impl Termination for ! {
1445
- fn report ( self ) -> i32 { unreachable ! ( ) ; }
1454
+ fn report ( self ) -> i32 { self }
1446
1455
}
1447
1456
1448
1457
#[ unstable( feature = "termination_trait_lib" , issue = "43301" ) ]
1449
- impl Termination for bool {
1458
+ impl < E : fmt :: Debug > Termination for Result < ! , E > {
1450
1459
fn report ( self ) -> i32 {
1451
- if self { exit:: SUCCESS } else { exit:: FAILURE }
1460
+ let Err ( err) = self ;
1461
+ eprintln ! ( "Error: {:?}" , err) ;
1462
+ exit:: FAILURE
1452
1463
}
1453
1464
}
1454
1465
1455
1466
#[ unstable( feature = "termination_trait_lib" , issue = "43301" ) ]
1456
- impl Termination for i32 {
1467
+ impl Termination for ExitCode {
1457
1468
fn report ( self ) -> i32 {
1458
- self
1469
+ let ExitCode ( code) = self ;
1470
+ code
1459
1471
}
1460
1472
}
1461
1473
0 commit comments