Skip to content

Commit 3730892

Browse files
authored
Unrolled build for rust-lang#140458
Rollup merge of rust-lang#140458 - azhogin:azhogin/async-drop-fix-dropped-tuple-ice, r=oli-obk Fix for async drop ice with partly dropped tuple Fixes rust-lang#140427. Problem was with block data access with block id from new added blocks in patch.
2 parents 251cda5 + cce706e commit 3730892

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

compiler/rustc_mir_transform/src/elaborate_drop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ where
376376
if self.tcx().features().async_drop()
377377
&& self.elaborator.body().coroutine.is_some()
378378
&& self.elaborator.allow_async_drops()
379-
&& !self.elaborator.body()[bb].is_cleanup
379+
&& !self.elaborator.patch_ref().block(self.elaborator.body(), bb).is_cleanup
380380
&& drop_ty.needs_async_drop(self.tcx(), self.elaborator.typing_env())
381381
{
382382
self.build_async_drop(

compiler/rustc_mir_transform/src/patch.rs

+14-8
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,20 @@ impl<'tcx> MirPatch<'tcx> {
148148
self.term_patch_map[bb].is_some()
149149
}
150150

151+
/// Universal getter for block data, either it is in 'old' blocks or in patched ones
152+
pub(crate) fn block<'a>(
153+
&'a self,
154+
body: &'a Body<'tcx>,
155+
bb: BasicBlock,
156+
) -> &'a BasicBlockData<'tcx> {
157+
match bb.index().checked_sub(body.basic_blocks.len()) {
158+
Some(new) => &self.new_blocks[new],
159+
None => &body[bb],
160+
}
161+
}
162+
151163
pub(crate) fn terminator_loc(&self, body: &Body<'tcx>, bb: BasicBlock) -> Location {
152-
let offset = match bb.index().checked_sub(body.basic_blocks.len()) {
153-
Some(index) => self.new_blocks[index].statements.len(),
154-
None => body[bb].statements.len(),
155-
};
164+
let offset = self.block(body, bb).statements.len();
156165
Location { block: bb, statement_index: offset }
157166
}
158167

@@ -284,10 +293,7 @@ impl<'tcx> MirPatch<'tcx> {
284293
}
285294

286295
pub(crate) fn source_info_for_location(&self, body: &Body<'tcx>, loc: Location) -> SourceInfo {
287-
let data = match loc.block.index().checked_sub(body.basic_blocks.len()) {
288-
Some(new) => &self.new_blocks[new],
289-
None => &body[loc.block],
290-
};
296+
let data = self.block(body, loc.block);
291297
Self::source_info_for_index(data, loc)
292298
}
293299
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//@ edition: 2024
2+
//@ build-pass
3+
#![crate_type = "lib"]
4+
#![allow(incomplete_features)]
5+
#![feature(async_drop)]
6+
async fn move_part_await_return_rest_tuple() -> Vec<usize> {
7+
let x = (vec![3], vec![4, 4]);
8+
drop(x.1);
9+
10+
x.0
11+
}

0 commit comments

Comments
 (0)