about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src/patch.rs
diff options
context:
space:
mode:
authorScott McMurray <scottmcm@users.noreply.github.com>2025-02-15 22:39:56 -0800
committerScott McMurray <scottmcm@users.noreply.github.com>2025-02-15 23:20:52 -0800
commit7e35729bfc2bbc0942ce8929d3c4d28cee7ca040 (patch)
treef58c9ee4383cba73ae2761149cca7ea24e8ac49a /compiler/rustc_mir_transform/src/patch.rs
parent54a0f387ea8c7bcb79b8e40c074a484d31b51990 (diff)
downloadrust-7e35729bfc2bbc0942ce8929d3c4d28cee7ca040.tar.gz
rust-7e35729bfc2bbc0942ce8929d3c4d28cee7ca040.zip
Don't project into `NonNull` when dropping a `Box`
Diffstat (limited to 'compiler/rustc_mir_transform/src/patch.rs')
-rw-r--r--compiler/rustc_mir_transform/src/patch.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_mir_transform/src/patch.rs b/compiler/rustc_mir_transform/src/patch.rs
index 72cd9c224f6..b4f6fa514a4 100644
--- a/compiler/rustc_mir_transform/src/patch.rs
+++ b/compiler/rustc_mir_transform/src/patch.rs
@@ -166,6 +166,14 @@ impl<'tcx> MirPatch<'tcx> {
         Local::new(index)
     }
 
+    /// Returns the type of a local that's newly-added in the patch.
+    pub(crate) fn local_ty(&self, local: Local) -> Ty<'tcx> {
+        let local = local.as_usize();
+        assert!(local < self.next_local);
+        let new_local_idx = self.new_locals.len() - (self.next_local - local);
+        self.new_locals[new_local_idx].ty
+    }
+
     pub(crate) fn new_block(&mut self, data: BasicBlockData<'tcx>) -> BasicBlock {
         let block = BasicBlock::new(self.patch_map.len());
         debug!("MirPatch: new_block: {:?}: {:?}", block, data);