Get LocalDefId from source instead of passing in
This commit is contained in:
parent
b4bdaa14f2
commit
d3338dcf4d
@ -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,
|
||||
|
@ -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>) {
|
||||
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user