Skip to content

Commit ac8797a

Browse files
committed
Auto merge of #61373 - tmandry:emit-storagedead-along-unwind, r=<try>
Emit StorageDead along unwind paths for generators Completion of the work done in #60840. That PR made a change to implicitly consider a local `StorageDead` after Drop, but that was incorrect for DropAndReplace (see also #61060 which tried to fix this in a different way). This finally enables the optimization implemented in #60187. r? @eddyb cc @Zoxc @cramertj @RalfJung
2 parents 0bfbaa6 + a09f605 commit ac8797a

File tree

6 files changed

+98
-98
lines changed

6 files changed

+98
-98
lines changed

src/librustc/ty/layout.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
666666
size,
667667
align,
668668
});
669-
debug!("generator layout: {:#?}", layout);
669+
debug!("generator layout ({:?}): {:#?}", ty, layout);
670670
layout
671671
}
672672

src/librustc_mir/build/expr/as_temp.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! See docs in build/expr/mod.rs
22
33
use crate::build::{BlockAnd, BlockAndExtension, Builder};
4-
use crate::build::scope::{CachedBlock, DropKind};
4+
use crate::build::scope::DropKind;
55
use crate::hair::*;
66
use rustc::middle::region;
77
use rustc::mir::*;
@@ -103,9 +103,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
103103
temp_lifetime,
104104
temp_place,
105105
expr_ty,
106-
DropKind::Value {
107-
cached_block: CachedBlock::default(),
108-
},
106+
DropKind::Value,
109107
);
110108
}
111109

src/librustc_mir/build/matches/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//! This also includes code for pattern bindings in `let` statements and
66
//! function parameters.
77
8-
use crate::build::scope::{CachedBlock, DropKind};
8+
use crate::build::scope::DropKind;
99
use crate::build::ForGuard::{self, OutsideGuard, RefWithinGuard};
1010
use crate::build::{BlockAnd, BlockAndExtension, Builder};
1111
use crate::build::{GuardFrame, GuardFrameLocal, LocalsForNode};
@@ -557,9 +557,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
557557
region_scope,
558558
&Place::Base(PlaceBase::Local(local_id)),
559559
var_ty,
560-
DropKind::Value {
561-
cached_block: CachedBlock::default(),
562-
},
560+
DropKind::Value,
563561
);
564562
}
565563

src/librustc_mir/build/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::build;
2-
use crate::build::scope::{CachedBlock, DropKind};
2+
use crate::build::scope::DropKind;
33
use crate::hair::cx::Cx;
44
use crate::hair::{LintLevel, BindingMode, PatternKind};
55
use crate::shim;
@@ -923,8 +923,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
923923
// Make sure we drop (parts of) the argument even when not matched on.
924924
self.schedule_drop(
925925
pattern.as_ref().map_or(ast_body.span, |pat| pat.span),
926-
argument_scope, &place, ty,
927-
DropKind::Value { cached_block: CachedBlock::default() },
926+
argument_scope, &place, ty, DropKind::Value,
928927
);
929928

930929
if let Some(pattern) = pattern {

0 commit comments

Comments
 (0)