diff options
| author | bors <bors@rust-lang.org> | 2017-08-12 11:57:10 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-08-12 11:57:10 +0000 |
| commit | 456493353867832170045cb063aebf22fa8a7201 (patch) | |
| tree | 64b6b2185fc25409aa802596fa0ed3b0d4c6acb4 /src/libstd/thread/mod.rs | |
| parent | 59f6b8338e866b022941ff78ccc82ccef73a52fd (diff) | |
| parent | 92892d3beb2ab858c6e73df0cf732d2c6f83a4aa (diff) | |
| download | rust-456493353867832170045cb063aebf22fa8a7201.tar.gz rust-456493353867832170045cb063aebf22fa8a7201.zip | |
Auto merge of #43746 - eddyb:sound-thread-local, r=alexcrichton
Check #[thread_local] statics correctly in the compiler. Fixes #43733 by introducing `#[allow_internal_unsafe]` analogous to `#[allow_internal_unstable]`, for letting a macro expand to `unsafe` blocks and functions even in `#![forbid(unsafe_code)]` crates. Fixes #17954 by not letting references to `#[thread_local]` statics escape the function they're taken in - we can't just use a magical lifetime because Rust has *lifetime parametrism*, so if we added the often-proposed `'thread` lifetime, we'd have no way to check it in generic code. To avoid potential edge cases in the compiler, the lifetime is actually that of a temporary at the same position, i.e. `&TLS_STATIC` has the same lifetime `&non_const_fn()` would. Referring to `#[thread_local]` `static`s at compile-time is banned now (as per PR discussion). Additionally, to remove `unsafe impl Sync` from `std::thread::local::fast::Key`, `#[thread_local]` statics are now not required to implement `Sync`, as they are not shared between threads.
Diffstat (limited to 'src/libstd/thread/mod.rs')
0 files changed, 0 insertions, 0 deletions
