about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-02-28 11:24:23 +0000
committerbors <bors@rust-lang.org>2018-02-28 11:24:23 +0000
commit0ff9872b2280009f094af0df3dcdc542cc46a5fd (patch)
tree65509a458d8fb7808cc501d6767b68ff7a08ca11 /src/libstd
parentddab91a5debadfda47c057117c8b498a31abaae7 (diff)
parentfed0c4201cb838eeeb1152f83fab88afa87ca825 (diff)
downloadrust-0ff9872b2280009f094af0df3dcdc542cc46a5fd.tar.gz
rust-0ff9872b2280009f094af0df3dcdc542cc46a5fd.zip
Auto merge of #48608 - kennytm:rollup, r=kennytm
Rollup of 15 pull requests

- Successful merges: #48266, #48321, #48365, #48381, #48450, #48473, #48479, #48484, #48488, #48497, #48541, #48548, #48558, #48560, #48565
- Failed merges:
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/process.rs24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/libstd/process.rs b/src/libstd/process.rs
index e25599b8bd8..e5fc33e241c 100644
--- a/src/libstd/process.rs
+++ b/src/libstd/process.rs
@@ -1080,6 +1080,15 @@ impl fmt::Display for ExitStatus {
     }
 }
 
+/// This is ridiculously unstable, as it's a completely-punted-upon part
+/// of the `?`-in-`main` RFC.  It's here only to allow experimenting with
+/// returning a code directly from main.  It will definitely change
+/// drastically before being stabilized, if it doesn't just get deleted.
+#[doc(hidden)]
+#[derive(Clone, Copy, Debug)]
+#[unstable(feature = "process_exitcode_placeholder", issue = "43301")]
+pub struct ExitCode(pub i32);
+
 impl Child {
     /// Forces the child to exit. This is equivalent to sending a
     /// SIGKILL on unix platforms.
@@ -1428,7 +1437,7 @@ impl Termination for () {
 }
 
 #[unstable(feature = "termination_trait_lib", issue = "43301")]
-impl<T: Termination, E: fmt::Debug> Termination for Result<T, E> {
+impl<E: fmt::Debug> Termination for Result<(), E> {
     fn report(self) -> i32 {
         match self {
             Ok(val) => val.report(),
@@ -1442,20 +1451,23 @@ impl<T: Termination, E: fmt::Debug> Termination for Result<T, E> {
 
 #[unstable(feature = "termination_trait_lib", issue = "43301")]
 impl Termination for ! {
-    fn report(self) -> i32 { unreachable!(); }
+    fn report(self) -> i32 { self }
 }
 
 #[unstable(feature = "termination_trait_lib", issue = "43301")]
-impl Termination for bool {
+impl<E: fmt::Debug> Termination for Result<!, E> {
     fn report(self) -> i32 {
-        if self { exit::SUCCESS } else { exit::FAILURE }
+        let Err(err) = self;
+        eprintln!("Error: {:?}", err);
+        exit::FAILURE
     }
 }
 
 #[unstable(feature = "termination_trait_lib", issue = "43301")]
-impl Termination for i32 {
+impl Termination for ExitCode {
     fn report(self) -> i32 {
-        self
+        let ExitCode(code) = self;
+        code
     }
 }