From 34be1516aa0f308d68369fe756b10f3c87ef2e96 Mon Sep 17 00:00:00 2001 From: Mikhail Modin Date: Mon, 13 Nov 2017 15:46:22 +0300 Subject: [PATCH] fix comment, remove redundant code --- .../dataflow/drop_flag_effects.rs | 19 +------------------ src/librustc_mir/dataflow/impls/mod.rs | 5 ++++- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/src/librustc_mir/dataflow/drop_flag_effects.rs b/src/librustc_mir/dataflow/drop_flag_effects.rs index 7ef9cc6fc3f..c1320d9daa8 100644 --- a/src/librustc_mir/dataflow/drop_flag_effects.rs +++ b/src/librustc_mir/dataflow/drop_flag_effects.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use syntax_pos::DUMMY_SP; - use rustc::mir::{self, Mir, Location}; use rustc::ty::{self, TyCtxt}; use util::elaborate_drops::DropFlagState; @@ -187,7 +185,6 @@ pub(crate) fn drop_flag_effects_for_location<'a, 'gcx, 'tcx, F>( where F: FnMut(MovePathIndex, DropFlagState) { let move_data = &ctxt.move_data; - let param_env = ctxt.param_env; debug!("drop_flag_effects_for_location({:?})", loc); // first, move out of the RHS @@ -195,15 +192,6 @@ pub(crate) fn drop_flag_effects_for_location<'a, 'gcx, 'tcx, F>( let path = mi.move_path_index(move_data); debug!("moving out of path {:?}", move_data.move_paths[path]); - // don't move out of non-Copy things - let lvalue = &move_data.move_paths[path].lvalue; - let ty = lvalue.ty(mir, tcx).to_ty(tcx); - let gcx = tcx.global_tcx(); - let erased_ty = gcx.lift(&tcx.erase_regions(&ty)).unwrap(); - if !erased_ty.moves_by_default(gcx, param_env, DUMMY_SP) { - continue; - } - on_all_children_bits(tcx, mir, move_data, path, |mpi| callback(mpi, DropFlagState::Absent)) @@ -231,13 +219,8 @@ pub(crate) fn drop_flag_effects_for_location<'a, 'gcx, 'tcx, F>( } } } - mir::StatementKind::StorageDead(local) => { - on_lookup_result_bits(tcx, mir, move_data, - move_data.rev_lookup.find(&mir::Lvalue::Local(local)), - |mpi| callback(mpi, DropFlagState::Absent)) - - } mir::StatementKind::StorageLive(_) | + mir::StatementKind::StorageDead(_) | mir::StatementKind::InlineAsm { .. } | mir::StatementKind::EndRegion(_) | mir::StatementKind::Validate(..) | diff --git a/src/librustc_mir/dataflow/impls/mod.rs b/src/librustc_mir/dataflow/impls/mod.rs index 524f8ffed83..147f3d796b9 100644 --- a/src/librustc_mir/dataflow/impls/mod.rs +++ b/src/librustc_mir/dataflow/impls/mod.rs @@ -457,7 +457,10 @@ impl<'a, 'gcx, 'tcx> BitDenotation for MovingOutStatements<'a, 'gcx, 'tcx> { let rev_lookup = &move_data.rev_lookup; match stmt.kind { - // skip move out for StorageDead + // this analysis only tries to find moves explicitly + // written by the user, so we ignore the move-outs + // created by `StorageDead` and at the beginning + // of a function. mir::StatementKind::StorageDead(_) => {} _ => { debug!("stmt {:?} at loc {:?} moves out of move_indexes {:?}",