Skip to content

Commit

Permalink
Get LocalDefId from source instead of passing in
Browse files Browse the repository at this point in the history
  • Loading branch information
simonvandel committed Sep 22, 2020
1 parent b4bdaa1 commit d3338dc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_mir/src/transform/mod.rs
Expand Up @@ -462,7 +462,7 @@ fn run_optimization_passes<'tcx>(

// The main optimizations that we do on MIR.
let optimizations: &[&dyn MirPass<'tcx>] = &[
&remove_unneeded_drops::RemoveUnneededDrops::new(def_id),
&remove_unneeded_drops::RemoveUnneededDrops,
&match_branches::MatchBranchSimplification,
// inst combine is after MatchBranchSimplification to clean up Ne(_1, false)
&instcombine::InstCombine,
Expand Down
12 changes: 2 additions & 10 deletions compiler/rustc_mir/src/transform/remove_unneeded_drops.rs
Expand Up @@ -6,15 +6,7 @@ use rustc_middle::mir::visit::Visitor;
use rustc_middle::mir::*;
use rustc_middle::ty::TyCtxt;

pub struct RemoveUnneededDrops {
def_id: LocalDefId,
}

impl RemoveUnneededDrops {
pub fn new(def_id: LocalDefId) -> Self {
Self { def_id }
}
}
pub struct RemoveUnneededDrops;

impl<'tcx> MirPass<'tcx> for RemoveUnneededDrops {
fn run_pass(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>) {
Expand All @@ -23,7 +15,7 @@ impl<'tcx> MirPass<'tcx> for RemoveUnneededDrops {
tcx,
body,
optimizations: vec![],
def_id: self.def_id,
def_id: source.def_id().expect_local(),
};
opt_finder.visit_body(body);
for (loc, target) in opt_finder.optimizations {
Expand Down

0 comments on commit d3338dc

Please sign in to comment.