Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b7e2157

Browse files
authoredAug 27, 2016
Auto merge of #35542 - scottcarr:visitor_refactor, r=nikomatsakis
[MIR] track Location in MirVisitor, combine Location All the users of MirVisitor::visit_statement implement their own statement index tracking. This PR move the tracking into MirVisitor itself. Also, there were 2 separate implementations of Location that were identical. This PR eliminates one of them.
2 parents 1987131 + c043a27 commit b7e2157

File tree

18 files changed

+278
-254
lines changed

18 files changed

+278
-254
lines changed
 

‎src/librustc/mir/repr.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,3 +1239,14 @@ impl<'a, 'b> GraphSuccessors<'b> for Mir<'a> {
12391239
type Item = BasicBlock;
12401240
type Iter = IntoIter<BasicBlock>;
12411241
}
1242+
1243+
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash, Ord, PartialOrd)]
1244+
pub struct Location {
1245+
/// the location is within this block
1246+
pub block: BasicBlock,
1247+
1248+
/// the location is the start of the this statement; or, if `statement_index`
1249+
/// == num-statements, then the start of the terminator.
1250+
pub statement_index: usize,
1251+
}
1252+

‎src/librustc/mir/visit.rs

Lines changed: 122 additions & 89 deletions
Large diffs are not rendered by default.

‎src/librustc_borrowck/borrowck/mir/dataflow/impls.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
// except according to those terms.
1010

1111
use rustc::ty::TyCtxt;
12-
use rustc::mir::repr::{self, Mir};
12+
use rustc::mir::repr::{self, Mir, Location};
1313
use rustc_data_structures::indexed_vec::Idx;
1414

15-
use super::super::gather_moves::{Location};
1615
use super::super::gather_moves::{MoveOutIndex, MovePathIndex};
1716
use super::super::MoveDataParamEnv;
1817
use super::super::DropFlagState;
@@ -252,7 +251,7 @@ impl<'a, 'tcx> BitDenotation for MaybeInitializedLvals<'a, 'tcx> {
252251
{
253252
drop_flag_effects_for_location(
254253
self.tcx, self.mir, ctxt,
255-
Location { block: bb, index: idx },
254+
Location { block: bb, statement_index: idx },
256255
|path, s| Self::update_bits(sets, path, s)
257256
)
258257
}
@@ -265,7 +264,7 @@ impl<'a, 'tcx> BitDenotation for MaybeInitializedLvals<'a, 'tcx> {
265264
{
266265
drop_flag_effects_for_location(
267266
self.tcx, self.mir, ctxt,
268-
Location { block: bb, index: statements_len },
267+
Location { block: bb, statement_index: statements_len },
269268
|path, s| Self::update_bits(sets, path, s)
270269
)
271270
}
@@ -314,7 +313,7 @@ impl<'a, 'tcx> BitDenotation for MaybeUninitializedLvals<'a, 'tcx> {
314313
{
315314
drop_flag_effects_for_location(
316315
self.tcx, self.mir, ctxt,
317-
Location { block: bb, index: idx },
316+
Location { block: bb, statement_index: idx },
318317
|path, s| Self::update_bits(sets, path, s)
319318
)
320319
}
@@ -327,7 +326,7 @@ impl<'a, 'tcx> BitDenotation for MaybeUninitializedLvals<'a, 'tcx> {
327326
{
328327
drop_flag_effects_for_location(
329328
self.tcx, self.mir, ctxt,
330-
Location { block: bb, index: statements_len },
329+
Location { block: bb, statement_index: statements_len },
331330
|path, s| Self::update_bits(sets, path, s)
332331
)
333332
}
@@ -375,7 +374,7 @@ impl<'a, 'tcx> BitDenotation for DefinitelyInitializedLvals<'a, 'tcx> {
375374
{
376375
drop_flag_effects_for_location(
377376
self.tcx, self.mir, ctxt,
378-
Location { block: bb, index: idx },
377+
Location { block: bb, statement_index: idx },
379378
|path, s| Self::update_bits(sets, path, s)
380379
)
381380
}
@@ -388,7 +387,7 @@ impl<'a, 'tcx> BitDenotation for DefinitelyInitializedLvals<'a, 'tcx> {
388387
{
389388
drop_flag_effects_for_location(
390389
self.tcx, self.mir, ctxt,
391-
Location { block: bb, index: statements_len },
390+
Location { block: bb, statement_index: statements_len },
392391
|path, s| Self::update_bits(sets, path, s)
393392
)
394393
}
@@ -431,7 +430,7 @@ impl<'a, 'tcx> BitDenotation for MovingOutStatements<'a, 'tcx> {
431430
let path_map = &move_data.path_map;
432431
let rev_lookup = &move_data.rev_lookup;
433432

434-
let loc = Location { block: bb, index: idx };
433+
let loc = Location { block: bb, statement_index: idx };
435434
debug!("stmt {:?} at loc {:?} moves out of move_indexes {:?}",
436435
stmt, loc, &loc_map[loc]);
437436
for move_index in &loc_map[loc] {
@@ -473,7 +472,7 @@ impl<'a, 'tcx> BitDenotation for MovingOutStatements<'a, 'tcx> {
473472
let (mir, move_data) = (self.mir, &ctxt.move_data);
474473
let term = mir[bb].terminator();
475474
let loc_map = &move_data.loc_map;
476-
let loc = Location { block: bb, index: statements_len };
475+
let loc = Location { block: bb, statement_index: statements_len };
477476
debug!("terminator {:?} at loc {:?} moves out of move_indexes {:?}",
478477
term, loc, &loc_map[loc]);
479478
let bits_per_block = self.bits_per_block(ctxt);

‎src/librustc_borrowck/borrowck/mir/elaborate_drops.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
use indexed_set::IdxSetBuf;
12-
use super::gather_moves::{MoveData, MovePathIndex, MovePathContent, Location};
12+
use super::gather_moves::{MoveData, MovePathIndex, MovePathContent};
1313
use super::dataflow::{MaybeInitializedLvals, MaybeUninitializedLvals};
1414
use super::dataflow::{DataflowResults};
1515
use super::{drop_flag_effects_for_location, on_all_children_bits};
@@ -146,9 +146,9 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
146146
dead: self.flow_uninits.sets().on_entry_set_for(loc.block.index())
147147
.to_owned(),
148148
};
149-
for stmt in 0..loc.index {
149+
for stmt in 0..loc.statement_index {
150150
data.apply_location(self.tcx, self.mir, self.env,
151-
Location { block: loc.block, index: stmt });
151+
Location { block: loc.block, statement_index: stmt });
152152
}
153153
data
154154
}
@@ -226,7 +226,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
226226

227227
let init_data = self.initialization_data_at(Location {
228228
block: bb,
229-
index: data.statements.len()
229+
statement_index: data.statements.len()
230230
});
231231

232232
let path = self.move_data().rev_lookup.find(location);
@@ -249,7 +249,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
249249
fn elaborate_drops(&mut self)
250250
{
251251
for (bb, data) in self.mir.basic_blocks().iter_enumerated() {
252-
let loc = Location { block: bb, index: data.statements.len() };
252+
let loc = Location { block: bb, statement_index: data.statements.len() };
253253
let terminator = data.terminator();
254254

255255
let resume_block = self.patch.resume_block();
@@ -359,9 +359,9 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
359359
unwind: Some(unwind)
360360
}, bb);
361361
on_all_children_bits(self.tcx, self.mir, self.move_data(), path, |child| {
362-
self.set_drop_flag(Location { block: target, index: 0 },
362+
self.set_drop_flag(Location { block: target, statement_index: 0 },
363363
child, DropFlagState::Present);
364-
self.set_drop_flag(Location { block: unwind, index: 0 },
364+
self.set_drop_flag(Location { block: unwind, statement_index: 0 },
365365
child, DropFlagState::Present);
366366
});
367367
}
@@ -741,7 +741,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
741741
let drop_block = self.drop_block(c);
742742
if update_drop_flag {
743743
self.set_drop_flag(
744-
Location { block: drop_block, index: 0 },
744+
Location { block: drop_block, statement_index: 0 },
745745
c.path,
746746
DropFlagState::Absent
747747
);
@@ -924,7 +924,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
924924
}
925925

926926
fn drop_flags_on_init(&mut self) {
927-
let loc = Location { block: START_BLOCK, index: 0 };
927+
let loc = Location { block: START_BLOCK, statement_index: 0 };
928928
let span = self.patch.source_info_for_location(self.mir, loc).span;
929929
let false_ = self.constant_bool(span, false);
930930
for flag in self.drop_flags.values() {
@@ -939,7 +939,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
939939
} = data.terminator().kind {
940940
assert!(!self.patch.is_patched(bb));
941941

942-
let loc = Location { block: tgt, index: 0 };
942+
let loc = Location { block: tgt, statement_index: 0 };
943943
let path = self.move_data().rev_lookup.find(lv);
944944
on_all_children_bits(
945945
self.tcx, self.mir, self.move_data(), path,
@@ -950,7 +950,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
950950
}
951951

952952
fn drop_flags_for_args(&mut self) {
953-
let loc = Location { block: START_BLOCK, index: 0 };
953+
let loc = Location { block: START_BLOCK, statement_index: 0 };
954954
super::drop_flag_effects_for_function_entry(
955955
self.tcx, self.mir, self.env, |path, ds| {
956956
self.set_drop_flag(loc, path, ds);
@@ -990,7 +990,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
990990
}
991991
}
992992
}
993-
let loc = Location { block: bb, index: i };
993+
let loc = Location { block: bb, statement_index: i };
994994
super::drop_flag_effects_for_location(
995995
self.tcx, self.mir, self.env, loc, |path, ds| {
996996
if ds == DropFlagState::Absent || allow_initializations {
@@ -1008,7 +1008,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
10081008
} = data.terminator().kind {
10091009
assert!(!self.patch.is_patched(bb));
10101010

1011-
let loc = Location { block: bb, index: data.statements.len() };
1011+
let loc = Location { block: bb, statement_index: data.statements.len() };
10121012
let path = self.move_data().rev_lookup.find(lv);
10131013
on_all_children_bits(
10141014
self.tcx, self.mir, self.move_data(), path,

‎src/librustc_borrowck/borrowck/mir/gather_moves.rs

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ impl Index<Location> for LocMap {
160160
type Output = [MoveOutIndex];
161161
fn index(&self, index: Location) -> &Self::Output {
162162
assert!(index.block.index() < self.map.len());
163-
assert!(index.index < self.map[index.block.index()].len());
164-
&self.map[index.block.index()][index.index]
163+
assert!(index.statement_index < self.map[index.block.index()].len());
164+
&self.map[index.block.index()][index.statement_index]
165165
}
166166
}
167167

@@ -200,21 +200,6 @@ impl fmt::Debug for MoveOut {
200200
}
201201
}
202202

203-
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
204-
pub struct Location {
205-
/// block where action is located
206-
pub block: BasicBlock,
207-
/// index within above block; statement when < statments.len) or
208-
/// the terminator (when = statements.len).
209-
pub index: usize,
210-
}
211-
212-
impl fmt::Debug for Location {
213-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
214-
write!(fmt, "{:?}[{}]", self.block, self.index)
215-
}
216-
}
217-
218203
#[derive(Debug)]
219204
pub struct MovePathData<'tcx> {
220205
move_paths: Vec<MovePath<'tcx>>,
@@ -569,7 +554,7 @@ fn gather_moves<'a, 'tcx>(mir: &Mir<'tcx>, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> MoveD
569554
};
570555

571556
for (i, stmt) in bb_data.statements.iter().enumerate() {
572-
let source = Location { block: bb, index: i };
557+
let source = Location { block: bb, statement_index: i };
573558
match stmt.kind {
574559
StatementKind::Assign(ref lval, ref rval) => {
575560
bb_ctxt.builder.create_move_path(lval);
@@ -631,14 +616,14 @@ fn gather_moves<'a, 'tcx>(mir: &Mir<'tcx>, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> MoveD
631616

632617
TerminatorKind::Return => {
633618
let source = Location { block: bb,
634-
index: bb_data.statements.len() };
619+
statement_index: bb_data.statements.len() };
635620
debug!("gather_moves Return on_move_out_lval return {:?}", source);
636621
bb_ctxt.on_move_out_lval(SK::Return, &Lvalue::ReturnPointer, source);
637622
}
638623

639624
TerminatorKind::If { ref cond, targets: _ } => {
640625
let source = Location { block: bb,
641-
index: bb_data.statements.len() };
626+
statement_index: bb_data.statements.len() };
642627
bb_ctxt.on_operand(SK::If, cond, source);
643628
}
644629

@@ -669,20 +654,20 @@ fn gather_moves<'a, 'tcx>(mir: &Mir<'tcx>, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> MoveD
669654

670655
TerminatorKind::Drop { ref location, target: _, unwind: _ } => {
671656
let source = Location { block: bb,
672-
index: bb_data.statements.len() };
657+
statement_index: bb_data.statements.len() };
673658
bb_ctxt.on_move_out_lval(SK::Drop, location, source);
674659
}
675660
TerminatorKind::DropAndReplace { ref location, ref value, .. } => {
676661
let assigned_path = bb_ctxt.builder.move_path_for(location);
677662
bb_ctxt.path_map.fill_to(assigned_path.index());
678663

679664
let source = Location { block: bb,
680-
index: bb_data.statements.len() };
665+
statement_index: bb_data.statements.len() };
681666
bb_ctxt.on_operand(SK::Use, value, source);
682667
}
683668
TerminatorKind::Call { ref func, ref args, ref destination, cleanup: _ } => {
684669
let source = Location { block: bb,
685-
index: bb_data.statements.len() };
670+
statement_index: bb_data.statements.len() };
686671
bb_ctxt.on_operand(SK::CallFn, func, source);
687672
for arg in args {
688673
debug!("gather_moves Call on_operand {:?} {:?}", arg, source);
@@ -757,7 +742,7 @@ impl<'b, 'tcx: 'b> BlockContext<'b, 'tcx> {
757742
stmt_kind: StmtKind,
758743
lval: &Lvalue<'tcx>,
759744
source: Location) {
760-
let i = source.index;
745+
let i = source.statement_index;
761746
let index = MoveOutIndex::new(self.moves.len());
762747

763748
let path = self.builder.move_path_for(lval);

‎src/librustc_borrowck/borrowck/mir/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use rustc::hir;
1919
use rustc::hir::intravisit::{FnKind};
2020

2121
use rustc::mir::repr;
22-
use rustc::mir::repr::{BasicBlock, BasicBlockData, Mir, Statement, Terminator};
22+
use rustc::mir::repr::{BasicBlock, BasicBlockData, Mir, Statement, Terminator, Location};
2323
use rustc::session::Session;
2424
use rustc::ty::{self, TyCtxt};
2525

@@ -35,7 +35,7 @@ use self::dataflow::{DataflowOperator};
3535
use self::dataflow::{Dataflow, DataflowAnalysis, DataflowResults};
3636
use self::dataflow::{MaybeInitializedLvals, MaybeUninitializedLvals};
3737
use self::dataflow::{DefinitelyInitializedLvals};
38-
use self::gather_moves::{MoveData, MovePathIndex, Location};
38+
use self::gather_moves::{MoveData, MovePathIndex};
3939
use self::gather_moves::{MovePathContent, MovePathData};
4040

4141
fn has_rustc_mir_with(attrs: &[ast::Attribute], name: &str) -> Option<P<MetaItem>> {
@@ -367,7 +367,7 @@ fn drop_flag_effects_for_location<'a, 'tcx, F>(
367367
}
368368

369369
let block = &mir[loc.block];
370-
match block.statements.get(loc.index) {
370+
match block.statements.get(loc.statement_index) {
371371
Some(stmt) => match stmt.kind {
372372
repr::StatementKind::SetDiscriminant{ .. } => {
373373
span_bug!(stmt.source_info.span, "SetDiscrimant should not exist during borrowck");

‎src/librustc_borrowck/borrowck/mir/patch.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use super::gather_moves::Location;
1211
use rustc::ty::Ty;
1312
use rustc::mir::repr::*;
1413
use rustc_data_structures::indexed_vec::{IndexVec, Idx};
@@ -89,7 +88,7 @@ impl<'tcx> MirPatch<'tcx> {
8988
};
9089
Location {
9190
block: bb,
92-
index: offset
91+
statement_index: offset
9392
}
9493
}
9594

@@ -149,12 +148,12 @@ impl<'tcx> MirPatch<'tcx> {
149148
}
150149
debug!("MirPatch: adding statement {:?} at loc {:?}+{}",
151150
stmt, loc, delta);
152-
loc.index += delta;
151+
loc.statement_index += delta;
153152
let source_info = Self::source_info_for_index(
154153
&mir[loc.block], loc
155154
);
156155
mir[loc.block].statements.insert(
157-
loc.index, Statement {
156+
loc.statement_index, Statement {
158157
source_info: source_info,
159158
kind: stmt
160159
});
@@ -163,7 +162,7 @@ impl<'tcx> MirPatch<'tcx> {
163162
}
164163

165164
pub fn source_info_for_index(data: &BasicBlockData, loc: Location) -> SourceInfo {
166-
match data.statements.get(loc.index) {
165+
match data.statements.get(loc.statement_index) {
167166
Some(stmt) => stmt.source_info,
168167
None => data.terminator().source_info
169168
}

‎src/librustc_metadata/decoder.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ use rustc_const_math::ConstInt;
4242

4343
use rustc::mir;
4444
use rustc::mir::visit::MutVisitor;
45+
use rustc::mir::repr::Location;
4546

4647
use std::cell::Cell;
4748
use std::io;
@@ -846,7 +847,7 @@ pub fn maybe_get_item_mir<'a, 'tcx>(cdata: Cmd,
846847
impl<'v, 'cdata, 'codemap> mir::visit::MutVisitor<'v>
847848
for MirDefIdAndSpanTranslator<'cdata, 'codemap>
848849
{
849-
fn visit_def_id(&mut self, def_id: &mut DefId) {
850+
fn visit_def_id(&mut self, def_id: &mut DefId, _: Location) {
850851
*def_id = translate_def_id(self.crate_metadata, *def_id);
851852
}
852853

‎src/librustc_mir/build/cfg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
//! Routines for manipulating the control-flow graph.
1515
16-
use build::{CFG, Location};
16+
use build::CFG;
1717
use rustc::mir::repr::*;
1818

1919
impl<'tcx> CFG<'tcx> {

‎src/librustc_mir/build/mod.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,6 @@ pub struct ScopeAuxiliary {
101101
pub postdoms: Vec<Location>,
102102
}
103103

104-
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
105-
pub struct Location {
106-
/// the location is within this block
107-
pub block: BasicBlock,
108-
109-
/// the location is the start of the this statement; or, if `statement_index`
110-
/// == num-statements, then the start of the terminator.
111-
pub statement_index: usize,
112-
}
113-
114104
pub type ScopeAuxiliaryVec = IndexVec<ScopeId, ScopeAuxiliary>;
115105

116106
///////////////////////////////////////////////////////////////////////////

‎src/librustc_mir/pretty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use build::{Location, ScopeAuxiliaryVec, ScopeId};
11+
use build::{ScopeAuxiliaryVec, ScopeId};
1212
use rustc::hir;
1313
use rustc::hir::def_id::DefId;
1414
use rustc::mir::repr::*;

‎src/librustc_mir/transform/no_landing_pads.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ use rustc::mir::transform::{Pass, MirPass, MirSource};
1919
pub struct NoLandingPads;
2020

2121
impl<'tcx> MutVisitor<'tcx> for NoLandingPads {
22-
fn visit_terminator(&mut self, bb: BasicBlock, terminator: &mut Terminator<'tcx>) {
22+
fn visit_terminator(&mut self,
23+
bb: BasicBlock,
24+
terminator: &mut Terminator<'tcx>,
25+
location: Location) {
2326
match terminator.kind {
2427
TerminatorKind::Goto { .. } |
2528
TerminatorKind::Resume |
@@ -37,7 +40,7 @@ impl<'tcx> MutVisitor<'tcx> for NoLandingPads {
3740
unwind.take();
3841
},
3942
}
40-
self.super_terminator(bb, terminator);
43+
self.super_terminator(bb, terminator, location);
4144
}
4245
}
4346

‎src/librustc_mir/transform/promote_consts.rs

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@ use rustc::mir::traversal::ReversePostorder;
2828
use rustc::ty::TyCtxt;
2929
use syntax_pos::Span;
3030

31-
use build::Location;
32-
3331
use rustc_data_structures::indexed_vec::{IndexVec, Idx};
3432

3533
use std::mem;
34+
use std::usize;
3635

3736
/// State of a temporary during collection and promotion.
3837
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
@@ -77,13 +76,12 @@ pub enum Candidate {
7776

7877
struct TempCollector {
7978
temps: IndexVec<Temp, TempState>,
80-
location: Location,
8179
span: Span
8280
}
8381

8482
impl<'tcx> Visitor<'tcx> for TempCollector {
85-
fn visit_lvalue(&mut self, lvalue: &Lvalue<'tcx>, context: LvalueContext) {
86-
self.super_lvalue(lvalue, context);
83+
fn visit_lvalue(&mut self, lvalue: &Lvalue<'tcx>, context: LvalueContext, location: Location) {
84+
self.super_lvalue(lvalue, context, location);
8785
if let Lvalue::Temp(index) = *lvalue {
8886
// Ignore drops, if the temp gets promoted,
8987
// then it's constant and thus drop is noop.
@@ -101,7 +99,7 @@ impl<'tcx> Visitor<'tcx> for TempCollector {
10199
LvalueContext::Store |
102100
LvalueContext::Call => {
103101
*temp = TempState::Defined {
104-
location: self.location,
102+
location: location,
105103
uses: 0
106104
};
107105
return;
@@ -126,27 +124,11 @@ impl<'tcx> Visitor<'tcx> for TempCollector {
126124
fn visit_source_info(&mut self, source_info: &SourceInfo) {
127125
self.span = source_info.span;
128126
}
129-
130-
fn visit_statement(&mut self, bb: BasicBlock, statement: &Statement<'tcx>) {
131-
assert_eq!(self.location.block, bb);
132-
self.super_statement(bb, statement);
133-
self.location.statement_index += 1;
134-
}
135-
136-
fn visit_basic_block_data(&mut self, bb: BasicBlock, data: &BasicBlockData<'tcx>) {
137-
self.location.statement_index = 0;
138-
self.location.block = bb;
139-
self.super_basic_block_data(bb, data);
140-
}
141127
}
142128

143129
pub fn collect_temps(mir: &Mir, rpo: &mut ReversePostorder) -> IndexVec<Temp, TempState> {
144130
let mut collector = TempCollector {
145131
temps: IndexVec::from_elem(TempState::Undefined, &mir.temp_decls),
146-
location: Location {
147-
block: START_BLOCK,
148-
statement_index: 0
149-
},
150132
span: mir.span
151133
};
152134
for (bb, data) in rpo {
@@ -266,9 +248,15 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
266248

267249
// Then, recurse for components in the Rvalue or Call.
268250
if stmt_idx < no_stmts {
269-
self.visit_rvalue(rvalue.as_mut().unwrap());
251+
self.visit_rvalue(rvalue.as_mut().unwrap(), Location {
252+
block: bb,
253+
statement_index: stmt_idx
254+
});
270255
} else {
271-
self.visit_terminator_kind(bb, call.as_mut().unwrap());
256+
self.visit_terminator_kind(bb, call.as_mut().unwrap(), Location {
257+
block: bb,
258+
statement_index: no_stmts
259+
});
272260
}
273261

274262
let new_temp = self.promoted.temp_decls.push(TempDecl {
@@ -327,19 +315,25 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
327315
}
328316
}
329317
};
330-
self.visit_rvalue(&mut rvalue);
318+
self.visit_rvalue(&mut rvalue, Location{
319+
block: BasicBlock::new(0),
320+
statement_index: usize::MAX
321+
});
331322
self.assign(Lvalue::ReturnPointer, rvalue, span);
332323
self.source.promoted.push(self.promoted);
333324
}
334325
}
335326

336327
/// Replaces all temporaries with their promoted counterparts.
337328
impl<'a, 'tcx> MutVisitor<'tcx> for Promoter<'a, 'tcx> {
338-
fn visit_lvalue(&mut self, lvalue: &mut Lvalue<'tcx>, context: LvalueContext) {
329+
fn visit_lvalue(&mut self,
330+
lvalue: &mut Lvalue<'tcx>,
331+
context: LvalueContext,
332+
location: Location) {
339333
if let Lvalue::Temp(ref mut temp) = *lvalue {
340334
*temp = self.promote_temp(*temp);
341335
}
342-
self.super_lvalue(lvalue, context);
336+
self.super_lvalue(lvalue, context, location);
343337
}
344338
}
345339

‎src/librustc_mir/transform/qualify_consts.rs

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ use syntax_pos::Span;
3636

3737
use std::collections::hash_map::Entry;
3838
use std::fmt;
39-
40-
use build::Location;
39+
use std::usize;
4140

4241
use super::promote_consts::{self, Candidate, TempState};
4342

@@ -147,7 +146,6 @@ struct Qualifier<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
147146
return_qualif: Option<Qualif>,
148147
qualif: Qualif,
149148
const_fn_arg_vars: BitVector,
150-
location: Location,
151149
temp_promotion_state: IndexVec<Temp, TempState>,
152150
promotion_candidates: Vec<Candidate>
153151
}
@@ -178,10 +176,6 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> {
178176
return_qualif: None,
179177
qualif: Qualif::empty(),
180178
const_fn_arg_vars: BitVector::new(mir.var_decls.len()),
181-
location: Location {
182-
block: START_BLOCK,
183-
statement_index: 0
184-
},
185179
temp_promotion_state: temps,
186180
promotion_candidates: vec![]
187181
}
@@ -293,7 +287,7 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> {
293287
}
294288

295289
/// Assign the current qualification to the given destination.
296-
fn assign(&mut self, dest: &Lvalue<'tcx>) {
290+
fn assign(&mut self, dest: &Lvalue<'tcx>, location: Location) {
297291
let qualif = self.qualif;
298292
let span = self.span;
299293
let store = |slot: &mut Option<Qualif>| {
@@ -331,7 +325,7 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> {
331325
// This must be an explicit assignment.
332326
_ => {
333327
// Catch more errors in the destination.
334-
self.visit_lvalue(dest, LvalueContext::Store);
328+
self.visit_lvalue(dest, LvalueContext::Store, location);
335329
self.statement_like();
336330
}
337331
}
@@ -399,7 +393,10 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> {
399393
self.qualif = Qualif::NOT_CONST;
400394
for index in 0..mir.var_decls.len() {
401395
if !self.const_fn_arg_vars.contains(index) {
402-
self.assign(&Lvalue::Var(Var::new(index)));
396+
self.assign(&Lvalue::Var(Var::new(index)), Location {
397+
block: bb,
398+
statement_index: usize::MAX,
399+
});
403400
}
404401
}
405402

@@ -445,7 +442,7 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> {
445442
/// For functions (constant or not), it also records
446443
/// candidates for promotion in promotion_candidates.
447444
impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
448-
fn visit_lvalue(&mut self, lvalue: &Lvalue<'tcx>, context: LvalueContext) {
445+
fn visit_lvalue(&mut self, lvalue: &Lvalue<'tcx>, context: LvalueContext, location: Location) {
449446
match *lvalue {
450447
Lvalue::Arg(_) => {
451448
self.add(Qualif::FN_ARGUMENT);
@@ -477,7 +474,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
477474
}
478475
Lvalue::Projection(ref proj) => {
479476
self.nest(|this| {
480-
this.super_lvalue(lvalue, context);
477+
this.super_lvalue(lvalue, context, location);
481478
match proj.elem {
482479
ProjectionElem::Deref => {
483480
if !this.try_consume() {
@@ -527,11 +524,11 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
527524
}
528525
}
529526

530-
fn visit_operand(&mut self, operand: &Operand<'tcx>) {
527+
fn visit_operand(&mut self, operand: &Operand<'tcx>, location: Location) {
531528
match *operand {
532529
Operand::Consume(_) => {
533530
self.nest(|this| {
534-
this.super_operand(operand);
531+
this.super_operand(operand, location);
535532
this.try_consume();
536533
});
537534
}
@@ -570,9 +567,9 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
570567
}
571568
}
572569

573-
fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>) {
570+
fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) {
574571
// Recurse through operands and lvalues.
575-
self.super_rvalue(rvalue);
572+
self.super_rvalue(rvalue, location);
576573

577574
match *rvalue {
578575
Rvalue::Use(_) |
@@ -648,7 +645,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
648645
}
649646

650647
// We might have a candidate for promotion.
651-
let candidate = Candidate::Ref(self.location);
648+
let candidate = Candidate::Ref(location);
652649
if self.mode == Mode::Fn || self.mode == Mode::ConstFn {
653650
if !self.qualif.intersects(Qualif::NEVER_PROMOTE) {
654651
// We can only promote direct borrows of temps.
@@ -733,9 +730,12 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
733730
}
734731
}
735732

736-
fn visit_terminator_kind(&mut self, bb: BasicBlock, kind: &TerminatorKind<'tcx>) {
733+
fn visit_terminator_kind(&mut self,
734+
bb: BasicBlock,
735+
kind: &TerminatorKind<'tcx>,
736+
location: Location) {
737737
if let TerminatorKind::Call { ref func, ref args, ref destination, .. } = *kind {
738-
self.visit_operand(func);
738+
self.visit_operand(func, location);
739739

740740
let fn_ty = func.ty(self.mir, self.tcx);
741741
let (is_shuffle, is_const_fn) = match fn_ty.sty {
@@ -749,7 +749,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
749749

750750
for (i, arg) in args.iter().enumerate() {
751751
self.nest(|this| {
752-
this.visit_operand(arg);
752+
this.visit_operand(arg, location);
753753
if is_shuffle && i == 2 && this.mode == Mode::Fn {
754754
let candidate = Candidate::ShuffleIndices(bb);
755755
if !this.qualif.intersects(Qualif::NEVER_PROMOTE) {
@@ -827,16 +827,20 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
827827
self.deny_drop();
828828
}
829829
}
830-
self.assign(dest);
830+
self.assign(dest, location);
831831
}
832832
} else {
833833
// Qualify any operands inside other terminators.
834-
self.super_terminator_kind(bb, kind);
834+
self.super_terminator_kind(bb, kind, location);
835835
}
836836
}
837837

838-
fn visit_assign(&mut self, _: BasicBlock, dest: &Lvalue<'tcx>, rvalue: &Rvalue<'tcx>) {
839-
self.visit_rvalue(rvalue);
838+
fn visit_assign(&mut self,
839+
_: BasicBlock,
840+
dest: &Lvalue<'tcx>,
841+
rvalue: &Rvalue<'tcx>,
842+
location: Location) {
843+
self.visit_rvalue(rvalue, location);
840844

841845
// Check the allowed const fn argument forms.
842846
if let (Mode::ConstFn, &Lvalue::Var(index)) = (self.mode, dest) {
@@ -857,38 +861,32 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
857861
}
858862
}
859863

860-
self.assign(dest);
864+
self.assign(dest, location);
861865
}
862866

863867
fn visit_source_info(&mut self, source_info: &SourceInfo) {
864868
self.span = source_info.span;
865869
}
866870

867-
fn visit_statement(&mut self, bb: BasicBlock, statement: &Statement<'tcx>) {
868-
assert_eq!(self.location.block, bb);
871+
fn visit_statement(&mut self, bb: BasicBlock, statement: &Statement<'tcx>, location: Location) {
869872
self.nest(|this| {
870873
this.visit_source_info(&statement.source_info);
871874
match statement.kind {
872875
StatementKind::Assign(ref lvalue, ref rvalue) => {
873-
this.visit_assign(bb, lvalue, rvalue);
876+
this.visit_assign(bb, lvalue, rvalue, location);
874877
}
875878
StatementKind::SetDiscriminant { .. } |
876879
StatementKind::StorageLive(_) |
877880
StatementKind::StorageDead(_) => {}
878881
}
879882
});
880-
self.location.statement_index += 1;
881-
}
882-
883-
fn visit_terminator(&mut self, bb: BasicBlock, terminator: &Terminator<'tcx>) {
884-
assert_eq!(self.location.block, bb);
885-
self.nest(|this| this.super_terminator(bb, terminator));
886883
}
887884

888-
fn visit_basic_block_data(&mut self, bb: BasicBlock, data: &BasicBlockData<'tcx>) {
889-
self.location.statement_index = 0;
890-
self.location.block = bb;
891-
self.super_basic_block_data(bb, data);
885+
fn visit_terminator(&mut self,
886+
bb: BasicBlock,
887+
terminator: &Terminator<'tcx>,
888+
location: Location) {
889+
self.nest(|this| this.super_terminator(bb, terminator, location));
892890
}
893891
}
894892

‎src/librustc_mir/transform/type_check.rs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,20 @@ impl<'a, 'b, 'gcx, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'gcx, 'tcx> {
6868
}
6969
}
7070

71-
fn visit_lvalue(&mut self, lvalue: &Lvalue<'tcx>, _context: visit::LvalueContext) {
72-
self.sanitize_lvalue(lvalue);
71+
fn visit_lvalue(&mut self,
72+
lvalue: &Lvalue<'tcx>,
73+
_context: visit::LvalueContext,
74+
location: Location) {
75+
self.sanitize_lvalue(lvalue, location);
7376
}
7477

75-
fn visit_constant(&mut self, constant: &Constant<'tcx>) {
76-
self.super_constant(constant);
78+
fn visit_constant(&mut self, constant: &Constant<'tcx>, location: Location) {
79+
self.super_constant(constant, location);
7780
self.sanitize_type(constant, constant.ty);
7881
}
7982

80-
fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>) {
81-
self.super_rvalue(rvalue);
83+
fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) {
84+
self.super_rvalue(rvalue, location);
8285
if let Some(ty) = rvalue.ty(self.mir, self.tcx()) {
8386
self.sanitize_type(rvalue, ty);
8487
}
@@ -124,7 +127,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
124127
}
125128
}
126129

127-
fn sanitize_lvalue(&mut self, lvalue: &Lvalue<'tcx>) -> LvalueTy<'tcx> {
130+
fn sanitize_lvalue(&mut self, lvalue: &Lvalue<'tcx>, location: Location) -> LvalueTy<'tcx> {
128131
debug!("sanitize_lvalue: {:?}", lvalue);
129132
match *lvalue {
130133
Lvalue::Var(index) => LvalueTy::Ty { ty: self.mir.var_decls[index].ty },
@@ -136,22 +139,23 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
136139
LvalueTy::Ty { ty: self.mir.return_ty }
137140
}
138141
Lvalue::Projection(ref proj) => {
139-
let base_ty = self.sanitize_lvalue(&proj.base);
142+
let base_ty = self.sanitize_lvalue(&proj.base, location);
140143
if let LvalueTy::Ty { ty } = base_ty {
141144
if ty.references_error() {
142145
assert!(self.errors_reported);
143146
return LvalueTy::Ty { ty: self.tcx().types.err };
144147
}
145148
}
146-
self.sanitize_projection(base_ty, &proj.elem, lvalue)
149+
self.sanitize_projection(base_ty, &proj.elem, lvalue, location)
147150
}
148151
}
149152
}
150153

151154
fn sanitize_projection(&mut self,
152155
base: LvalueTy<'tcx>,
153156
pi: &LvalueElem<'tcx>,
154-
lvalue: &Lvalue<'tcx>)
157+
lvalue: &Lvalue<'tcx>,
158+
location: Location)
155159
-> LvalueTy<'tcx> {
156160
debug!("sanitize_projection: {:?} {:?} {:?}", base, pi, lvalue);
157161
let tcx = self.tcx();
@@ -168,7 +172,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
168172
}
169173
}
170174
ProjectionElem::Index(ref i) => {
171-
self.visit_operand(i);
175+
self.visit_operand(i, location);
172176
let index_ty = i.ty(self.mir, tcx);
173177
if index_ty != tcx.types.usize {
174178
LvalueTy::Ty {

‎src/librustc_trans/collector.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ use rustc::ty::adjustment::CustomCoerceUnsized;
201201
use rustc::mir::repr as mir;
202202
use rustc::mir::visit as mir_visit;
203203
use rustc::mir::visit::Visitor as MirVisitor;
204+
use rustc::mir::repr::Location;
204205

205206
use rustc_const_eval as const_eval;
206207

@@ -446,7 +447,7 @@ struct MirNeighborCollector<'a, 'tcx: 'a> {
446447

447448
impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
448449

449-
fn visit_rvalue(&mut self, rvalue: &mir::Rvalue<'tcx>) {
450+
fn visit_rvalue(&mut self, rvalue: &mir::Rvalue<'tcx>, location: Location) {
450451
debug!("visiting rvalue {:?}", *rvalue);
451452

452453
match *rvalue {
@@ -517,12 +518,13 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
517518
_ => { /* not interesting */ }
518519
}
519520

520-
self.super_rvalue(rvalue);
521+
self.super_rvalue(rvalue, location);
521522
}
522523

523524
fn visit_lvalue(&mut self,
524525
lvalue: &mir::Lvalue<'tcx>,
525-
context: mir_visit::LvalueContext) {
526+
context: mir_visit::LvalueContext,
527+
location: Location) {
526528
debug!("visiting lvalue {:?}", *lvalue);
527529

528530
if let mir_visit::LvalueContext::Drop = context {
@@ -537,10 +539,10 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
537539
self.output.push(TransItem::DropGlue(DropGlueKind::Ty(ty)));
538540
}
539541

540-
self.super_lvalue(lvalue, context);
542+
self.super_lvalue(lvalue, context, location);
541543
}
542544

543-
fn visit_operand(&mut self, operand: &mir::Operand<'tcx>) {
545+
fn visit_operand(&mut self, operand: &mir::Operand<'tcx>, location: Location) {
544546
debug!("visiting operand {:?}", *operand);
545547

546548
let callee = match *operand {
@@ -620,7 +622,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
620622
}
621623
}
622624

623-
self.super_operand(operand);
625+
self.super_operand(operand, location);
624626

625627
fn can_result_in_trans_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
626628
def_id: DefId)
@@ -654,7 +656,8 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
654656
// we would not register drop-glues.
655657
fn visit_terminator_kind(&mut self,
656658
block: mir::BasicBlock,
657-
kind: &mir::TerminatorKind<'tcx>) {
659+
kind: &mir::TerminatorKind<'tcx>,
660+
location: Location) {
658661
let tcx = self.scx.tcx();
659662
match *kind {
660663
mir::TerminatorKind::Call {
@@ -682,7 +685,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
682685
_ => { /* Nothing to do. */ }
683686
}
684687

685-
self.super_terminator_kind(block, kind);
688+
self.super_terminator_kind(block, kind, location);
686689

687690
fn is_drop_in_place_intrinsic<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
688691
def_id: DefId,

‎src/librustc_trans/mir/analyze.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use rustc_data_structures::bitvec::BitVector;
1515
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
1616
use rustc::mir::repr as mir;
1717
use rustc::mir::repr::TerminatorKind;
18+
use rustc::mir::repr::Location;
1819
use rustc::mir::visit::{Visitor, LvalueContext};
1920
use rustc::mir::traversal;
2021
use common::{self, Block, BlockAndBuilder};
@@ -104,7 +105,8 @@ impl<'mir, 'bcx, 'tcx> Visitor<'tcx> for LocalAnalyzer<'mir, 'bcx, 'tcx> {
104105
fn visit_assign(&mut self,
105106
block: mir::BasicBlock,
106107
lvalue: &mir::Lvalue<'tcx>,
107-
rvalue: &mir::Rvalue<'tcx>) {
108+
rvalue: &mir::Rvalue<'tcx>,
109+
location: Location) {
108110
debug!("visit_assign(block={:?}, lvalue={:?}, rvalue={:?})", block, lvalue, rvalue);
109111

110112
if let Some(index) = self.mir.local_index(lvalue) {
@@ -113,15 +115,16 @@ impl<'mir, 'bcx, 'tcx> Visitor<'tcx> for LocalAnalyzer<'mir, 'bcx, 'tcx> {
113115
self.mark_as_lvalue(index);
114116
}
115117
} else {
116-
self.visit_lvalue(lvalue, LvalueContext::Store);
118+
self.visit_lvalue(lvalue, LvalueContext::Store, location);
117119
}
118120

119-
self.visit_rvalue(rvalue);
121+
self.visit_rvalue(rvalue, location);
120122
}
121123

122124
fn visit_terminator_kind(&mut self,
123125
block: mir::BasicBlock,
124-
kind: &mir::TerminatorKind<'tcx>) {
126+
kind: &mir::TerminatorKind<'tcx>,
127+
location: Location) {
125128
match *kind {
126129
mir::TerminatorKind::Call {
127130
func: mir::Operand::Constant(mir::Constant {
@@ -133,18 +136,19 @@ impl<'mir, 'bcx, 'tcx> Visitor<'tcx> for LocalAnalyzer<'mir, 'bcx, 'tcx> {
133136
// is not guaranteed to be statically dominated by the
134137
// definition of x, so x must always be in an alloca.
135138
if let mir::Operand::Consume(ref lvalue) = args[0] {
136-
self.visit_lvalue(lvalue, LvalueContext::Drop);
139+
self.visit_lvalue(lvalue, LvalueContext::Drop, location);
137140
}
138141
}
139142
_ => {}
140143
}
141144

142-
self.super_terminator_kind(block, kind);
145+
self.super_terminator_kind(block, kind, location);
143146
}
144147

145148
fn visit_lvalue(&mut self,
146149
lvalue: &mir::Lvalue<'tcx>,
147-
context: LvalueContext) {
150+
context: LvalueContext,
151+
location: Location) {
148152
debug!("visit_lvalue(lvalue={:?}, context={:?})", lvalue, context);
149153

150154
// Allow uses of projections of immediate pair fields.
@@ -196,11 +200,11 @@ impl<'mir, 'bcx, 'tcx> Visitor<'tcx> for LocalAnalyzer<'mir, 'bcx, 'tcx> {
196200
// A deref projection only reads the pointer, never needs the lvalue.
197201
if let mir::Lvalue::Projection(ref proj) = *lvalue {
198202
if let mir::ProjectionElem::Deref = proj.elem {
199-
return self.visit_lvalue(&proj.base, LvalueContext::Consume);
203+
return self.visit_lvalue(&proj.base, LvalueContext::Consume, location);
200204
}
201205
}
202206

203-
self.super_lvalue(lvalue, context);
207+
self.super_lvalue(lvalue, context, location);
204208
}
205209
}
206210

‎src/test/run-pass-fulldeps/auxiliary/dummy_mir_pass.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ extern crate rustc_const_math;
1919
extern crate syntax;
2020

2121
use rustc::mir::transform::{self, MirPass, MirSource};
22-
use rustc::mir::repr::{Mir, Literal};
22+
use rustc::mir::repr::{Mir, Literal, Location};
2323
use rustc::mir::visit::MutVisitor;
2424
use rustc::ty::TyCtxt;
2525
use rustc::middle::const_val::ConstVal;
@@ -40,7 +40,7 @@ impl<'tcx> MirPass<'tcx> for Pass {
4040
struct Visitor;
4141

4242
impl<'tcx> MutVisitor<'tcx> for Visitor {
43-
fn visit_literal(&mut self, literal: &mut Literal<'tcx>) {
43+
fn visit_literal(&mut self, literal: &mut Literal<'tcx>, _: Location) {
4444
if let Literal::Value { ref mut value } = *literal {
4545
if let ConstVal::Integral(ConstInt::I32(ref mut i @ 11)) = *value {
4646
*i = 42;

0 commit comments

Comments
 (0)
Please sign in to comment.