Simplify with_tlv.

This commit is contained in:
Nicholas Nethercote
2023-02-08 16:24:57 +11:00
parent f7b3e39502
commit 18f751df6a
2 changed files with 3 additions and 3 deletions

View File

@@ -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()
}
}