Auto merge of #3158 - RalfJung:tls-rename, r=RalfJung

more consistent naming for TLS tests

"tls_static" for `#[thread_local] static`, "tls_macro" for `thread_local!`
This commit is contained in:
bors 2023-11-12 16:15:47 +00:00
commit 9721690ac5
17 changed files with 13 additions and 10 deletions

View File

@ -1,4 +1,4 @@
thread $NAME panicked at $DIR/thread_local_const_drop_panic.rs:LL:CC:
thread $NAME panicked at $DIR/tls_macro_const_drop_panic.rs:LL:CC:
ow
fatal runtime error: thread local panicked on drop
error: abnormal termination: the program aborted execution

View File

@ -1,4 +1,4 @@
thread $NAME panicked at $DIR/thread_local_drop_panic.rs:LL:CC:
thread $NAME panicked at $DIR/tls_macro_drop_panic.rs:LL:CC:
ow
fatal runtime error: thread local panicked on drop
error: abnormal termination: the program aborted execution

View File

@ -1,5 +1,5 @@
error: Undefined Behavior: memory access failed: ALLOC has been freed, so this pointer is dangling
--> $DIR/thread_local_static_dealloc.rs:LL:CC
--> $DIR/tls_static_dealloc.rs:LL:CC
|
LL | let _val = *dangling_ptr.0;
| ^^^^^^^^^^^^^^^ memory access failed: ALLOC has been freed, so this pointer is dangling
@ -7,7 +7,7 @@ LL | let _val = *dangling_ptr.0;
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
= note: BACKTRACE:
= note: inside `main` at $DIR/thread_local_static_dealloc.rs:LL:CC
= note: inside `main` at $DIR/tls_static_dealloc.rs:LL:CC
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

View File

@ -10,14 +10,14 @@ LL | __rust_alloc(layout.size(), layout.align())
= note: inside `alloc::alloc::exchange_malloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
= note: inside `std::boxed::Box::<i32>::new` at RUSTLIB/alloc/src/boxed.rs:LL:CC
note: inside closure
--> $DIR/leak_in_lib_tls.rs:LL:CC
--> $DIR/tls_macro_leak.rs:LL:CC
|
LL | cell.set(Some(Box::leak(Box::new(123))));
| ^^^^^^^^^^^^^
= note: inside `std::thread::LocalKey::<std::cell::Cell<std::option::Option<&i32>>>::try_with::<{closure@$DIR/leak_in_lib_tls.rs:LL:CC}, ()>` at RUSTLIB/std/src/thread/local.rs:LL:CC
= note: inside `std::thread::LocalKey::<std::cell::Cell<std::option::Option<&i32>>>::with::<{closure@$DIR/leak_in_lib_tls.rs:LL:CC}, ()>` at RUSTLIB/std/src/thread/local.rs:LL:CC
= note: inside `std::thread::LocalKey::<std::cell::Cell<std::option::Option<&i32>>>::try_with::<{closure@$DIR/tls_macro_leak.rs:LL:CC}, ()>` at RUSTLIB/std/src/thread/local.rs:LL:CC
= note: inside `std::thread::LocalKey::<std::cell::Cell<std::option::Option<&i32>>>::with::<{closure@$DIR/tls_macro_leak.rs:LL:CC}, ()>` at RUSTLIB/std/src/thread/local.rs:LL:CC
note: inside closure
--> $DIR/leak_in_lib_tls.rs:LL:CC
--> $DIR/tls_macro_leak.rs:LL:CC
|
LL | / TLS.with(|cell| {
LL | | cell.set(Some(Box::leak(Box::new(123))));

View File

@ -10,7 +10,7 @@ LL | __rust_alloc(layout.size(), layout.align())
= note: inside `alloc::alloc::exchange_malloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
= note: inside `std::boxed::Box::<i32>::new` at RUSTLIB/alloc/src/boxed.rs:LL:CC
note: inside closure
--> $DIR/leak_in_static_tls.rs:LL:CC
--> $DIR/tls_static_leak.rs:LL:CC
|
LL | TLS.set(Some(Box::leak(Box::new(123))));
| ^^^^^^^^^^^^^

View File

@ -5,6 +5,8 @@ use std::cell::Cell;
// Thread-local variables in the main thread are basically like `static` (they live
// as long as the program does), so make sure we treat them the same for leak purposes.
//
// The test covers both TLS statics and the TLS macro.
pub fn main() {
thread_local! {
static TLS_KEY: Cell<Option<&'static i32>> = Cell::new(None);

View File

@ -1,4 +1,5 @@
//! Check that destructors of the thread locals are executed on all OSes.
//! Check that destructors of the thread locals are executed on all OSes
//! (even when we do not support concurrency, and cannot run the other test).
use std::cell::RefCell;