Move 'tcx lifetime on MirPass
This commit is contained in:
parent
42dcd4b7c5
commit
666180c324
@ -30,8 +30,8 @@ pub use self::AddCallGuards::*;
|
||||
*
|
||||
*/
|
||||
|
||||
impl MirPass for AddCallGuards {
|
||||
fn run_pass<'tcx>(&self, _tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
impl<'tcx> MirPass<'tcx> for AddCallGuards {
|
||||
fn run_pass(&self, _tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
self.add_call_guards(body);
|
||||
}
|
||||
}
|
||||
|
@ -39,8 +39,8 @@ use crate::util;
|
||||
|
||||
pub struct AddMovesForPackedDrops;
|
||||
|
||||
impl MirPass for AddMovesForPackedDrops {
|
||||
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
impl<'tcx> MirPass<'tcx> for AddMovesForPackedDrops {
|
||||
fn run_pass(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
debug!("add_moves_for_packed_drops({:?} @ {:?})", src, body.span);
|
||||
add_moves_for_packed_drops(tcx, body, src.def_id());
|
||||
}
|
||||
|
@ -65,8 +65,8 @@ fn may_be_reference<'tcx>(ty: Ty<'tcx>) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
impl MirPass for AddRetag {
|
||||
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
impl<'tcx> MirPass<'tcx> for AddRetag {
|
||||
fn run_pass(&self, tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
if !tcx.sess.opts.debugging_opts.mir_emit_retag {
|
||||
return;
|
||||
}
|
||||
|
@ -26,8 +26,8 @@ pub struct CleanupNonCodegenStatements;
|
||||
|
||||
pub struct DeleteNonCodegenStatements;
|
||||
|
||||
impl MirPass for CleanupNonCodegenStatements {
|
||||
fn run_pass<'tcx>(&self, _tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
impl<'tcx> MirPass<'tcx> for CleanupNonCodegenStatements {
|
||||
fn run_pass(&self, _tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
let mut delete = DeleteNonCodegenStatements;
|
||||
delete.visit_body(body);
|
||||
}
|
||||
|
@ -33,8 +33,8 @@ use crate::transform::{MirPass, MirSource};
|
||||
|
||||
pub struct ConstProp;
|
||||
|
||||
impl MirPass for ConstProp {
|
||||
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
impl<'tcx> MirPass<'tcx> for ConstProp {
|
||||
fn run_pass(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
// will be evaluated by miri and produce its errors there
|
||||
if source.promoted.is_some() {
|
||||
return;
|
||||
|
@ -29,8 +29,8 @@ use crate::util::def_use::DefUseAnalysis;
|
||||
|
||||
pub struct CopyPropagation;
|
||||
|
||||
impl MirPass for CopyPropagation {
|
||||
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
impl<'tcx> MirPass<'tcx> for CopyPropagation {
|
||||
fn run_pass(&self, tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
// We only run when the MIR optimization level is > 1.
|
||||
// This avoids a slow pass, and messing up debug info.
|
||||
if tcx.sess.opts.debugging_opts.mir_opt_level <= 1 {
|
||||
|
@ -5,8 +5,8 @@ use crate::util::expand_aggregate;
|
||||
|
||||
pub struct Deaggregator;
|
||||
|
||||
impl MirPass for Deaggregator {
|
||||
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
impl<'tcx> MirPass<'tcx> for Deaggregator {
|
||||
fn run_pass(&self, tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
let (basic_blocks, local_decls) = body.basic_blocks_and_local_decls_mut();
|
||||
let local_decls = &*local_decls;
|
||||
for bb in basic_blocks {
|
||||
|
@ -13,12 +13,12 @@ use crate::util as mir_util;
|
||||
|
||||
pub struct Marker(pub &'static str);
|
||||
|
||||
impl MirPass for Marker {
|
||||
impl<'tcx> MirPass<'tcx> for Marker {
|
||||
fn name(&self) -> Cow<'_, str> {
|
||||
Cow::Borrowed(self.0)
|
||||
}
|
||||
|
||||
fn run_pass<'tcx>(&self, _tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, _body: &mut Body<'tcx>) {
|
||||
fn run_pass(&self, _tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, _body: &mut Body<'tcx>) {
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,8 +20,8 @@ use syntax_pos::Span;
|
||||
|
||||
pub struct ElaborateDrops;
|
||||
|
||||
impl MirPass for ElaborateDrops {
|
||||
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
impl<'tcx> MirPass<'tcx> for ElaborateDrops {
|
||||
fn run_pass(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
debug!("elaborate_drops({:?} @ {:?})", src, body.span);
|
||||
|
||||
let def_id = src.def_id();
|
||||
|
@ -49,8 +49,8 @@ impl MutVisitor<'tcx> for EraseRegionsVisitor<'tcx> {
|
||||
|
||||
pub struct EraseRegions;
|
||||
|
||||
impl MirPass for EraseRegions {
|
||||
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
impl<'tcx> MirPass<'tcx> for EraseRegions {
|
||||
fn run_pass(&self, tcx: TyCtxt<'tcx>, _: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
EraseRegionsVisitor::new(tcx).visit_body(body);
|
||||
}
|
||||
}
|
||||
|
@ -1115,8 +1115,8 @@ where
|
||||
}).collect()
|
||||
}
|
||||
|
||||
impl MirPass for StateTransform {
|
||||
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
impl<'tcx> MirPass<'tcx> for StateTransform {
|
||||
fn run_pass(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
let yield_ty = if let Some(yield_ty) = body.yield_ty {
|
||||
yield_ty
|
||||
} else {
|
||||
|
@ -37,8 +37,8 @@ struct CallSite<'tcx> {
|
||||
location: SourceInfo,
|
||||
}
|
||||
|
||||
impl MirPass for Inline {
|
||||
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
impl<'tcx> MirPass<'tcx> for Inline {
|
||||
fn run_pass(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
if tcx.sess.opts.debugging_opts.mir_opt_level >= 2 {
|
||||
Inliner { tcx, source }.run_pass(body);
|
||||
}
|
||||
|
@ -11,8 +11,8 @@ use crate::transform::{MirPass, MirSource};
|
||||
|
||||
pub struct InstCombine;
|
||||
|
||||
impl MirPass for InstCombine {
|
||||
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
impl<'tcx> MirPass<'tcx> for InstCombine {
|
||||
fn run_pass(&self, tcx: TyCtxt<'tcx>, _: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
// We only run when optimizing MIR (at any level).
|
||||
if tcx.sess.opts.debugging_opts.mir_opt_level == 0 {
|
||||
return
|
||||
|
@ -137,12 +137,12 @@ pub fn default_name<T: ?Sized>() -> Cow<'static, str> {
|
||||
/// A streamlined trait that you can implement to create a pass; the
|
||||
/// pass will be named after the type, and it will consist of a main
|
||||
/// loop that goes over each available MIR and applies `run_pass`.
|
||||
pub trait MirPass {
|
||||
pub trait MirPass<'tcx> {
|
||||
fn name(&self) -> Cow<'_, str> {
|
||||
default_name::<Self>()
|
||||
}
|
||||
|
||||
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>);
|
||||
fn run_pass(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>);
|
||||
}
|
||||
|
||||
pub fn run_passes(
|
||||
@ -150,7 +150,7 @@ pub fn run_passes(
|
||||
body: &mut Body<'tcx>,
|
||||
instance: InstanceDef<'tcx>,
|
||||
mir_phase: MirPhase,
|
||||
passes: &[&dyn MirPass],
|
||||
passes: &[&dyn MirPass<'tcx>],
|
||||
) {
|
||||
let phase_index = mir_phase.phase_index();
|
||||
|
||||
@ -164,7 +164,7 @@ pub fn run_passes(
|
||||
promoted,
|
||||
};
|
||||
let mut index = 0;
|
||||
let mut run_pass = |pass: &dyn MirPass| {
|
||||
let mut run_pass = |pass: &dyn MirPass<'tcx>| {
|
||||
let run_hooks = |body: &_, index, is_after| {
|
||||
dump_mir::on_mir_pass(tcx, &format_args!("{:03}-{:03}", phase_index, index),
|
||||
&pass.name(), source, body, is_after);
|
||||
|
@ -8,8 +8,8 @@ use crate::transform::{MirPass, MirSource};
|
||||
|
||||
pub struct NoLandingPads;
|
||||
|
||||
impl MirPass for NoLandingPads {
|
||||
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
impl<'tcx> MirPass<'tcx> for NoLandingPads {
|
||||
fn run_pass(&self, tcx: TyCtxt<'tcx>, _: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
no_landing_pads(tcx, body)
|
||||
}
|
||||
}
|
||||
|
@ -1572,8 +1572,8 @@ fn mir_const_qualif(tcx: TyCtxt<'_>, def_id: DefId) -> (u8, &BitSet<Local>) {
|
||||
|
||||
pub struct QualifyAndPromoteConstants;
|
||||
|
||||
impl MirPass for QualifyAndPromoteConstants {
|
||||
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
impl<'tcx> MirPass<'tcx> for QualifyAndPromoteConstants {
|
||||
fn run_pass(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
// There's not really any point in promoting errorful MIR.
|
||||
if body.return_ty().references_error() {
|
||||
tcx.sess.delay_span_bug(body.span, "QualifyAndPromoteConstants: MIR had errors");
|
||||
|
@ -18,8 +18,8 @@ pub fn remove_noop_landing_pads<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>)
|
||||
RemoveNoopLandingPads.remove_nop_landing_pads(body)
|
||||
}
|
||||
|
||||
impl MirPass for RemoveNoopLandingPads {
|
||||
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
impl<'tcx> MirPass<'tcx> for RemoveNoopLandingPads {
|
||||
fn run_pass(&self, tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
remove_noop_landing_pads(tcx, body);
|
||||
}
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ use crate::dataflow::has_rustc_mir_with;
|
||||
|
||||
pub struct SanityCheck;
|
||||
|
||||
impl MirPass for SanityCheck {
|
||||
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
impl<'tcx> MirPass<'tcx> for SanityCheck {
|
||||
fn run_pass(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
let def_id = src.def_id();
|
||||
if !tcx.has_attr(def_id, sym::rustc_mir) {
|
||||
debug!("skipping rustc_peek::SanityCheck on {}", tcx.def_path_str(def_id));
|
||||
|
@ -52,12 +52,12 @@ pub fn simplify_cfg(body: &mut Body<'_>) {
|
||||
body.basic_blocks_mut().raw.shrink_to_fit();
|
||||
}
|
||||
|
||||
impl MirPass for SimplifyCfg {
|
||||
impl<'tcx> MirPass<'tcx> for SimplifyCfg {
|
||||
fn name(&self) -> Cow<'_, str> {
|
||||
Cow::Borrowed(&self.label)
|
||||
}
|
||||
|
||||
fn run_pass<'tcx>(&self, _tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
fn run_pass(&self, _tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
debug!("SimplifyCfg({:?}) - simplifying {:?}", self.label, body);
|
||||
simplify_cfg(body);
|
||||
}
|
||||
@ -292,8 +292,8 @@ pub fn remove_dead_blocks(body: &mut Body<'_>) {
|
||||
|
||||
pub struct SimplifyLocals;
|
||||
|
||||
impl MirPass for SimplifyLocals {
|
||||
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
impl<'tcx> MirPass<'tcx> for SimplifyLocals {
|
||||
fn run_pass(&self, tcx: TyCtxt<'tcx>, _: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
let mut marker = DeclMarker { locals: BitSet::new_empty(body.local_decls.len()) };
|
||||
marker.visit_body(body);
|
||||
// Return pointer and arguments are always live
|
||||
|
@ -14,12 +14,12 @@ impl SimplifyBranches {
|
||||
}
|
||||
}
|
||||
|
||||
impl MirPass for SimplifyBranches {
|
||||
impl<'tcx> MirPass<'tcx> for SimplifyBranches {
|
||||
fn name(&self) -> Cow<'_, str> {
|
||||
Cow::Borrowed(&self.label)
|
||||
}
|
||||
|
||||
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
fn run_pass(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
let param_env = tcx.param_env(src.def_id());
|
||||
for block in body.basic_blocks_mut() {
|
||||
let terminator = block.terminator_mut();
|
||||
|
@ -36,8 +36,8 @@ use crate::util::patch::MirPatch;
|
||||
|
||||
pub struct UniformArrayMoveOut;
|
||||
|
||||
impl MirPass for UniformArrayMoveOut {
|
||||
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
impl<'tcx> MirPass<'tcx> for UniformArrayMoveOut {
|
||||
fn run_pass(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
let mut patch = MirPatch::new(body);
|
||||
let param_env = tcx.param_env(src.def_id());
|
||||
{
|
||||
@ -184,8 +184,8 @@ impl<'a, 'tcx> UniformArrayMoveOutVisitor<'a, 'tcx> {
|
||||
|
||||
pub struct RestoreSubsliceArrayMoveOut;
|
||||
|
||||
impl MirPass for RestoreSubsliceArrayMoveOut {
|
||||
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
impl<'tcx> MirPass<'tcx> for RestoreSubsliceArrayMoveOut {
|
||||
fn run_pass(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
let mut patch = MirPatch::new(body);
|
||||
let param_env = tcx.param_env(src.def_id());
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user