Skip to content

Commit 0bcefd9

Browse files
committed
remove visit_terminator_kind from MIR visitor
1 parent f315c35 commit 0bcefd9

File tree

10 files changed

+43
-46
lines changed

10 files changed

+43
-46
lines changed

src/librustc_codegen_ssa/mir/analyze.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,8 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
234234
self.visit_rvalue(rvalue, location);
235235
}
236236

237-
fn visit_terminator_kind(&mut self, kind: &mir::TerminatorKind<'tcx>, location: Location) {
238-
let check = match *kind {
237+
fn visit_terminator(&mut self, terminator: &mir::Terminator<'tcx>, location: Location) {
238+
let check = match terminator.kind {
239239
mir::TerminatorKind::Call { func: mir::Operand::Constant(ref c), ref args, .. } => {
240240
match c.literal.ty.kind {
241241
ty::FnDef(did, _) => Some((did, args)),
@@ -259,7 +259,7 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
259259
}
260260
}
261261

262-
self.super_terminator_kind(kind, location);
262+
self.super_terminator(terminator, location);
263263
}
264264

265265
fn visit_place(&mut self, place: &mir::Place<'tcx>, context: PlaceContext, location: Location) {

src/librustc_middle/mir/visit.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,6 @@ macro_rules! make_mir_visitor {
108108
self.super_terminator(terminator, location);
109109
}
110110

111-
fn visit_terminator_kind(&mut self,
112-
kind: & $($mutability)? TerminatorKind<'tcx>,
113-
location: Location) {
114-
self.super_terminator_kind(kind, location);
115-
}
116-
117111
fn visit_assert_message(&mut self,
118112
msg: & $($mutability)? AssertMessage<'tcx>,
119113
location: Location) {
@@ -413,16 +407,10 @@ macro_rules! make_mir_visitor {
413407

414408
fn super_terminator(&mut self,
415409
terminator: &$($mutability)? Terminator<'tcx>,
416-
location: Location) {
410+
source_location: Location) {
417411
let Terminator { source_info, kind } = terminator;
418412

419413
self.visit_source_info(source_info);
420-
self.visit_terminator_kind(kind, location);
421-
}
422-
423-
fn super_terminator_kind(&mut self,
424-
kind: & $($mutability)? TerminatorKind<'tcx>,
425-
source_location: Location) {
426414
match kind {
427415
TerminatorKind::Goto { .. } |
428416
TerminatorKind::Resume |

src/librustc_mir/borrow_check/invalidation.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use rustc_data_structures::graph::dominators::Dominators;
22
use rustc_middle::mir::visit::Visitor;
33
use rustc_middle::mir::{BasicBlock, Body, Location, Place, Rvalue};
44
use rustc_middle::mir::{BorrowKind, Mutability, Operand};
5-
use rustc_middle::mir::{InlineAsmOperand, TerminatorKind};
5+
use rustc_middle::mir::{InlineAsmOperand, Terminator, TerminatorKind};
66
use rustc_middle::mir::{Statement, StatementKind};
77
use rustc_middle::ty::TyCtxt;
88

@@ -112,10 +112,10 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
112112
self.super_statement(statement, location);
113113
}
114114

115-
fn visit_terminator_kind(&mut self, kind: &TerminatorKind<'tcx>, location: Location) {
115+
fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) {
116116
self.check_activations(location);
117117

118-
match kind {
118+
match &terminator.kind {
119119
TerminatorKind::SwitchInt { ref discr, switch_ty: _, values: _, targets: _ } => {
120120
self.consume_operand(location, discr);
121121
}
@@ -222,7 +222,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
222222
}
223223
}
224224

225-
self.super_terminator_kind(kind, location);
225+
self.super_terminator(terminator, location);
226226
}
227227
}
228228

src/librustc_mir/borrow_check/used_muts.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use rustc_middle::mir::visit::{PlaceContext, Visitor};
2-
use rustc_middle::mir::{Local, Location, Place, Statement, StatementKind, TerminatorKind};
2+
use rustc_middle::mir::{
3+
Local, Location, Place, Statement, StatementKind, Terminator, TerminatorKind,
4+
};
35

46
use rustc_data_structures::fx::FxHashSet;
57

@@ -62,9 +64,9 @@ impl GatherUsedMutsVisitor<'_, '_, '_> {
6264
}
6365

6466
impl<'visit, 'cx, 'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'visit, 'cx, 'tcx> {
65-
fn visit_terminator_kind(&mut self, kind: &TerminatorKind<'tcx>, _location: Location) {
66-
debug!("visit_terminator_kind: kind={:?}", kind);
67-
match &kind {
67+
fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, _location: Location) {
68+
debug!("visit_terminator: terminator={:?}", terminator);
69+
match &terminator.kind {
6870
TerminatorKind::Call { destination: Some((into, _)), .. } => {
6971
self.remove_never_initialized_mut_locals(*into);
7072
}
@@ -73,6 +75,8 @@ impl<'visit, 'cx, 'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'visit, 'cx, 'tc
7375
}
7476
_ => {}
7577
}
78+
79+
// FIXME: no super_terminator?
7680
}
7781

7882
fn visit_statement(&mut self, statement: &Statement<'tcx>, _location: Location) {
@@ -84,6 +88,8 @@ impl<'visit, 'cx, 'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'visit, 'cx, 'tc
8488
);
8589
self.remove_never_initialized_mut_locals(*into);
8690
}
91+
92+
// FIXME: no super_statement?
8793
}
8894

8995
fn visit_local(&mut self, local: &Local, place_context: PlaceContext, location: Location) {
@@ -101,5 +107,7 @@ impl<'visit, 'cx, 'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'visit, 'cx, 'tc
101107
}
102108
}
103109
}
110+
111+
// FIXME: no super_local?
104112
}
105113
}

src/librustc_mir/monomorphize/collector.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -616,11 +616,11 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
616616
self.super_const(constant);
617617
}
618618

619-
fn visit_terminator_kind(&mut self, kind: &mir::TerminatorKind<'tcx>, location: Location) {
620-
debug!("visiting terminator {:?} @ {:?}", kind, location);
619+
fn visit_terminator(&mut self, terminator: &mir::Terminator<'tcx>, location: Location) {
620+
debug!("visiting terminator {:?} @ {:?}", terminator, location);
621621

622622
let tcx = self.tcx;
623-
match *kind {
623+
match terminator.kind {
624624
mir::TerminatorKind::Call { ref func, .. } => {
625625
let callee_ty = func.ty(self.body, tcx);
626626
let callee_ty = self.monomorphize(callee_ty);
@@ -663,7 +663,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
663663
| mir::TerminatorKind::FalseUnwind { .. } => bug!(),
664664
}
665665

666-
self.super_terminator_kind(kind, location);
666+
self.super_terminator(terminator, location);
667667
}
668668

669669
fn visit_local(

src/librustc_mir/transform/check_consts/resolver.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,12 @@ where
121121
self.super_assign(place, rvalue, location);
122122
}
123123

124-
fn visit_terminator_kind(&mut self, kind: &mir::TerminatorKind<'tcx>, location: Location) {
124+
fn visit_terminator(&mut self, terminator: &mir::Terminator<'tcx>, location: Location) {
125125
// The effect of assignment to the return place in `TerminatorKind::Call` is not applied
126126
// here; that occurs in `apply_call_return_effect`.
127127

128-
if let mir::TerminatorKind::DropAndReplace { value, location: dest, .. } = kind {
128+
if let mir::TerminatorKind::DropAndReplace { value, location: dest, .. } = &terminator.kind
129+
{
129130
let qualif = qualifs::in_operand::<Q, _>(
130131
self.ccx,
131132
&mut |l| self.qualifs_per_local.contains(l),
@@ -139,7 +140,7 @@ where
139140

140141
// We need to assign qualifs to the dropped location before visiting the operand that
141142
// replaces it since qualifs can be cleared on move.
142-
self.super_terminator_kind(kind, location);
143+
self.super_terminator(terminator, location);
143144
}
144145
}
145146

src/librustc_mir/transform/generator.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ impl<'tcx> MutVisitor<'tcx> for RenameLocalVisitor<'tcx> {
9393
}
9494
}
9595

96-
fn visit_terminator_kind(&mut self, kind: &mut TerminatorKind<'tcx>, location: Location) {
97-
match kind {
96+
fn visit_terminator(&mut self, terminator: &mut Terminator<'tcx>, location: Location) {
97+
match terminator.kind {
9898
TerminatorKind::Return => {
9999
// Do not replace the implicit `_0` access here, as that's not possible. The
100100
// transform already handles `return` correctly.
101101
}
102-
_ => self.super_terminator_kind(kind, location),
102+
_ => self.super_terminator(terminator, location),
103103
}
104104
}
105105
}

src/librustc_mir/transform/inline.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -731,14 +731,14 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> {
731731
}
732732
}
733733

734-
fn visit_terminator_kind(&mut self, kind: &mut TerminatorKind<'tcx>, loc: Location) {
734+
fn visit_terminator(&mut self, terminator: &mut Terminator<'tcx>, loc: Location) {
735735
// Don't try to modify the implicit `_0` access on return (`return` terminators are
736736
// replaced down below anyways).
737-
if !matches!(kind, TerminatorKind::Return) {
738-
self.super_terminator_kind(kind, loc);
737+
if !matches!(terminator.kind, TerminatorKind::Return) {
738+
self.super_terminator(terminator, loc);
739739
}
740740

741-
match *kind {
741+
match terminator.kind {
742742
TerminatorKind::GeneratorDrop | TerminatorKind::Yield { .. } => bug!(),
743743
TerminatorKind::Goto { ref mut target } => {
744744
*target = self.update_target(*target);
@@ -782,11 +782,11 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> {
782782
}
783783
}
784784
TerminatorKind::Return => {
785-
*kind = TerminatorKind::Goto { target: self.return_block };
785+
terminator.kind = TerminatorKind::Goto { target: self.return_block };
786786
}
787787
TerminatorKind::Resume => {
788788
if let Some(tgt) = self.cleanup_block {
789-
*kind = TerminatorKind::Goto { target: tgt }
789+
terminator.kind = TerminatorKind::Goto { target: tgt }
790790
}
791791
}
792792
TerminatorKind::Abort => {}

src/librustc_mir/transform/no_landing_pads.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ impl<'tcx> MutVisitor<'tcx> for NoLandingPads<'tcx> {
3434
self.tcx
3535
}
3636

37-
fn visit_terminator_kind(&mut self, kind: &mut TerminatorKind<'tcx>, location: Location) {
38-
if let Some(unwind) = kind.unwind_mut() {
37+
fn visit_terminator(&mut self, terminator: &mut Terminator<'tcx>, location: Location) {
38+
if let Some(unwind) = terminator.kind.unwind_mut() {
3939
unwind.take();
4040
}
41-
self.super_terminator_kind(kind, location);
41+
self.super_terminator(terminator, location);
4242
}
4343
}

src/librustc_mir/transform/promote_consts.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,10 @@ impl<'tcx> Visitor<'tcx> for Collector<'_, 'tcx> {
216216
}
217217
}
218218

219-
fn visit_terminator_kind(&mut self, kind: &TerminatorKind<'tcx>, location: Location) {
220-
self.super_terminator_kind(kind, location);
219+
fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) {
220+
self.super_terminator(terminator, location);
221221

222-
match *kind {
222+
match terminator.kind {
223223
TerminatorKind::Call { ref func, .. } => {
224224
if let ty::FnDef(def_id, _) = func.ty(self.ccx.body, self.ccx.tcx).kind {
225225
let fn_sig = self.ccx.tcx.fn_sig(def_id);

0 commit comments

Comments
 (0)