Skip to content

Commit d12f35f

Browse files
committed
make thread local statics actual statics
1 parent a4f6438 commit d12f35f

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/librustc_mir/transform/qualify_consts.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,7 @@ This does not pose a problem by itself because they can't be accessed directly."
935935
| "cttz_nonzero"
936936
| "ctlz"
937937
| "ctlz_nonzero" => {
938+
self.add(Qualif::NOT_PROMOTABLE);
938939
is_const_fn = Some(def_id)
939940
},
940941

src/libstd/io/stdio.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ pub fn set_print(sink: Option<Box<Write + Send>>) -> Option<Box<Write + Send>> {
670670
/// However, if the actual I/O causes an error, this function does panic.
671671
fn print_to<T>(
672672
args: fmt::Arguments,
673-
local_s: &LocalKey<RefCell<Option<Box<Write+Send>>>>,
673+
local_s: &'static LocalKey<RefCell<Option<Box<Write+Send>>>>,
674674
global_s: fn() -> T,
675675
label: &str,
676676
)

src/libstd/thread/local.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ macro_rules! __thread_local_inner {
194194
}
195195
};
196196
($(#[$attr:meta])* $vis:vis $name:ident, $t:ty, $init:expr) => {
197-
$(#[$attr])* $vis const $name: $crate::thread::LocalKey<$t> =
197+
$(#[$attr])* $vis static $name: $crate::thread::LocalKey<$t> =
198198
__thread_local_inner!(@key $(#[$attr])* $vis $name, $t, $init);
199199
}
200200
}
@@ -243,7 +243,7 @@ impl<T: 'static> LocalKey<T> {
243243
/// destructor running, and it **may** panic if the destructor has
244244
/// previously been run for this thread.
245245
#[stable(feature = "rust1", since = "1.0.0")]
246-
pub fn with<F, R>(&self, f: F) -> R
246+
pub fn with<F, R>(&'static self, f: F) -> R
247247
where F: FnOnce(&T) -> R {
248248
self.try_with(f).expect("cannot access a TLS value during or \
249249
after it is destroyed")
@@ -283,7 +283,7 @@ impl<T: 'static> LocalKey<T> {
283283
/// This function will still `panic!()` if the key is uninitialized and the
284284
/// key's initializer panics.
285285
#[stable(feature = "thread_local_try_with", since = "1.26.0")]
286-
pub fn try_with<F, R>(&self, f: F) -> Result<R, AccessError>
286+
pub fn try_with<F, R>(&'static self, f: F) -> Result<R, AccessError>
287287
where
288288
F: FnOnce(&T) -> R,
289289
{

0 commit comments

Comments
 (0)