Skip to content

Commit 06a9dbe

Browse files
committed
Fix a soundness bug in with_tables.
We were able to uplift any value from `Tables` to `'static`, which is unsound.
1 parent 16fadb3 commit 06a9dbe

File tree

1 file changed

+2
-2
lines changed
  • compiler/rustc_smir/src/rustc_internal

1 file changed

+2
-2
lines changed

compiler/rustc_smir/src/rustc_internal/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,12 @@ where
162162

163163
/// Loads the current context and calls a function with it.
164164
/// Do not nest these, as that will ICE.
165-
pub(crate) fn with_tables<'tcx, R>(f: impl FnOnce(&mut Tables<'tcx>) -> R) -> R {
165+
pub(crate) fn with_tables<R>(f: impl for<'tcx> FnOnce(&mut Tables<'tcx>) -> R) -> R {
166166
assert!(TLV.is_set());
167167
TLV.with(|tlv| {
168168
let ptr = tlv.get();
169169
assert!(!ptr.is_null());
170-
let wrapper = ptr as *const TablesWrapper<'tcx>;
170+
let wrapper = ptr as *const TablesWrapper<'_>;
171171
let mut tables = unsafe { (*wrapper).0.borrow_mut() };
172172
f(&mut *tables)
173173
})

0 commit comments

Comments
 (0)