Skip to content

Commit

Permalink
Auto merge of rust-lang#61373 - tmandry:emit-storagedead-along-unwind…
Browse files Browse the repository at this point in the history
…, r=eddyb

Emit StorageDead along unwind paths for generators

Completion of the work done in rust-lang#60840. That PR made a change to implicitly consider a local `StorageDead` after Drop, but that was incorrect for DropAndReplace (see also rust-lang#61060 which tried to fix this in a different way).

This finally enables the optimization implemented in rust-lang#60187.

r? @eddyb
cc @Zoxc @cramertj @RalfJung
  • Loading branch information
bors committed Jun 6, 2019
2 parents 740668d + 7718b14 commit daf1ed0
Show file tree
Hide file tree
Showing 8 changed files with 247 additions and 97 deletions.
2 changes: 1 addition & 1 deletion src/librustc/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
size,
align,
});
debug!("generator layout: {:#?}", layout);
debug!("generator layout ({:?}): {:#?}", ty, layout);
layout
}

Expand Down
6 changes: 2 additions & 4 deletions src/librustc_mir/build/expr/as_temp.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! See docs in build/expr/mod.rs
use crate::build::{BlockAnd, BlockAndExtension, Builder};
use crate::build::scope::{CachedBlock, DropKind};
use crate::build::scope::DropKind;
use crate::hair::*;
use rustc::middle::region;
use rustc::mir::*;
Expand Down Expand Up @@ -103,9 +103,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
temp_lifetime,
temp_place,
expr_ty,
DropKind::Value {
cached_block: CachedBlock::default(),
},
DropKind::Value,
);
}

Expand Down
6 changes: 2 additions & 4 deletions src/librustc_mir/build/matches/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! This also includes code for pattern bindings in `let` statements and
//! function parameters.
use crate::build::scope::{CachedBlock, DropKind};
use crate::build::scope::DropKind;
use crate::build::ForGuard::{self, OutsideGuard, RefWithinGuard};
use crate::build::{BlockAnd, BlockAndExtension, Builder};
use crate::build::{GuardFrame, GuardFrameLocal, LocalsForNode};
Expand Down Expand Up @@ -557,9 +557,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
region_scope,
&Place::Base(PlaceBase::Local(local_id)),
var_ty,
DropKind::Value {
cached_block: CachedBlock::default(),
},
DropKind::Value,
);
}

Expand Down
5 changes: 2 additions & 3 deletions src/librustc_mir/build/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::build;
use crate::build::scope::{CachedBlock, DropKind};
use crate::build::scope::DropKind;
use crate::hair::cx::Cx;
use crate::hair::{LintLevel, BindingMode, PatternKind};
use crate::shim;
Expand Down Expand Up @@ -912,8 +912,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
// Make sure we drop (parts of) the argument even when not matched on.
self.schedule_drop(
pattern.as_ref().map_or(ast_body.span, |pat| pat.span),
argument_scope, &place, ty,
DropKind::Value { cached_block: CachedBlock::default() },
argument_scope, &place, ty, DropKind::Value,
);

if let Some(pattern) = pattern {
Expand Down
Loading

0 comments on commit daf1ed0

Please sign in to comment.