mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 08:44:35 +00:00
Simplify with_tlv
.
This commit is contained in:
parent
f7b3e39502
commit
18f751df6a
@ -34,6 +34,7 @@
|
||||
#![feature(get_mut_unchecked)]
|
||||
#![feature(if_let_guard)]
|
||||
#![feature(iter_from_generator)]
|
||||
#![feature(local_key_cell_methods)]
|
||||
#![feature(negative_impls)]
|
||||
#![feature(never_type)]
|
||||
#![feature(extern_types)]
|
||||
|
@ -89,9 +89,8 @@ mod tlv {
|
||||
/// This is used to set the pointer to the new `ImplicitCtxt`.
|
||||
#[inline]
|
||||
pub(super) fn with_tlv<F: FnOnce() -> R, R>(value: *const (), f: F) -> R {
|
||||
let old = get_tlv();
|
||||
let _reset = rustc_data_structures::OnDrop(move || TLV.with(|tlv| tlv.set(old)));
|
||||
TLV.with(|tlv| tlv.set(value));
|
||||
let old = TLV.replace(value);
|
||||
let _reset = rustc_data_structures::OnDrop(move || TLV.set(old));
|
||||
f()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user