]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #72295 - RalfJung:rollup-icmhbs7, r=RalfJung
authorbors <bors@rust-lang.org>
Sun, 17 May 2020 16:20:19 +0000 (16:20 +0000)
committerbors <bors@rust-lang.org>
Sun, 17 May 2020 16:20:19 +0000 (16:20 +0000)
Rollup of 3 pull requests

Successful merges:

 - #72259 (Disallow forbidden usage of non-ascii identifiers.)
 - #72261 (Break out early on empty span when generate_fn_span)
 - #72291 (bootstrap: fix typo)

Failed merges:

r? @ghost

src/liballoc/rc.rs
src/liballoc/sync.rs
src/libcore/cell.rs
src/libcore/intrinsics.rs
src/libcore/panicking.rs
src/libpanic_unwind/seh.rs
src/librustc_typeck/check/intrinsic.rs
src/libstd/panicking.rs
src/libstd/sync/mpsc/shared.rs
src/libstd/sync/mpsc/sync.rs

index 307f6714f323061c997a86ec7d55af325f42fcee..76213e65bab5aaa08651bf81fd61d50451e4dac7 100644 (file)
@@ -2027,6 +2027,8 @@ fn inc_strong(&self) {
         // nevertheless, we insert an abort here to hint LLVM at
         // an otherwise missed optimization.
         if strong == 0 || strong == usize::max_value() {
+            // remove `unsafe` on bootstrap bump
+            #[cfg_attr(not(bootstrap), allow(unused_unsafe))]
             unsafe {
                 abort();
             }
@@ -2053,6 +2055,8 @@ fn inc_weak(&self) {
         // nevertheless, we insert an abort here to hint LLVM at
         // an otherwise missed optimization.
         if weak == 0 || weak == usize::max_value() {
+            // remove `unsafe` on bootstrap bump
+            #[cfg_attr(not(bootstrap), allow(unused_unsafe))]
             unsafe {
                 abort();
             }
index 2bcf7633542472e086cd49bd1407150c17070b4b..2c6d130826bf3c6dd661b045a51a779170c72e8e 100644 (file)
@@ -1096,6 +1096,8 @@ fn clone(&self) -> 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 @@ pub fn upgrade(&self) -> Option<Arc<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 @@ fn clone(&self) -> 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();
             }
index 0f2665eba6f22f1be3e2e48652129dcfefa53023..fad3095f8a3fcd4b4fe1128516aba2afb198781f 100644 (file)
 //! `Cell<T>`.
 //!
 //! ```
-//! #![feature(core_intrinsics)]
 //! use std::cell::Cell;
 //! use std::ptr::NonNull;
-//! use std::intrinsics::abort;
+//! use std::process::abort;
 //! use std::marker::PhantomData;
 //!
 //! struct Rc<T: ?Sized> {
 //!             .strong
 //!             .set(self.strong()
 //!                      .checked_add(1)
-//!                      .unwrap_or_else(|| unsafe { abort() }));
+//!                      .unwrap_or_else(|| abort() ));
 //!     }
 //! }
 //!
index 962bcbe61985b18eeb621d9755b08350b4ebeb04..43512f7a2366da9980be7e67612765bbe681e2ab 100644 (file)
 
     /// Aborts the execution of the process.
     ///
-    /// The stabilized version of this intrinsic is
+    /// A more user-friendly and stable version of this operation is
     /// [`std::process::abort`](../../std/process/fn.abort.html).
     pub fn abort() -> !;
 
index 94ea9b78828db737d13c551532379d566a3f8e2a..16739b4a1afdf9628f12a713bb0a7b95acfe01a0 100644 (file)
 #[lang = "panic"] // needed by codegen for panic on overflow and other `Assert` MIR terminators
 pub fn panic(expr: &str) -> ! {
     if cfg!(feature = "panic_immediate_abort") {
+        // remove `unsafe` (and safety comment) on bootstrap bump
+        #[cfg_attr(not(bootstrap), allow(unused_unsafe))]
         // SAFETY: the `abort` intrinsic has no requirements to be called.
-        unsafe { super::intrinsics::abort() }
+        unsafe {
+            super::intrinsics::abort()
+        }
     }
 
     // Use Arguments::new_v1 instead of format_args!("{}", expr) to potentially
@@ -58,8 +62,12 @@ pub fn panic(expr: &str) -> ! {
 #[lang = "panic_bounds_check"] // needed by codegen for panic on OOB array/slice access
 fn panic_bounds_check(index: usize, len: usize) -> ! {
     if cfg!(feature = "panic_immediate_abort") {
+        // remove `unsafe` (and safety comment) on bootstrap bump
+        #[cfg_attr(not(bootstrap), allow(unused_unsafe))]
         // SAFETY: the `abort` intrinsic has no requirements to be called.
-        unsafe { super::intrinsics::abort() }
+        unsafe {
+            super::intrinsics::abort()
+        }
     }
 
     panic!("index out of bounds: the len is {} but the index is {}", len, index)
@@ -72,8 +80,12 @@ fn panic_bounds_check(index: usize, len: usize) -> ! {
 #[track_caller]
 pub fn panic_fmt(fmt: fmt::Arguments<'_>) -> ! {
     if cfg!(feature = "panic_immediate_abort") {
+        // remove `unsafe` (and safety comment) on bootstrap bump
+        #[cfg_attr(not(bootstrap), allow(unused_unsafe))]
         // SAFETY: the `abort` intrinsic has no requirements to be called.
-        unsafe { super::intrinsics::abort() }
+        unsafe {
+            super::intrinsics::abort()
+        }
     }
 
     // NOTE This function never crosses the FFI boundary; it's a Rust-to-Rust call
index 8d8276b4159acaedb5c7a609fbd68325c7ebf89c..b1e87a7cac26a5313a7fc371c19032c052daaedb 100644 (file)
@@ -327,5 +327,8 @@ pub unsafe fn cleanup(payload: *mut u8) -> Box<dyn Any + Send> {
 #[lang = "eh_personality"]
 #[cfg(not(test))]
 fn rust_eh_personality() {
-    unsafe { core::intrinsics::abort() }
+    #[cfg_attr(not(bootstrap), allow(unused_unsafe))] // remove `unsafe` on bootstrap bump
+    unsafe {
+        core::intrinsics::abort()
+    }
 }
index 05028ff0b2c26f01d6292a5d7909ef30425ce95c..db6c30adb04cc9d4f5b13500d8c6957a243d394b 100644 (file)
@@ -69,7 +69,7 @@ fn equate_intrinsic_type<'tcx>(
 /// Returns `true` if the given intrinsic is unsafe to call or not.
 pub fn intrinsic_operation_unsafety(intrinsic: &str) -> hir::Unsafety {
     match intrinsic {
-        "size_of" | "min_align_of" | "needs_drop" | "caller_location" | "size_of_val"
+        "abort" | "size_of" | "min_align_of" | "needs_drop" | "caller_location" | "size_of_val"
         | "min_align_of_val" | "add_with_overflow" | "sub_with_overflow" | "mul_with_overflow"
         | "wrapping_add" | "wrapping_sub" | "wrapping_mul" | "saturating_add"
         | "saturating_sub" | "rotate_left" | "rotate_right" | "ctpop" | "ctlz" | "cttz"
@@ -130,7 +130,9 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
             }
         };
         (n_tps, inputs, output, hir::Unsafety::Unsafe)
-    } else if &name[..] == "abort" || &name[..] == "unreachable" {
+    } else if &name[..] == "abort" {
+        (0, Vec::new(), tcx.types.never, hir::Unsafety::Normal)
+    } else if &name[..] == "unreachable" {
         (0, Vec::new(), tcx.types.never, hir::Unsafety::Unsafe)
     } else {
         let unsafety = intrinsic_operation_unsafety(&name[..]);
index 343b2ee12735f2c7dc5845b4eb42b04abeb8d003..bf381896a22bbe7bf22519c7136dc42998479fe0 100644 (file)
@@ -332,7 +332,10 @@ pub fn panicking() -> bool {
 #[cfg_attr(feature = "panic_immediate_abort", inline)]
 pub fn begin_panic_fmt(msg: &fmt::Arguments<'_>) -> ! {
     if cfg!(feature = "panic_immediate_abort") {
-        unsafe { intrinsics::abort() }
+        #[cfg_attr(not(bootstrap), allow(unused_unsafe))] // remove `unsafe` on bootstrap bump
+        unsafe {
+            intrinsics::abort()
+        }
     }
 
     let info = PanicInfo::internal_constructor(Some(msg), Location::caller());
@@ -398,7 +401,10 @@ fn get(&mut self) -> &(dyn Any + Send) {
 #[track_caller]
 pub fn begin_panic<M: Any + Send>(msg: M) -> ! {
     if cfg!(feature = "panic_immediate_abort") {
-        unsafe { intrinsics::abort() }
+        #[cfg_attr(not(bootstrap), allow(unused_unsafe))] // remove `unsafe` on bootstrap bump
+        unsafe {
+            intrinsics::abort()
+        }
     }
 
     rust_panic_with_hook(&mut PanicPayload::new(msg), None, Location::caller());
@@ -458,7 +464,10 @@ fn rust_panic_with_hook(
             "thread panicked while processing \
                                        panic. aborting.\n"
         ));
-        unsafe { intrinsics::abort() }
+        #[cfg_attr(not(bootstrap), allow(unused_unsafe))] // remove `unsafe` on bootstrap bump
+        unsafe {
+            intrinsics::abort()
+        }
     }
 
     unsafe {
@@ -493,7 +502,10 @@ fn rust_panic_with_hook(
             "thread panicked while panicking. \
                                        aborting.\n"
         ));
-        unsafe { intrinsics::abort() }
+        #[cfg_attr(not(bootstrap), allow(unused_unsafe))] // remove `unsafe` on bootstrap bump
+        unsafe {
+            intrinsics::abort()
+        }
     }
 
     rust_panic(payload)
index fd9d61e99c2cd2d3b39f935c94cf5573422e3501..d1a46c517574315f32a2c9dd3d3ad8af9c369a07 100644 (file)
@@ -354,6 +354,8 @@ pub fn clone_chan(&self) {
 
         // See comments on Arc::clone() on why we do this (for `mem::forget`).
         if old_count > MAX_REFCOUNT {
+            // remove `unsafe` on bootstrap bump
+            #[cfg_attr(not(bootstrap), allow(unused_unsafe))]
             unsafe {
                 abort();
             }
index 79123903e92a5ac2cdd01676076efdc151778aa0..603764922c5aad76f7d479e09fe9715c0a803950 100644 (file)
@@ -358,6 +358,8 @@ pub fn clone_chan(&self) {
 
         // See comments on Arc::clone() on why we do this (for `mem::forget`).
         if old_count > MAX_REFCOUNT {
+            // remove `unsafe` on bootstrap bump
+            #[cfg_attr(not(bootstrap), allow(unused_unsafe))]
             unsafe {
                 abort();
             }