summary refs log tree commit diff
path: root/library/std/src/thread/local.rs
AgeCommit message (Collapse)AuthorLines
2024-02-23Get rid of some `#[allow(static_mut_refs)]`Pavel Grigorenko-2/+0
2024-02-22Add `rustc_confusables` annotations to some stdlib APIsEsteban Küber-0/+2
Help with common API confusion, like asking for `push` when the data structure really has `append`. ``` error[E0599]: no method named `size` found for struct `Vec<{integer}>` in the current scope --> $DIR/rustc_confusables_std_cases.rs:17:7 | LL | x.size(); | ^^^^ | help: you might have meant to use `len` | LL | x.len(); | ~~~ help: there is a method with a similar name | LL | x.resize(); | ~~~~~~ ``` #59450
2024-02-18Improve wording of static_mut_refObei Sideg-2/+2
Rename `static_mut_ref` lint to `static_mut_refs`.
2024-02-08Step all bootstrap cfgs forwardMark Rousskov-1/+1
This also takes care of other bootstrap-related changes.
2024-01-20Revert example change from PR 116392David Tolnay-4/+1
2024-01-20Allow any expression blocks in `thread_local!`Nikolai Vazquez-3/+6
2024-01-07Update test for `E0796` and `static_mut_ref` lintObei Sideg-0/+2
2024-01-02Update `thread_local` examples to use `local_key_cell_methods`Trevor Gross-18/+32
`local_key_cell_methods` has been stable for a while and provides a much less clunky way to interface with thread-local variables. Additionaly add context to the documentation about why types with interior mutability are needed.
2023-09-26std: broaden the allowed behaviour for recursive TLS initializationjoboet-3/+3
2023-08-22Replace version placeholders with 1.73.0Mark Rousskov-9/+9
2023-08-10Stabilize thread local cell methods.Mara Bos-18/+9
2023-05-15Rollup merge of #110049 - SkiFire13:localkey-with-docs-fix, r=workingjubileeMatthias Krüger-2/+2
Don't claim `LocalKey::with` prevents a reference to be sent across threads The documentation for `LocalKey` claims that `with` yields a reference that cannot be sent across threads, but this is false since you can easily do that with scoped threads. What it actually prevents is the reference from outliving the current thread.
2023-04-27Document `const {}` syntax for `std::thread_local`.Nilstrieb-2/+20
It exists and is pretty cool. More people should use it.
2023-04-26Restructure and rename thread local things in std.Mara Bos-4/+4
2023-04-07Don't claim LocalKey::with prevents a reference to be sent across threadsGiacomo Stevanato-2/+2
2023-03-10Moved thread_local implementation to sys::commonAyush Singh-373/+0
This allows removing all the platform-dependent code from `library/std/src/thread/local.rs` and `library/std/src/thread/mod.rs` Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-03-10Move __thread_local_inner to sysAyush Singh-194/+0
Move __thread_local_inner macro in crate::thread::local to crate::sys. Currently, the tidy check does not fail for `library/std/src/thread/local.rs` even though it contains platform specific code. This is beacause target_family did not exist at the time the tidy checks were written [1]. [1]: https://github.com/rust-lang/rust/pull/105861#discussion_r1125841678 Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-01-17refactor[std]: do not use box syntaxjoboet-2/+1
2022-12-30Auto merge of #106296 - matthiaskrgr:rollup-ukdbqwx, r=matthiaskrgrbors-1/+1
Rollup of 4 pull requests Successful merges: - #99244 (doc: clearer and more correct Iterator::scan) - #103707 (Replace libstd, libcore, liballoc terminology in docs) - #104182 (`IN6ADDR_ANY_INIT` and `IN6ADDR_LOOPBACK_INIT` documentation.) - #106273 (rustdoc: remove redundant CSS `.source .content { overflow: visible }`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-12-30Replace libstd, libcore, liballoc in line comments.jonathanCogan-1/+1
2022-12-28Catch panics in destruction of TLS valuesFlorian Bartels-7/+14
`destroy_value` is/can be called from C code (libc). Unwinding from Rust to C code is undefined behavior, which is why unwinding is caught here.
2022-11-24Revert "Forbid inlining `thread_local!`'s `__getit` function on Windows"Thom Chiovoloni-16/+9
This reverts commit 3099dfdd9fc1a331eb9c53200b310fa1a06e1573.
2022-11-22Forbid inlining `thread_local!`'s `__getit` function on WindowsThom Chiovoloni-9/+16
2022-10-13sync thread_local key conditions exactly with what the macro usesRalf Jung-2/+5
2022-09-27Address feedbackmejrs-1/+1
2022-09-27Wrapper suggestionsmejrs-0/+1
2022-08-22update and extend some comments, and cfg-out some unused codeRalf Jung-0/+3
2022-05-01Fix some links in the standard libraryVadim Petrochenkov-0/+2
2022-04-17Revert "Auto merge of #94373 - erikdesjardins:getitinl, r=Mark-Simulacrum"Erik Desjardins-2/+2
This reverts commit 035a717ee8bf548868fb50b5c7ca562fc4a657a7, reversing changes made to 761e8884858759b21f3374ad610494e68c087a38.
2022-04-12Add missing unsafe marker.Mara Bos-1/+1
This is now necessary because of deny(unsafe_op_in_unsafe_fn).
2022-04-12Add #[deny(unsafe_op_in_unsafe_fn)] to thread_local!(const).Mara Bos-0/+1
This avoids 'unused unsafe' warnings when using this feature inside std.
2022-04-07Use gender neutral termsJames 'zofrex' Sanderson-1/+1
2022-04-02Refer to u8 by absolute path in expansion of thread_localDavid Tolnay-3/+3
2022-04-01Fix `thread_local!` macro to be compatible with `no_implicit_prelude`niluxv-8/+8
Fixes issue #95533
2022-03-29Make the stdlib largely conform to strict provenance.Aria Beingessner-3/+3
Some things like the unwinders and system APIs are not fully conformant, this only covers a lot of low-hanging fruit.
2022-03-05Small fixes in thread local code.Mara Bos-2/+2
2022-03-05Update documentation in thread/local.rs.Mara Bos-6/+26
2022-03-05Add debug asserts in thread local cell set methods.Mara Bos-0/+4
2022-03-05Add tracking issue number for local_key_cell_methods.Mara Bos-9/+9
2022-03-05Rename LocalKey's with_{ref,mut} to with_borrow{,_mut}.Mara Bos-9/+9
2022-03-05Implement RFC 3184 - thread local cell methods.Mara Bos-10/+347
2022-02-25Make TLS __getit #[inline(always)] on non-WindowsErik Desjardins-2/+2
This may improve perf.
2022-01-06Add diagnostic items for macrosAlex Macleod-0/+1
2021-12-14Fix a bunch of typosFrank Steffahn-2/+2
2021-12-05Rollup merge of #91355 - alexcrichton:stabilize-thread-local-const, r=m-ou-seMatthias Krüger-1/+0
std: Stabilize the `thread_local_const_init` feature This commit is intended to follow the stabilization disposition of the FCP that has now finished in #84223. This stabilizes the ability to flag thread local initializers as `const` expressions which enables the macro to generate more efficient code for accessing it, notably removing runtime checks for initialization. More information can also be found in #84223 as well as the tests where the feature usage was removed in this PR. Closes #84223
2021-12-02Document Windows TLS drop behaviourChris Denton-0/+14
2021-11-29std: Stabilize the `thread_local_const_init` featureAlex Crichton-1/+0
This commit is intended to follow the stabilization disposition of the FCP that has now finished in #84223. This stabilizes the ability to flag thread local initializers as `const` expressions which enables the macro to generate more efficient code for accessing it, notably removing runtime checks for initialization. More information can also be found in #84223 as well as the tests where the feature usage was removed in this PR. Closes #84223
2021-11-18Auto merge of #90774 - alexcrichton:tweak-const, r=m-ou-sebors-6/+6
std: Tweak expansion of thread-local const This commit tweaks the expansion of `thread_local!` when combined with a `const { ... }` value to help ensure that the rules which apply to `const { ... }` blocks will be the same as when they're stabilized. Previously with this invocation: thread_local!(static NAME: Type = const { init_expr }); this would generate (on supporting platforms): #[thread_local] static NAME: Type = init_expr; instead the macro now expands to: const INIT_EXPR: Type = init_expr; #[thread_local] static NAME: Type = INIT_EXPR; with the hope that because `init_expr` is defined as a `const` item then it's not accidentally allowing more behavior than if it were put into a `static`. For example on the stabilization issue [this example][ex] now gives the same error both ways. [ex]: https://github.com/rust-lang/rust/issues/84223#issuecomment-953384298
2021-11-10std: Tweak expansion of thread-local constAlex Crichton-6/+6
This commit tweaks the expansion of `thread_local!` when combined with a `const { ... }` value to help ensure that the rules which apply to `const { ... }` blocks will be the same as when they're stabilized. Previously with this invocation: thread_local!(static NAME: Type = const { init_expr }); this would generate (on supporting platforms): #[thread_local] static NAME: Type = init_expr; instead the macro now expands to: const INIT_EXPR: Type = init_expr; #[thread_local] static NAME: Type = INIT_EXPR; with the hope that because `init_expr` is defined as a `const` item then it's not accidentally allowing more behavior than if it were put into a `static`. For example on the stabilization issue [this example][ex] now gives the same error both ways. [ex]: https://github.com/rust-lang/rust/issues/84223#issuecomment-953384298
2021-11-10Review commentsAlex Crichton-1/+1