Skip to content

Commit 666180c

Browse files
committed
Move 'tcx lifetime on MirPass
1 parent 42dcd4b commit 666180c

21 files changed

+48
-48
lines changed

src/librustc_mir/transform/add_call_guards.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ pub use self::AddCallGuards::*;
3030
*
3131
*/
3232

33-
impl MirPass for AddCallGuards {
34-
fn run_pass<'tcx>(&self, _tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>) {
33+
impl<'tcx> MirPass<'tcx> for AddCallGuards {
34+
fn run_pass(&self, _tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>) {
3535
self.add_call_guards(body);
3636
}
3737
}

src/librustc_mir/transform/add_moves_for_packed_drops.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ use crate::util;
3939

4040
pub struct AddMovesForPackedDrops;
4141

42-
impl MirPass for AddMovesForPackedDrops {
43-
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) {
42+
impl<'tcx> MirPass<'tcx> for AddMovesForPackedDrops {
43+
fn run_pass(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) {
4444
debug!("add_moves_for_packed_drops({:?} @ {:?})", src, body.span);
4545
add_moves_for_packed_drops(tcx, body, src.def_id());
4646
}

src/librustc_mir/transform/add_retag.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ fn may_be_reference<'tcx>(ty: Ty<'tcx>) -> bool {
6565
}
6666
}
6767

68-
impl MirPass for AddRetag {
69-
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>) {
68+
impl<'tcx> MirPass<'tcx> for AddRetag {
69+
fn run_pass(&self, tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>) {
7070
if !tcx.sess.opts.debugging_opts.mir_emit_retag {
7171
return;
7272
}

src/librustc_mir/transform/cleanup_post_borrowck.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ pub struct CleanupNonCodegenStatements;
2626

2727
pub struct DeleteNonCodegenStatements;
2828

29-
impl MirPass for CleanupNonCodegenStatements {
30-
fn run_pass<'tcx>(&self, _tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, body: &mut Body<'tcx>) {
29+
impl<'tcx> MirPass<'tcx> for CleanupNonCodegenStatements {
30+
fn run_pass(&self, _tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, body: &mut Body<'tcx>) {
3131
let mut delete = DeleteNonCodegenStatements;
3232
delete.visit_body(body);
3333
}

src/librustc_mir/transform/const_prop.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ use crate::transform::{MirPass, MirSource};
3333

3434
pub struct ConstProp;
3535

36-
impl MirPass for ConstProp {
37-
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>) {
36+
impl<'tcx> MirPass<'tcx> for ConstProp {
37+
fn run_pass(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>) {
3838
// will be evaluated by miri and produce its errors there
3939
if source.promoted.is_some() {
4040
return;

src/librustc_mir/transform/copy_prop.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ use crate::util::def_use::DefUseAnalysis;
2929

3030
pub struct CopyPropagation;
3131

32-
impl MirPass for CopyPropagation {
33-
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, body: &mut Body<'tcx>) {
32+
impl<'tcx> MirPass<'tcx> for CopyPropagation {
33+
fn run_pass(&self, tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, body: &mut Body<'tcx>) {
3434
// We only run when the MIR optimization level is > 1.
3535
// This avoids a slow pass, and messing up debug info.
3636
if tcx.sess.opts.debugging_opts.mir_opt_level <= 1 {

src/librustc_mir/transform/deaggregator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use crate::util::expand_aggregate;
55

66
pub struct Deaggregator;
77

8-
impl MirPass for Deaggregator {
9-
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, body: &mut Body<'tcx>) {
8+
impl<'tcx> MirPass<'tcx> for Deaggregator {
9+
fn run_pass(&self, tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, body: &mut Body<'tcx>) {
1010
let (basic_blocks, local_decls) = body.basic_blocks_and_local_decls_mut();
1111
let local_decls = &*local_decls;
1212
for bb in basic_blocks {

src/librustc_mir/transform/dump_mir.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ use crate::util as mir_util;
1313

1414
pub struct Marker(pub &'static str);
1515

16-
impl MirPass for Marker {
16+
impl<'tcx> MirPass<'tcx> for Marker {
1717
fn name(&self) -> Cow<'_, str> {
1818
Cow::Borrowed(self.0)
1919
}
2020

21-
fn run_pass<'tcx>(&self, _tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, _body: &mut Body<'tcx>) {
21+
fn run_pass(&self, _tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, _body: &mut Body<'tcx>) {
2222
}
2323
}
2424

src/librustc_mir/transform/elaborate_drops.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ use syntax_pos::Span;
2020

2121
pub struct ElaborateDrops;
2222

23-
impl MirPass for ElaborateDrops {
24-
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) {
23+
impl<'tcx> MirPass<'tcx> for ElaborateDrops {
24+
fn run_pass(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) {
2525
debug!("elaborate_drops({:?} @ {:?})", src, body.span);
2626

2727
let def_id = src.def_id();

src/librustc_mir/transform/erase_regions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ impl MutVisitor<'tcx> for EraseRegionsVisitor<'tcx> {
4949

5050
pub struct EraseRegions;
5151

52-
impl MirPass for EraseRegions {
53-
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _: MirSource<'tcx>, body: &mut Body<'tcx>) {
52+
impl<'tcx> MirPass<'tcx> for EraseRegions {
53+
fn run_pass(&self, tcx: TyCtxt<'tcx>, _: MirSource<'tcx>, body: &mut Body<'tcx>) {
5454
EraseRegionsVisitor::new(tcx).visit_body(body);
5555
}
5656
}

src/librustc_mir/transform/generator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,8 +1115,8 @@ where
11151115
}).collect()
11161116
}
11171117

1118-
impl MirPass for StateTransform {
1119-
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>) {
1118+
impl<'tcx> MirPass<'tcx> for StateTransform {
1119+
fn run_pass(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>) {
11201120
let yield_ty = if let Some(yield_ty) = body.yield_ty {
11211121
yield_ty
11221122
} else {

src/librustc_mir/transform/inline.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ struct CallSite<'tcx> {
3737
location: SourceInfo,
3838
}
3939

40-
impl MirPass for Inline {
41-
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>) {
40+
impl<'tcx> MirPass<'tcx> for Inline {
41+
fn run_pass(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>) {
4242
if tcx.sess.opts.debugging_opts.mir_opt_level >= 2 {
4343
Inliner { tcx, source }.run_pass(body);
4444
}

src/librustc_mir/transform/instcombine.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use crate::transform::{MirPass, MirSource};
1111

1212
pub struct InstCombine;
1313

14-
impl MirPass for InstCombine {
15-
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _: MirSource<'tcx>, body: &mut Body<'tcx>) {
14+
impl<'tcx> MirPass<'tcx> for InstCombine {
15+
fn run_pass(&self, tcx: TyCtxt<'tcx>, _: MirSource<'tcx>, body: &mut Body<'tcx>) {
1616
// We only run when optimizing MIR (at any level).
1717
if tcx.sess.opts.debugging_opts.mir_opt_level == 0 {
1818
return

src/librustc_mir/transform/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,20 +137,20 @@ pub fn default_name<T: ?Sized>() -> Cow<'static, str> {
137137
/// A streamlined trait that you can implement to create a pass; the
138138
/// pass will be named after the type, and it will consist of a main
139139
/// loop that goes over each available MIR and applies `run_pass`.
140-
pub trait MirPass {
140+
pub trait MirPass<'tcx> {
141141
fn name(&self) -> Cow<'_, str> {
142142
default_name::<Self>()
143143
}
144144

145-
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>);
145+
fn run_pass(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>);
146146
}
147147

148148
pub fn run_passes(
149149
tcx: TyCtxt<'tcx>,
150150
body: &mut Body<'tcx>,
151151
instance: InstanceDef<'tcx>,
152152
mir_phase: MirPhase,
153-
passes: &[&dyn MirPass],
153+
passes: &[&dyn MirPass<'tcx>],
154154
) {
155155
let phase_index = mir_phase.phase_index();
156156

@@ -164,7 +164,7 @@ pub fn run_passes(
164164
promoted,
165165
};
166166
let mut index = 0;
167-
let mut run_pass = |pass: &dyn MirPass| {
167+
let mut run_pass = |pass: &dyn MirPass<'tcx>| {
168168
let run_hooks = |body: &_, index, is_after| {
169169
dump_mir::on_mir_pass(tcx, &format_args!("{:03}-{:03}", phase_index, index),
170170
&pass.name(), source, body, is_after);

src/librustc_mir/transform/no_landing_pads.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use crate::transform::{MirPass, MirSource};
88

99
pub struct NoLandingPads;
1010

11-
impl MirPass for NoLandingPads {
12-
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _: MirSource<'tcx>, body: &mut Body<'tcx>) {
11+
impl<'tcx> MirPass<'tcx> for NoLandingPads {
12+
fn run_pass(&self, tcx: TyCtxt<'tcx>, _: MirSource<'tcx>, body: &mut Body<'tcx>) {
1313
no_landing_pads(tcx, body)
1414
}
1515
}

src/librustc_mir/transform/qualify_consts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,8 +1572,8 @@ fn mir_const_qualif(tcx: TyCtxt<'_>, def_id: DefId) -> (u8, &BitSet<Local>) {
15721572

15731573
pub struct QualifyAndPromoteConstants;
15741574

1575-
impl MirPass for QualifyAndPromoteConstants {
1576-
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) {
1575+
impl<'tcx> MirPass<'tcx> for QualifyAndPromoteConstants {
1576+
fn run_pass(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) {
15771577
// There's not really any point in promoting errorful MIR.
15781578
if body.return_ty().references_error() {
15791579
tcx.sess.delay_span_bug(body.span, "QualifyAndPromoteConstants: MIR had errors");

src/librustc_mir/transform/remove_noop_landing_pads.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ pub fn remove_noop_landing_pads<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>)
1818
RemoveNoopLandingPads.remove_nop_landing_pads(body)
1919
}
2020

21-
impl MirPass for RemoveNoopLandingPads {
22-
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>) {
21+
impl<'tcx> MirPass<'tcx> for RemoveNoopLandingPads {
22+
fn run_pass(&self, tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>) {
2323
remove_noop_landing_pads(tcx, body);
2424
}
2525
}

src/librustc_mir/transform/rustc_peek.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ use crate::dataflow::has_rustc_mir_with;
2323

2424
pub struct SanityCheck;
2525

26-
impl MirPass for SanityCheck {
27-
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) {
26+
impl<'tcx> MirPass<'tcx> for SanityCheck {
27+
fn run_pass(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) {
2828
let def_id = src.def_id();
2929
if !tcx.has_attr(def_id, sym::rustc_mir) {
3030
debug!("skipping rustc_peek::SanityCheck on {}", tcx.def_path_str(def_id));

src/librustc_mir/transform/simplify.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ pub fn simplify_cfg(body: &mut Body<'_>) {
5252
body.basic_blocks_mut().raw.shrink_to_fit();
5353
}
5454

55-
impl MirPass for SimplifyCfg {
55+
impl<'tcx> MirPass<'tcx> for SimplifyCfg {
5656
fn name(&self) -> Cow<'_, str> {
5757
Cow::Borrowed(&self.label)
5858
}
5959

60-
fn run_pass<'tcx>(&self, _tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>) {
60+
fn run_pass(&self, _tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Body<'tcx>) {
6161
debug!("SimplifyCfg({:?}) - simplifying {:?}", self.label, body);
6262
simplify_cfg(body);
6363
}
@@ -292,8 +292,8 @@ pub fn remove_dead_blocks(body: &mut Body<'_>) {
292292

293293
pub struct SimplifyLocals;
294294

295-
impl MirPass for SimplifyLocals {
296-
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _: MirSource<'tcx>, body: &mut Body<'tcx>) {
295+
impl<'tcx> MirPass<'tcx> for SimplifyLocals {
296+
fn run_pass(&self, tcx: TyCtxt<'tcx>, _: MirSource<'tcx>, body: &mut Body<'tcx>) {
297297
let mut marker = DeclMarker { locals: BitSet::new_empty(body.local_decls.len()) };
298298
marker.visit_body(body);
299299
// Return pointer and arguments are always live

src/librustc_mir/transform/simplify_branches.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ impl SimplifyBranches {
1414
}
1515
}
1616

17-
impl MirPass for SimplifyBranches {
17+
impl<'tcx> MirPass<'tcx> for SimplifyBranches {
1818
fn name(&self) -> Cow<'_, str> {
1919
Cow::Borrowed(&self.label)
2020
}
2121

22-
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) {
22+
fn run_pass(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) {
2323
let param_env = tcx.param_env(src.def_id());
2424
for block in body.basic_blocks_mut() {
2525
let terminator = block.terminator_mut();

src/librustc_mir/transform/uniform_array_move_out.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ use crate::util::patch::MirPatch;
3636

3737
pub struct UniformArrayMoveOut;
3838

39-
impl MirPass for UniformArrayMoveOut {
40-
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) {
39+
impl<'tcx> MirPass<'tcx> for UniformArrayMoveOut {
40+
fn run_pass(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) {
4141
let mut patch = MirPatch::new(body);
4242
let param_env = tcx.param_env(src.def_id());
4343
{
@@ -184,8 +184,8 @@ impl<'a, 'tcx> UniformArrayMoveOutVisitor<'a, 'tcx> {
184184

185185
pub struct RestoreSubsliceArrayMoveOut;
186186

187-
impl MirPass for RestoreSubsliceArrayMoveOut {
188-
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) {
187+
impl<'tcx> MirPass<'tcx> for RestoreSubsliceArrayMoveOut {
188+
fn run_pass(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut Body<'tcx>) {
189189
let mut patch = MirPatch::new(body);
190190
let param_env = tcx.param_env(src.def_id());
191191
{

0 commit comments

Comments
 (0)