about summary refs log tree commit diff
path: root/src/liballoc/sync.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-05-17 12:49:01 +0000
committerbors <bors@rust-lang.org>2020-05-17 12:49:01 +0000
commit34cce58d81f006a5406fcae918db4492e6cf2784 (patch)
tree963b133e4a094980ea9c302075c7b9a8e13d3ca7 /src/liballoc/sync.rs
parent7faeae0d385730e712634fb2af331ea0140771b4 (diff)
parent5980d972d1911225e38e98fe81974973349793a0 (diff)
downloadrust-34cce58d81f006a5406fcae918db4492e6cf2784.tar.gz
rust-34cce58d81f006a5406fcae918db4492e6cf2784.zip
Auto merge of #72204 - RalfJung:abort, r=Mark-Simulacrum
make abort intrinsic safe, and correct its documentation

Turns out `std::process::abort` is not the same as the intrinsic, the comment was just wrong. Quoting from the unix implementation:
```
// On Unix-like platforms, libc::abort will unregister signal handlers
// including the SIGABRT handler, preventing the abort from being blocked, and
// fclose streams, with the side effect of flushing them so libc buffered
// output will be printed.  Additionally the shell will generally print a more
// understandable error message like "Abort trap" rather than "Illegal
// instruction" that intrinsics::abort would cause, as intrinsics::abort is
// implemented as an illegal instruction.
```
Diffstat (limited to 'src/liballoc/sync.rs')
-rw-r--r--src/liballoc/sync.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs
index 2bcf7633542..2c6d130826b 100644
--- a/src/liballoc/sync.rs
+++ b/src/liballoc/sync.rs
@@ -1096,6 +1096,8 @@ impl<T: ?Sized> Clone for Arc<T> {
         // We abort because such a program is incredibly degenerate, and we
         // don't care to support it.
         if old_size > MAX_REFCOUNT {
+            // remove `unsafe` on bootstrap bump
+            #[cfg_attr(not(bootstrap), allow(unused_unsafe))]
             unsafe {
                 abort();
             }
@@ -1614,6 +1616,8 @@ impl<T: ?Sized> Weak<T> {
 
             // See comments in `Arc::clone` for why we do this (for `mem::forget`).
             if n > MAX_REFCOUNT {
+                // remove `unsafe` on bootstrap bump
+                #[cfg_attr(not(bootstrap), allow(unused_unsafe))]
                 unsafe {
                     abort();
                 }
@@ -1753,6 +1757,7 @@ impl<T: ?Sized> Clone for Weak<T> {
 
         // See comments in Arc::clone() for why we do this (for mem::forget).
         if old_size > MAX_REFCOUNT {
+            #[cfg_attr(not(bootstrap), allow(unused_unsafe))] // remove `unsafe` on bootstrap bump
             unsafe {
                 abort();
             }