about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-01-19 09:42:30 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-01-19 09:42:30 +0000
commit06a9dbe5e80c55b20f79aac6d32ad7a81cf544d2 (patch)
tree146ed87bc40bf6138ef2f334d261afa072621125
parent16fadb3f252bcfc5ee3f0be09472c9600a052202 (diff)
downloadrust-06a9dbe5e80c55b20f79aac6d32ad7a81cf544d2.tar.gz
rust-06a9dbe5e80c55b20f79aac6d32ad7a81cf544d2.zip
Fix a soundness bug in `with_tables`.
We were able to uplift any value from `Tables` to `'static`, which is unsound.
-rw-r--r--compiler/rustc_smir/src/rustc_internal/mod.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_smir/src/rustc_internal/mod.rs b/compiler/rustc_smir/src/rustc_internal/mod.rs
index b99640d2f2d..cd4ad724b00 100644
--- a/compiler/rustc_smir/src/rustc_internal/mod.rs
+++ b/compiler/rustc_smir/src/rustc_internal/mod.rs
@@ -162,12 +162,12 @@ where
 
 /// Loads the current context and calls a function with it.
 /// 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());
     TLV.with(|tlv| {
         let ptr = tlv.get();
         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() };
         f(&mut *tables)
     })