Skip to content

Commit 7ab20c8

Browse files
author
Pirh
committed
Explain difference between panic! and abort in abort docs
As per rust-lang#29370
1 parent 6dfa45d commit 7ab20c8

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/libstd/process.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,14 @@ pub fn exit(code: i32) -> ! {
11241124
///
11251125
/// Note that because this function never returns, and that it terminates the
11261126
/// process, no destructors on the current stack or any other thread's stack
1127-
/// will be run. If a clean shutdown is needed it is recommended to only call
1127+
/// will be run.
1128+
///
1129+
/// This is in contrast to the default behaviour of [`panic!`] which unwinds
1130+
/// the current thread's stack and calls all destructors.
1131+
/// When `panic="abort"` is set, either as an argument to `rustc` or in a
1132+
/// crate's Cargo.toml, [`panic!`] and `abort` are equivalent.
1133+
///
1134+
/// If a clean shutdown is needed it is recommended to only call
11281135
/// this function at a known point where there are no more destructors left
11291136
/// to run.
11301137
///
@@ -1162,6 +1169,8 @@ pub fn exit(code: i32) -> ! {
11621169
/// // the destructor implemented for HasDrop will never get run
11631170
/// }
11641171
/// ```
1172+
///
1173+
/// [`panic!`]: ../../std/macro.panic.html
11651174
#[stable(feature = "process_abort", since = "1.17.0")]
11661175
pub fn abort() -> ! {
11671176
unsafe { ::sys::abort_internal() };

0 commit comments

Comments
 (0)