Skip to content

Commit 18f751d

Browse files
committed
Simplify with_tlv.
1 parent f7b3e39 commit 18f751d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

compiler/rustc_middle/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#![feature(get_mut_unchecked)]
3535
#![feature(if_let_guard)]
3636
#![feature(iter_from_generator)]
37+
#![feature(local_key_cell_methods)]
3738
#![feature(negative_impls)]
3839
#![feature(never_type)]
3940
#![feature(extern_types)]

compiler/rustc_middle/src/ty/context/tls.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,8 @@ mod tlv {
8989
/// This is used to set the pointer to the new `ImplicitCtxt`.
9090
#[inline]
9191
pub(super) fn with_tlv<F: FnOnce() -> R, R>(value: *const (), f: F) -> R {
92-
let old = get_tlv();
93-
let _reset = rustc_data_structures::OnDrop(move || TLV.with(|tlv| tlv.set(old)));
94-
TLV.with(|tlv| tlv.set(value));
92+
let old = TLV.replace(value);
93+
let _reset = rustc_data_structures::OnDrop(move || TLV.set(old));
9594
f()
9695
}
9796
}

0 commit comments

Comments
 (0)