diff options
| author | Andrew Zhogin <andrew.zhogin@gmail.com> | 2025-04-29 20:41:36 +0700 |
|---|---|---|
| committer | Andrew Zhogin <andrew.zhogin@gmail.com> | 2025-04-29 21:41:15 +0700 |
| commit | cce706ec3c4ed38ecaffc61dac3b835038cdc50b (patch) | |
| tree | 9dd89e73e3e9641623bc993537540f35345d9a68 /compiler/rustc_mir_transform/src/patch.rs | |
| parent | 4c83e55e2d88ff93155be2784b9f64b91b870e99 (diff) | |
| download | rust-cce706ec3c4ed38ecaffc61dac3b835038cdc50b.tar.gz rust-cce706ec3c4ed38ecaffc61dac3b835038cdc50b.zip | |
Fix for async drop ice with partly dropped tuple
Diffstat (limited to 'compiler/rustc_mir_transform/src/patch.rs')
| -rw-r--r-- | compiler/rustc_mir_transform/src/patch.rs | 22 |
1 files changed, 14 insertions, 8 deletions
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) } } |
