Skip to content

Commit

Permalink
Rollup merge of rust-lang#77165 - simonvandel:do-not-fire-on-drop-and…
Browse files Browse the repository at this point in the history
…-replace, r=oli-obk

Followup to rust-lang#76673

Resolves rust-lang#76673 (comment)
r? @tmiasko
  • Loading branch information
jonas-schievink authored Sep 25, 2020
2 parents fc4dc5f + 7dec440 commit 8515efb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 2 additions & 0 deletions compiler/rustc_middle/src/mir/terminator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ pub enum TerminatorKind<'tcx> {
/// P <- V
/// }
/// ```
///
/// Note that DropAndReplace is eliminated as part of the `ElaborateDrops` pass.
DropAndReplace {
place: Place<'tcx>,
value: Operand<'tcx>,
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_mir/src/transform/remove_unneeded_drops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ impl<'tcx> MirPass<'tcx> for RemoveUnneededDrops {
impl<'a, 'tcx> Visitor<'tcx> for RemoveUnneededDropsOptimizationFinder<'a, 'tcx> {
fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) {
match terminator.kind {
TerminatorKind::Drop { place, target, .. }
| TerminatorKind::DropAndReplace { place, target, .. } => {
TerminatorKind::Drop { place, target, .. } => {
let ty = place.ty(self.body, self.tcx);
let needs_drop = ty.ty.needs_drop(self.tcx, self.tcx.param_env(self.def_id));
if !needs_drop {
Expand Down

0 comments on commit 8515efb

Please sign in to comment.