Skip to content

Commit 673935f

Browse files
committed
Get LocalDefId from source instead of passing in
1 parent 9d47ecf commit 673935f

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

compiler/rustc_mir/src/transform/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ fn run_optimization_passes<'tcx>(
456456

457457
// The main optimizations that we do on MIR.
458458
let optimizations: &[&dyn MirPass<'tcx>] = &[
459-
&remove_unneeded_drops::RemoveUnneededDrops::new(def_id),
459+
&remove_unneeded_drops::RemoveUnneededDrops,
460460
&match_branches::MatchBranchSimplification,
461461
// inst combine is after MatchBranchSimplification to clean up Ne(_1, false)
462462
&instcombine::InstCombine,

compiler/rustc_mir/src/transform/remove_unneeded_drops.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,7 @@ use rustc_middle::mir::visit::Visitor;
66
use rustc_middle::mir::*;
77
use rustc_middle::ty::TyCtxt;
88

9-
pub struct RemoveUnneededDrops {
10-
def_id: LocalDefId,
11-
}
12-
13-
impl RemoveUnneededDrops {
14-
pub fn new(def_id: LocalDefId) -> Self {
15-
Self { def_id }
16-
}
17-
}
9+
pub struct RemoveUnneededDrops;
1810

1911
impl<'tcx> MirPass<'tcx> for RemoveUnneededDrops {
2012
fn run_pass(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>) {
@@ -23,7 +15,7 @@ impl<'tcx> MirPass<'tcx> for RemoveUnneededDrops {
2315
tcx,
2416
body,
2517
optimizations: vec![],
26-
def_id: self.def_id,
18+
def_id: source.def_id().expect_local(),
2719
};
2820
opt_finder.visit_body(body);
2921
for (loc, target) in opt_finder.optimizations {

0 commit comments

Comments
 (0)