Skip to content

Commit 0eeab6b

Browse files
committed
Remove BasicBlock parameter from mir visitor methods
1 parent 597f432 commit 0eeab6b

File tree

19 files changed

+52
-99
lines changed

19 files changed

+52
-99
lines changed

src/librustc/mir/visit.rs

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -88,32 +88,28 @@ macro_rules! make_mir_visitor {
8888
}
8989

9090
fn visit_statement(&mut self,
91-
block: BasicBlock,
9291
statement: & $($mutability)? Statement<'tcx>,
9392
location: Location) {
94-
self.super_statement(block, statement, location);
93+
self.super_statement(statement, location);
9594
}
9695

9796
fn visit_assign(&mut self,
98-
block: BasicBlock,
9997
place: & $($mutability)? Place<'tcx>,
10098
rvalue: & $($mutability)? Rvalue<'tcx>,
10199
location: Location) {
102-
self.super_assign(block, place, rvalue, location);
100+
self.super_assign(place, rvalue, location);
103101
}
104102

105103
fn visit_terminator(&mut self,
106-
block: BasicBlock,
107104
terminator: & $($mutability)? Terminator<'tcx>,
108105
location: Location) {
109-
self.super_terminator(block, terminator, location);
106+
self.super_terminator(terminator, location);
110107
}
111108

112109
fn visit_terminator_kind(&mut self,
113-
block: BasicBlock,
114110
kind: & $($mutability)? TerminatorKind<'tcx>,
115111
location: Location) {
116-
self.super_terminator_kind(block, kind, location);
112+
self.super_terminator_kind(kind, location);
117113
}
118114

119115
fn visit_assert_message(&mut self,
@@ -327,13 +323,13 @@ macro_rules! make_mir_visitor {
327323
let mut index = 0;
328324
for statement in statements {
329325
let location = Location { block: block, statement_index: index };
330-
self.visit_statement(block, statement, location);
326+
self.visit_statement(statement, location);
331327
index += 1;
332328
}
333329

334330
if let Some(terminator) = terminator {
335331
let location = Location { block: block, statement_index: index };
336-
self.visit_terminator(block, terminator, location);
332+
self.visit_terminator(terminator, location);
337333
}
338334
}
339335

@@ -350,7 +346,6 @@ macro_rules! make_mir_visitor {
350346
}
351347

352348
fn super_statement(&mut self,
353-
block: BasicBlock,
354349
statement: & $($mutability)? Statement<'tcx>,
355350
location: Location) {
356351
let Statement {
@@ -361,7 +356,7 @@ macro_rules! make_mir_visitor {
361356
self.visit_source_info(source_info);
362357
match kind {
363358
StatementKind::Assign(place, rvalue) => {
364-
self.visit_assign(block, place, rvalue, location);
359+
self.visit_assign(place, rvalue, location);
365360
}
366361
StatementKind::FakeRead(_, place) => {
367362
self.visit_place(
@@ -415,7 +410,6 @@ macro_rules! make_mir_visitor {
415410
}
416411

417412
fn super_assign(&mut self,
418-
_block: BasicBlock,
419413
place: &$($mutability)? Place<'tcx>,
420414
rvalue: &$($mutability)? Rvalue<'tcx>,
421415
location: Location) {
@@ -428,19 +422,18 @@ macro_rules! make_mir_visitor {
428422
}
429423

430424
fn super_terminator(&mut self,
431-
block: BasicBlock,
432425
terminator: &$($mutability)? Terminator<'tcx>,
433426
location: Location) {
434427
let Terminator { source_info, kind } = terminator;
435428

436429
self.visit_source_info(source_info);
437-
self.visit_terminator_kind(block, kind, location);
430+
self.visit_terminator_kind(kind, location);
438431
}
439432

440433
fn super_terminator_kind(&mut self,
441-
block: BasicBlock,
442434
kind: & $($mutability)? TerminatorKind<'tcx>,
443435
source_location: Location) {
436+
let block = source_location.block;
444437
match kind {
445438
TerminatorKind::Goto { target } => {
446439
self.visit_branch(block, *target);
@@ -890,12 +883,12 @@ macro_rules! make_mir_visitor {
890883
let basic_block = & $($mutability)? mir[location.block];
891884
if basic_block.statements.len() == location.statement_index {
892885
if let Some(ref $($mutability)? terminator) = basic_block.terminator {
893-
self.visit_terminator(location.block, terminator, location)
886+
self.visit_terminator(terminator, location)
894887
}
895888
} else {
896889
let statement = & $($mutability)?
897890
basic_block.statements[location.statement_index];
898-
self.visit_statement(location.block, statement, location)
891+
self.visit_statement(statement, location)
899892
}
900893
}
901894
}
@@ -912,21 +905,21 @@ pub trait MirVisitable<'tcx> {
912905
impl<'tcx> MirVisitable<'tcx> for Statement<'tcx> {
913906
fn apply(&self, location: Location, visitor: &mut dyn Visitor<'tcx>)
914907
{
915-
visitor.visit_statement(location.block, self, location)
908+
visitor.visit_statement(self, location)
916909
}
917910
}
918911

919912
impl<'tcx> MirVisitable<'tcx> for Terminator<'tcx> {
920913
fn apply(&self, location: Location, visitor: &mut dyn Visitor<'tcx>)
921914
{
922-
visitor.visit_terminator(location.block, self, location)
915+
visitor.visit_terminator(self, location)
923916
}
924917
}
925918

926919
impl<'tcx> MirVisitable<'tcx> for Option<Terminator<'tcx>> {
927920
fn apply(&self, location: Location, visitor: &mut dyn Visitor<'tcx>)
928921
{
929-
visitor.visit_terminator(location.block, self.as_ref().unwrap(), location)
922+
visitor.visit_terminator(self.as_ref().unwrap(), location)
930923
}
931924
}
932925

src/librustc_codegen_ssa/mir/analyze.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,10 @@ impl<Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
9797
impl<'mir, 'a: 'mir, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
9898
for LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
9999
fn visit_assign(&mut self,
100-
block: mir::BasicBlock,
101100
place: &mir::Place<'tcx>,
102101
rvalue: &mir::Rvalue<'tcx>,
103102
location: Location) {
104-
debug!("visit_assign(block={:?}, place={:?}, rvalue={:?})", block, place, rvalue);
103+
debug!("visit_assign(place={:?}, rvalue={:?})", place, rvalue);
105104

106105
if let mir::Place::Base(mir::PlaceBase::Local(index)) = *place {
107106
self.assign(index, location);
@@ -120,7 +119,6 @@ impl<'mir, 'a: 'mir, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
120119
}
121120

122121
fn visit_terminator_kind(&mut self,
123-
block: mir::BasicBlock,
124122
kind: &mir::TerminatorKind<'tcx>,
125123
location: Location) {
126124
let check = match *kind {
@@ -148,7 +146,7 @@ impl<'mir, 'a: 'mir, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
148146
}
149147
}
150148

151-
self.super_terminator_kind(block, kind, location);
149+
self.super_terminator_kind(kind, location);
152150
}
153151

154152
fn visit_place(&mut self,

src/librustc_mir/borrow_check/borrow_set.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ struct GatherBorrows<'a, 'gcx: 'tcx, 'tcx: 'a> {
184184
impl<'a, 'gcx, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'gcx, 'tcx> {
185185
fn visit_assign(
186186
&mut self,
187-
block: mir::BasicBlock,
188187
assigned_place: &mir::Place<'tcx>,
189188
rvalue: &mir::Rvalue<'tcx>,
190189
location: mir::Location,
@@ -215,7 +214,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'gcx, 'tcx> {
215214
}
216215
}
217216

218-
self.super_assign(block, assigned_place, rvalue, location)
217+
self.super_assign(assigned_place, rvalue, location)
219218
}
220219

221220
fn visit_local(
@@ -287,15 +286,6 @@ impl<'a, 'gcx, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'gcx, 'tcx> {
287286

288287
return self.super_rvalue(rvalue, location);
289288
}
290-
291-
fn visit_statement(
292-
&mut self,
293-
block: mir::BasicBlock,
294-
statement: &mir::Statement<'tcx>,
295-
location: Location,
296-
) {
297-
return self.super_statement(block, statement, location);
298-
}
299289
}
300290

301291
impl<'a, 'gcx, 'tcx> GatherBorrows<'a, 'gcx, 'tcx> {

src/librustc_mir/borrow_check/nll/constraint_generation.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ impl<'cg, 'cx, 'gcx, 'tcx> Visitor<'tcx> for ConstraintGeneration<'cg, 'cx, 'gcx
100100

101101
fn visit_statement(
102102
&mut self,
103-
block: BasicBlock,
104103
statement: &Statement<'tcx>,
105104
location: Location,
106105
) {
@@ -117,12 +116,11 @@ impl<'cg, 'cx, 'gcx, 'tcx> Visitor<'tcx> for ConstraintGeneration<'cg, 'cx, 'gcx
117116
));
118117
}
119118

120-
self.super_statement(block, statement, location);
119+
self.super_statement(statement, location);
121120
}
122121

123122
fn visit_assign(
124123
&mut self,
125-
block: BasicBlock,
126124
place: &Place<'tcx>,
127125
rvalue: &Rvalue<'tcx>,
128126
location: Location,
@@ -141,12 +139,11 @@ impl<'cg, 'cx, 'gcx, 'tcx> Visitor<'tcx> for ConstraintGeneration<'cg, 'cx, 'gcx
141139
}
142140
}
143141

144-
self.super_assign(block, place, rvalue, location);
142+
self.super_assign(place, rvalue, location);
145143
}
146144

147145
fn visit_terminator(
148146
&mut self,
149-
block: BasicBlock,
150147
terminator: &Terminator<'tcx>,
151148
location: Location,
152149
) {
@@ -167,7 +164,7 @@ impl<'cg, 'cx, 'gcx, 'tcx> Visitor<'tcx> for ConstraintGeneration<'cg, 'cx, 'gcx
167164
}
168165
}
169166

170-
self.super_terminator(block, terminator, location);
167+
self.super_terminator(terminator, location);
171168
}
172169

173170
fn visit_ascribe_user_ty(

src/librustc_mir/borrow_check/nll/invalidation.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ struct InvalidationGenerator<'cx, 'tcx: 'cx, 'gcx: 'tcx> {
5858
impl<'cx, 'tcx, 'gcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx, 'gcx> {
5959
fn visit_statement(
6060
&mut self,
61-
block: BasicBlock,
6261
statement: &Statement<'tcx>,
6362
location: Location,
6463
) {
@@ -134,13 +133,12 @@ impl<'cx, 'tcx, 'gcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx, 'gcx> {
134133
}
135134
}
136135

137-
self.super_statement(block, statement, location);
136+
self.super_statement(statement, location);
138137
}
139138

140139
fn visit_terminator(
141140
&mut self,
142-
block: BasicBlock,
143-
terminator: &Terminator<'tcx>,
141+
kind: &Terminator<'tcx>,
144142
location: Location
145143
) {
146144
self.check_activations(location);
@@ -258,7 +256,7 @@ impl<'cx, 'tcx, 'gcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx, 'gcx> {
258256
}
259257
}
260258

261-
self.super_terminator(block, terminator, location);
259+
self.super_terminator(terminator, location);
262260
}
263261
}
264262

src/librustc_mir/borrow_check/used_muts.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use rustc::mir::visit::{PlaceContext, Visitor};
22
use rustc::mir::{
3-
BasicBlock, Local, Location, Place, PlaceBase, Statement, StatementKind, TerminatorKind
3+
Local, Location, Place, PlaceBase, Statement, StatementKind, TerminatorKind
44
};
55

66
use rustc_data_structures::fx::FxHashSet;
@@ -55,7 +55,6 @@ struct GatherUsedMutsVisitor<'visit, 'cx: 'visit, 'gcx: 'tcx, 'tcx: 'cx> {
5555
impl<'visit, 'cx, 'gcx, 'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'visit, 'cx, 'gcx, 'tcx> {
5656
fn visit_terminator_kind(
5757
&mut self,
58-
_block: BasicBlock,
5958
kind: &TerminatorKind<'tcx>,
6059
_location: Location,
6160
) {
@@ -77,7 +76,6 @@ impl<'visit, 'cx, 'gcx, 'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'visit, 'c
7776

7877
fn visit_statement(
7978
&mut self,
80-
_block: BasicBlock,
8179
statement: &Statement<'tcx>,
8280
_location: Location,
8381
) {

src/librustc_mir/dataflow/impls/borrowed_locals.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl<'a, 'tcx> BitDenotation<'tcx> for HaveBeenBorrowedLocals<'a, 'tcx> {
4444

4545
BorrowedLocalsVisitor {
4646
sets,
47-
}.visit_statement(loc.block, stmt, loc);
47+
}.visit_statement(stmt, loc);
4848

4949
// StorageDead invalidates all borrows and raw pointers to a local
5050
match stmt.kind {
@@ -58,7 +58,7 @@ impl<'a, 'tcx> BitDenotation<'tcx> for HaveBeenBorrowedLocals<'a, 'tcx> {
5858
loc: Location) {
5959
BorrowedLocalsVisitor {
6060
sets,
61-
}.visit_terminator(loc.block, self.mir[loc.block].terminator(), loc);
61+
}.visit_terminator(self.mir[loc.block].terminator(), loc);
6262
}
6363

6464
fn propagate_call_return(

src/librustc_mir/monomorphize/collector.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,6 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
615615
}
616616

617617
fn visit_terminator_kind(&mut self,
618-
block: mir::BasicBlock,
619618
kind: &mir::TerminatorKind<'tcx>,
620619
location: Location) {
621620
debug!("visiting terminator {:?} @ {:?}", kind, location);
@@ -654,7 +653,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
654653
mir::TerminatorKind::FalseUnwind { .. } => bug!(),
655654
}
656655

657-
self.super_terminator_kind(block, kind, location);
656+
self.super_terminator_kind(kind, location);
658657
}
659658

660659
fn visit_place(&mut self,

src/librustc_mir/transform/check_unsafety.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ impl<'a, 'gcx, 'tcx> UnsafetyChecker<'a, 'tcx> {
6565

6666
impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
6767
fn visit_terminator(&mut self,
68-
block: BasicBlock,
6968
terminator: &Terminator<'tcx>,
7069
location: Location)
7170
{
@@ -97,11 +96,10 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
9796
}
9897
}
9998
}
100-
self.super_terminator(block, terminator, location);
99+
self.super_terminator(terminator, location);
101100
}
102101

103102
fn visit_statement(&mut self,
104-
block: BasicBlock,
105103
statement: &Statement<'tcx>,
106104
location: Location)
107105
{
@@ -124,7 +122,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
124122
UnsafetyViolationKind::General)
125123
},
126124
}
127-
self.super_statement(block, statement, location);
125+
self.super_statement(statement, location);
128126
}
129127

130128
fn visit_rvalue(&mut self,

src/librustc_mir/transform/cleanup_post_borrowck.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
//! [`FakeRead`]: rustc::mir::StatementKind::FakeRead
1717
//! [`Nop`]: rustc::mir::StatementKind::Nop
1818
19-
use rustc::mir::{BasicBlock, BorrowKind, Rvalue, Location, Mir};
19+
use rustc::mir::{BorrowKind, Rvalue, Location, Mir};
2020
use rustc::mir::{Statement, StatementKind};
2121
use rustc::mir::visit::MutVisitor;
2222
use rustc::ty::TyCtxt;
@@ -38,7 +38,6 @@ impl MirPass for CleanupNonCodegenStatements {
3838

3939
impl<'tcx> MutVisitor<'tcx> for DeleteNonCodegenStatements {
4040
fn visit_statement(&mut self,
41-
block: BasicBlock,
4241
statement: &mut Statement<'tcx>,
4342
location: Location) {
4443
match statement.kind {
@@ -47,6 +46,6 @@ impl<'tcx> MutVisitor<'tcx> for DeleteNonCodegenStatements {
4746
| StatementKind::FakeRead(..) => statement.make_nop(),
4847
_ => (),
4948
}
50-
self.super_statement(block, statement, location);
49+
self.super_statement(statement, location);
5150
}
5251
}

0 commit comments

Comments
 (0)