Skip to content

docs(LocalKey<T>): clarify that T's Drop shouldn't panic #140009

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/std/src/rt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ macro_rules! rtprintpanic {
macro_rules! rtabort {
($($t:tt)*) => {
{
rtprintpanic!("fatal runtime error: {}\n", format_args!($($t)*));
rtprintpanic!("fatal runtime error: {}, aborting\n", format_args!($($t)*));
crate::sys::abort_internal();
}
}
Expand Down
6 changes: 5 additions & 1 deletion library/std/src/thread/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@ use crate::fmt;
///
/// Initialization is dynamically performed on the first call to a setter (e.g.
/// [`with`]) within a thread, and values that implement [`Drop`] get
/// destructed when a thread exits. Some caveats apply, which are explained below.
/// destructed when a thread exits. Some platform-specific caveats apply, which
/// are explained below.
/// Note that, should the destructor panics, the whole process will be [aborted].
///
/// A `LocalKey`'s initializer cannot recursively depend on itself. Using a
/// `LocalKey` in this way may cause panics, aborts or infinite recursion on
/// the first call to `with`.
///
/// [aborted]: crate::process::abort
///
/// # Single-thread Synchronization
///
/// Though there is no potential race with other threads, it is still possible to
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

thread $NAME panicked at tests/fail/panic/tls_macro_const_drop_panic.rs:LL:CC:
ow
fatal runtime error: thread local panicked on drop
fatal runtime error: thread local panicked on drop, aborting
error: abnormal termination: the program aborted execution

error: aborting due to 1 previous error
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

thread $NAME panicked at tests/fail/panic/tls_macro_drop_panic.rs:LL:CC:
ow
fatal runtime error: thread local panicked on drop
fatal runtime error: thread local panicked on drop, aborting
error: abnormal termination: the program aborted execution

error: aborting due to 1 previous error
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/runtime/rt-explody-panic-payloads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ fn main() {
// by QEMU in the stderr whenever a core dump happens. Remove it before the check.
v.strip_suffix("qemu: uncaught target signal 6 (Aborted) - core dumped\n").unwrap_or(v)
})
.map(|v| { v.ends_with("fatal runtime error: drop of the panic payload panicked\n") })
.map(|v| v.ends_with("fatal runtime error: drop of the panic payload panicked, aborting\n"))
.unwrap_or(false));
}
Loading