diff options
| author | bors <bors@rust-lang.org> | 2025-04-30 20:42:22 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-04-30 20:42:22 +0000 |
| commit | b45dd71d1824f176fba88f6c40467030a16afa2c (patch) | |
| tree | e411711ed4353d3828f34aebca7bdeda8f357d28 /compiler/rustc_mir_transform | |
| parent | 251cda5e1f0057eb04fd9fc1653f2f1e010e8f97 (diff) | |
| parent | a477172cedb83e1b8295bb20f4bff6e79f9e7bb1 (diff) | |
| download | rust-b45dd71d1824f176fba88f6c40467030a16afa2c.tar.gz rust-b45dd71d1824f176fba88f6c40467030a16afa2c.zip | |
Auto merge of #140529 - matthiaskrgr:rollup-jpaa2ky, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - #140385 (Subtree update of `rust-analyzer`) - #140458 (Fix for async drop ice with partly dropped tuple) - #140465 (chore: edit and move tests) - #140467 (Don't FCW assoc consts in patterns) - #140468 (Minor tweaks to make some normalization (adjacent) code less confusing) - #140470 (CI: rfl: move job forward to Linux v6.15-rc4) - #140476 (chore: delete unused ui/auxiliary crates) - #140481 (Require sanitizers be enabled for asan_odr_windows.rs) - #140486 (rustfmt: Also allow bool literals as first item of let chain) - #140494 (Parser: Document restrictions) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_mir_transform')
| -rw-r--r-- | compiler/rustc_mir_transform/src/elaborate_drop.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_mir_transform/src/patch.rs | 22 |
2 files changed, 15 insertions, 9 deletions
diff --git a/compiler/rustc_mir_transform/src/elaborate_drop.rs b/compiler/rustc_mir_transform/src/elaborate_drop.rs index 6f867f8105d..73a58160a6a 100644 --- a/compiler/rustc_mir_transform/src/elaborate_drop.rs +++ b/compiler/rustc_mir_transform/src/elaborate_drop.rs @@ -376,7 +376,7 @@ where if self.tcx().features().async_drop() && self.elaborator.body().coroutine.is_some() && self.elaborator.allow_async_drops() - && !self.elaborator.body()[bb].is_cleanup + && !self.elaborator.patch_ref().block(self.elaborator.body(), bb).is_cleanup && drop_ty.needs_async_drop(self.tcx(), self.elaborator.typing_env()) { self.build_async_drop( diff --git a/compiler/rustc_mir_transform/src/patch.rs b/compiler/rustc_mir_transform/src/patch.rs index c7eb2a921c7..a872eae15f1 100644 --- a/compiler/rustc_mir_transform/src/patch.rs +++ b/compiler/rustc_mir_transform/src/patch.rs @@ -148,11 +148,20 @@ impl<'tcx> MirPatch<'tcx> { self.term_patch_map[bb].is_some() } + /// Universal getter for block data, either it is in 'old' blocks or in patched ones + pub(crate) fn block<'a>( + &'a self, + body: &'a Body<'tcx>, + bb: BasicBlock, + ) -> &'a BasicBlockData<'tcx> { + match bb.index().checked_sub(body.basic_blocks.len()) { + Some(new) => &self.new_blocks[new], + None => &body[bb], + } + } + pub(crate) fn terminator_loc(&self, body: &Body<'tcx>, bb: BasicBlock) -> Location { - let offset = match bb.index().checked_sub(body.basic_blocks.len()) { - Some(index) => self.new_blocks[index].statements.len(), - None => body[bb].statements.len(), - }; + let offset = self.block(body, bb).statements.len(); Location { block: bb, statement_index: offset } } @@ -284,10 +293,7 @@ impl<'tcx> MirPatch<'tcx> { } pub(crate) fn source_info_for_location(&self, body: &Body<'tcx>, loc: Location) -> SourceInfo { - let data = match loc.block.index().checked_sub(body.basic_blocks.len()) { - Some(new) => &self.new_blocks[new], - None => &body[loc.block], - }; + let data = self.block(body, loc.block); Self::source_info_for_index(data, loc) } } |
