From 6dfa45d2ed83ecf25bf457201a3d482be42856ca Mon Sep 17 00:00:00 2001 From: Pirh Date: Wed, 27 Sep 2017 21:13:07 +0100 Subject: [PATCH 1/3] Remove extraneous brackets from abort documentation As per #29370 --- src/libstd/process.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 1869ad3ed707a..d1cb90826f9d5 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -1142,7 +1142,7 @@ pub fn exit(code: i32) -> ! { /// } /// ``` /// -/// The [`abort`] function terminates the process, so the destructor will not +/// The `abort` function terminates the process, so the destructor will not /// get run on the example below: /// /// ```no_run From 7ab20c850e23618d4b8acea22e8930a52b783289 Mon Sep 17 00:00:00 2001 From: Pirh Date: Wed, 27 Sep 2017 22:47:21 +0100 Subject: [PATCH 2/3] Explain difference between panic! and abort in abort docs As per #29370 --- src/libstd/process.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/libstd/process.rs b/src/libstd/process.rs index d1cb90826f9d5..fa9ec4b31856b 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -1124,7 +1124,14 @@ pub fn exit(code: i32) -> ! { /// /// Note that because this function never returns, and that it terminates the /// process, no destructors on the current stack or any other thread's stack -/// will be run. If a clean shutdown is needed it is recommended to only call +/// will be run. +/// +/// This is in contrast to the default behaviour of [`panic!`] which unwinds +/// the current thread's stack and calls all destructors. +/// When `panic="abort"` is set, either as an argument to `rustc` or in a +/// crate's Cargo.toml, [`panic!`] and `abort` are equivalent. +/// +/// If a clean shutdown is needed it is recommended to only call /// this function at a known point where there are no more destructors left /// to run. /// @@ -1162,6 +1169,8 @@ pub fn exit(code: i32) -> ! { /// // the destructor implemented for HasDrop will never get run /// } /// ``` +/// +/// [`panic!`]: ../../std/macro.panic.html #[stable(feature = "process_abort", since = "1.17.0")] pub fn abort() -> ! { unsafe { ::sys::abort_internal() }; From 28ef0d1085120d72741bc52fc2dacfe18ebe8a2e Mon Sep 17 00:00:00 2001 From: Pirh Date: Mon, 2 Oct 2017 19:59:50 +0100 Subject: [PATCH 3/3] Document that process::abort will not call the panic hook --- src/libstd/process.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libstd/process.rs b/src/libstd/process.rs index fa9ec4b31856b..dbb589912153c 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -1129,7 +1129,8 @@ pub fn exit(code: i32) -> ! { /// This is in contrast to the default behaviour of [`panic!`] which unwinds /// the current thread's stack and calls all destructors. /// When `panic="abort"` is set, either as an argument to `rustc` or in a -/// crate's Cargo.toml, [`panic!`] and `abort` are equivalent. +/// crate's Cargo.toml, [`panic!`] and `abort` are similar. However, +/// [`panic!`] will still call the [panic hook] while `abort` will not. /// /// If a clean shutdown is needed it is recommended to only call /// this function at a known point where there are no more destructors left @@ -1171,6 +1172,7 @@ pub fn exit(code: i32) -> ! { /// ``` /// /// [`panic!`]: ../../std/macro.panic.html +/// [panic hook]: ../../std/panic/fn.set_hook.html #[stable(feature = "process_abort", since = "1.17.0")] pub fn abort() -> ! { unsafe { ::sys::abort_internal() };