From 4e1147f3406bcd368c50c89242bbba6a6fec5127 Mon Sep 17 00:00:00 2001 From: raph Date: Wed, 5 Apr 2017 20:41:43 +0200 Subject: [PATCH 1/2] Add example to std::process::abort This is a second (2/3?) step in order to complete this issue: https://github.com/rust-lang/rust/issues/29370 I submitted this PR with the help of @steveklabnik again. Thanks to him! More info here: https://github.com/rust-lang/rust/issues/29370#issuecomment-290653877 --- src/libstd/process.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 7f1a00c707c20..95e625888ccee 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -1070,6 +1070,28 @@ pub fn exit(code: i32) -> ! { /// // execution never gets here /// } /// ``` +/// +/// The abort function terminates the process, so the destructor will not get +/// run on the example below: +/// +/// ```no_run +/// use std::process; +/// +/// struct HasDrop; +/// +/// impl Drop for HasDrop { +/// fn drop(&mut self) { +/// println!("This will never be printed!"); +/// } +/// } +/// +/// fn main() { +/// let _x = HasDrop; +/// process::abort(); +/// // the destructor implemented for HasDrop will never get run +/// } +/// ``` +/// #[stable(feature = "process_abort", since = "1.17.0")] pub fn abort() -> ! { unsafe { ::sys::abort_internal() }; From 16c77d7da1d1707a90d94d9eb77e0752f974a0db Mon Sep 17 00:00:00 2001 From: raph Date: Thu, 6 Apr 2017 10:17:32 +0200 Subject: [PATCH 2/2] Update process.rs --- src/libstd/process.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 95e625888ccee..8cfd8fcd8c680 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -1071,8 +1071,8 @@ pub fn exit(code: i32) -> ! { /// } /// ``` /// -/// The abort function terminates the process, so the destructor will not get -/// run on the example below: +/// The [`abort`] function terminates the process, so the destructor will not +/// get run on the example below: /// /// ```no_run /// use std::process; @@ -1091,7 +1091,6 @@ pub fn exit(code: i32) -> ! { /// // the destructor implemented for HasDrop will never get run /// } /// ``` -/// #[stable(feature = "process_abort", since = "1.17.0")] pub fn abort() -> ! { unsafe { ::sys::abort_internal() };