X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibstd%2Fpanic.rs;h=ac8e0daf766bfc4d7df36e7a8545bde1cfd3c778;hb=4436c9d35498e7ae3da261f6141d6d73b915e1e8;hp=577673b7e405b6e3e3de3e86f6636823e366aaed;hpb=31fc42b7f778accb21db8daaf0f0e725948c9d6d;p=rust.git diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs index 577673b7e40..ac8e0daf766 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -7,22 +7,21 @@ use crate::collections; use crate::fmt; use crate::future::Future; -use crate::pin::Pin; use crate::ops::{Deref, DerefMut}; use crate::panicking; -use crate::ptr::{Unique, NonNull}; +use crate::pin::Pin; +use crate::ptr::{NonNull, Unique}; use crate::rc::Rc; -use crate::sync::{Arc, Mutex, RwLock}; -#[cfg(not(bootstrap))] use crate::sync::atomic; +use crate::sync::{Arc, Mutex, RwLock}; use crate::task::{Context, Poll}; use crate::thread::Result; #[stable(feature = "panic_hooks", since = "1.10.0")] -pub use crate::panicking::{take_hook, set_hook}; +pub use crate::panicking::{set_hook, take_hook}; #[stable(feature = "panic_hooks", since = "1.10.0")] -pub use core::panic::{PanicInfo, Location}; +pub use core::panic::{Location, PanicInfo}; /// A marker trait which represents "panic safe" types in Rust. /// @@ -104,8 +103,8 @@ /// [`AssertUnwindSafe`]: ./struct.AssertUnwindSafe.html #[stable(feature = "catch_unwind", since = "1.9.0")] #[rustc_on_unimplemented( - message="the type `{Self}` may not be safely transferred across an unwind boundary", - label="`{Self}` may not be safely transferred across an unwind boundary", + message = "the type `{Self}` may not be safely transferred across an unwind boundary", + label = "`{Self}` may not be safely transferred across an unwind boundary" )] pub auto trait UnwindSafe {} @@ -122,10 +121,10 @@ /// [`UnwindSafe`]: ./trait.UnwindSafe.html #[stable(feature = "catch_unwind", since = "1.9.0")] #[rustc_on_unimplemented( - message="the type `{Self}` may contain interior mutability and a reference may not be safely \ - transferrable across a catch_unwind boundary", - label="`{Self}` may contain interior mutability and a reference may not be safely \ - transferrable across a catch_unwind boundary", + message = "the type `{Self}` may contain interior mutability and a reference may not be safely \ + transferrable across a catch_unwind boundary", + label = "`{Self}` may contain interior mutability and a reference may not be safely \ + transferrable across a catch_unwind boundary" )] pub auto trait RefUnwindSafe {} @@ -188,10 +187,7 @@ /// // ... /// ``` #[stable(feature = "catch_unwind", since = "1.9.0")] -pub struct AssertUnwindSafe( - #[stable(feature = "catch_unwind", since = "1.9.0")] - pub T -); +pub struct AssertUnwindSafe(#[stable(feature = "catch_unwind", since = "1.9.0")] pub T); // Implementations of the `UnwindSafe` trait: // @@ -291,7 +287,12 @@ impl RefUnwindSafe for atomic::AtomicPtr {} // https://github.com/rust-lang/rust/issues/62301 #[stable(feature = "hashbrown", since = "1.36.0")] impl UnwindSafe for collections::HashMap - where K: UnwindSafe, V: UnwindSafe, S: UnwindSafe {} +where + K: UnwindSafe, + V: UnwindSafe, + S: UnwindSafe, +{ +} #[stable(feature = "catch_unwind", since = "1.9.0")] impl Deref for AssertUnwindSafe { @@ -321,9 +322,7 @@ extern "rust-call" fn call_once(self, _args: ()) -> R { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for AssertUnwindSafe { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_tuple("AssertUnwindSafe") - .field(&self.0) - .finish() + f.debug_tuple("AssertUnwindSafe").field(&self.0).finish() } } @@ -392,9 +391,7 @@ fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { /// ``` #[stable(feature = "catch_unwind", since = "1.9.0")] pub fn catch_unwind R + UnwindSafe, R>(f: F) -> Result { - unsafe { - panicking::r#try(f) - } + unsafe { panicking::r#try(f) } } /// Triggers a panic without invoking the panic hook. @@ -426,5 +423,5 @@ pub fn catch_unwind R + UnwindSafe, R>(f: F) -> Result { /// ``` #[stable(feature = "resume_unwind", since = "1.9.0")] pub fn resume_unwind(payload: Box) -> ! { - panicking::update_count_then_panic(payload) + panicking::rust_panic_without_hook(payload) }