// 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();
}
// 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();
}
// 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();
}
// 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();
}
// 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();
}
//! `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() ));
//! }
//! }
//!
/// 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() -> !;
#[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
#[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)
#[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
#[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()
+ }
}
/// 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"
}
};
(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[..]);
#[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());
#[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());
"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 {
"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)
// 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();
}
// 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();
}