Skip to content

Commit a750276

Browse files
authored
Rollup merge of rust-lang#41090 - rap2hpoutre:patch-2, r=steveklabnik
Add example to std::process::abort This is a second step in order to complete this issue: rust-lang#29370 I submitted this PR with the help of @steveklabnik again. Thanks to him! More info here: rust-lang#29370 (comment)
2 parents 9516c80 + 16c77d7 commit a750276

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/libstd/process.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,27 @@ pub fn exit(code: i32) -> ! {
10701070
/// // execution never gets here
10711071
/// }
10721072
/// ```
1073+
///
1074+
/// The [`abort`] function terminates the process, so the destructor will not
1075+
/// get run on the example below:
1076+
///
1077+
/// ```no_run
1078+
/// use std::process;
1079+
///
1080+
/// struct HasDrop;
1081+
///
1082+
/// impl Drop for HasDrop {
1083+
/// fn drop(&mut self) {
1084+
/// println!("This will never be printed!");
1085+
/// }
1086+
/// }
1087+
///
1088+
/// fn main() {
1089+
/// let _x = HasDrop;
1090+
/// process::abort();
1091+
/// // the destructor implemented for HasDrop will never get run
1092+
/// }
1093+
/// ```
10731094
#[stable(feature = "process_abort", since = "1.17.0")]
10741095
pub fn abort() -> ! {
10751096
unsafe { ::sys::abort_internal() };

0 commit comments

Comments
 (0)