Fix a soundness bug in with_tables
.
We were able to uplift any value from `Tables` to `'static`, which is unsound.
This commit is contained in:
parent
16fadb3f25
commit
06a9dbe5e8
@ -162,12 +162,12 @@ where
|
|||||||
|
|
||||||
/// Loads the current context and calls a function with it.
|
/// Loads the current context and calls a function with it.
|
||||||
/// Do not nest these, as that will ICE.
|
/// Do not nest these, as that will ICE.
|
||||||
pub(crate) fn with_tables<'tcx, R>(f: impl FnOnce(&mut Tables<'tcx>) -> R) -> R {
|
pub(crate) fn with_tables<R>(f: impl for<'tcx> FnOnce(&mut Tables<'tcx>) -> R) -> R {
|
||||||
assert!(TLV.is_set());
|
assert!(TLV.is_set());
|
||||||
TLV.with(|tlv| {
|
TLV.with(|tlv| {
|
||||||
let ptr = tlv.get();
|
let ptr = tlv.get();
|
||||||
assert!(!ptr.is_null());
|
assert!(!ptr.is_null());
|
||||||
let wrapper = ptr as *const TablesWrapper<'tcx>;
|
let wrapper = ptr as *const TablesWrapper<'_>;
|
||||||
let mut tables = unsafe { (*wrapper).0.borrow_mut() };
|
let mut tables = unsafe { (*wrapper).0.borrow_mut() };
|
||||||
f(&mut *tables)
|
f(&mut *tables)
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user