about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src/patch.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-02-16 21:23:25 +0000
committerbors <bors@rust-lang.org>2025-02-16 21:23:25 +0000
commitd1fb81e8dd5354ddf7cb334d5a234cab7f64b3bb (patch)
tree80e2993f00d5200299e7d2da384f6b8e0ae67b76 /compiler/rustc_mir_transform/src/patch.rs
parent5bc62314547c7639484481f62f218156697cfef0 (diff)
parente802a8cc015436382fc8b125dddc56016fe5e490 (diff)
downloadrust-d1fb81e8dd5354ddf7cb334d5a234cab7f64b3bb.tar.gz
rust-d1fb81e8dd5354ddf7cb334d5a234cab7f64b3bb.zip
Auto merge of #137143 - matthiaskrgr:rollup-9hapmyd, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #136986 (Apply unsafe_op_in_unsafe_fn to the standard library)
 - #137012 (add docs and ut for bootstrap util cc-detect)
 - #137072 (Load all builtin targets at once instead of one by one in check-cfg)
 - #137102 (Rework `name_regions` to not rely on reverse scc graph for non-member-constrain usages)
 - #137112 (Don't project into `NonNull` when dropping a `Box`)
 - #137114 (Add an example for `std::error::Error`)
 - #137117 (Fix test that relies on error language)
 - #137119 (fix broken `x {doc, build} core`)

r? `@ghost`
`@rustbot` modify labels: rollup
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);