@@ -210,17 +210,20 @@ macro_rules! make_mir_visitor {
210
210
}
211
211
212
212
fn visit_ty( & mut self ,
213
- ty: & $( $mutability) * Ty <' tcx>) {
213
+ ty: & $( $mutability) * Ty <' tcx>,
214
+ _: PositionalInfo ) {
214
215
self . super_ty( ty) ;
215
216
}
216
217
217
218
fn visit_substs( & mut self ,
218
- substs: & $( $mutability) * & ' tcx Substs <' tcx>) {
219
+ substs: & $( $mutability) * & ' tcx Substs <' tcx>,
220
+ _: Location ) {
219
221
self . super_substs( substs) ;
220
222
}
221
223
222
224
fn visit_closure_substs( & mut self ,
223
- substs: & $( $mutability) * ClosureSubsts <' tcx>) {
225
+ substs: & $( $mutability) * ClosureSubsts <' tcx>,
226
+ _: Location ) {
224
227
self . super_closure_substs( substs) ;
225
228
}
226
229
@@ -266,7 +269,7 @@ macro_rules! make_mir_visitor {
266
269
self . visit_visibility_scope_data( scope) ;
267
270
}
268
271
269
- self . visit_ty( & $( $mutability) * mir. return_ty) ;
272
+ self . visit_ty( & $( $mutability) * mir. return_ty, PositionalInfo :: Span ( mir . span ) ) ;
270
273
271
274
for local_decl in & $( $mutability) * mir. local_decls {
272
275
self . visit_local_decl( local_decl) ;
@@ -385,7 +388,7 @@ macro_rules! make_mir_visitor {
385
388
ref values,
386
389
ref targets } => {
387
390
self . visit_operand( discr, source_location) ;
388
- self . visit_ty( switch_ty) ;
391
+ self . visit_ty( switch_ty, PositionalInfo :: Location ( source_location ) ) ;
389
392
for value in & values[ ..] {
390
393
self . visit_const_int( value, source_location) ;
391
394
}
@@ -489,7 +492,7 @@ macro_rules! make_mir_visitor {
489
492
ref $( $mutability) * operand,
490
493
ref $( $mutability) * ty) => {
491
494
self . visit_operand( operand, location) ;
492
- self . visit_ty( ty) ;
495
+ self . visit_ty( ty, PositionalInfo :: Location ( location ) ) ;
493
496
}
494
497
495
498
Rvalue :: BinaryOp ( _bin_op,
@@ -511,28 +514,28 @@ macro_rules! make_mir_visitor {
511
514
}
512
515
513
516
Rvalue :: NullaryOp ( _op, ref $( $mutability) * ty) => {
514
- self . visit_ty( ty) ;
517
+ self . visit_ty( ty, PositionalInfo :: Location ( location ) ) ;
515
518
}
516
519
517
520
Rvalue :: Aggregate ( ref $( $mutability) * kind,
518
521
ref $( $mutability) * operands) => {
519
522
let kind = & $( $mutability) * * * kind;
520
523
match * kind {
521
524
AggregateKind :: Array ( ref $( $mutability) * ty) => {
522
- self . visit_ty( ty) ;
525
+ self . visit_ty( ty, PositionalInfo :: Location ( location ) ) ;
523
526
}
524
527
AggregateKind :: Tuple => {
525
528
}
526
529
AggregateKind :: Adt ( _adt_def,
527
530
_variant_index,
528
531
ref $( $mutability) * substs,
529
532
_active_field_index) => {
530
- self . visit_substs( substs) ;
533
+ self . visit_substs( substs, location ) ;
531
534
}
532
535
AggregateKind :: Closure ( ref $( $mutability) * def_id,
533
536
ref $( $mutability) * closure_substs) => {
534
537
self . visit_def_id( def_id, location) ;
535
- self . visit_closure_substs( closure_substs) ;
538
+ self . visit_closure_substs( closure_substs, location ) ;
536
539
}
537
540
}
538
541
@@ -581,7 +584,7 @@ macro_rules! make_mir_visitor {
581
584
ref $( $mutability) * ty,
582
585
} = * static_;
583
586
self . visit_def_id( def_id, location) ;
584
- self . visit_ty( ty) ;
587
+ self . visit_ty( ty, PositionalInfo :: Location ( location ) ) ;
585
588
}
586
589
587
590
fn super_projection( & mut self ,
@@ -611,7 +614,7 @@ macro_rules! make_mir_visitor {
611
614
ProjectionElem :: Subslice { from: _, to: _ } => {
612
615
}
613
616
ProjectionElem :: Field ( _field, ref $( $mutability) * ty) => {
614
- self . visit_ty( ty) ;
617
+ self . visit_ty( ty, PositionalInfo :: Location ( location ) ) ;
615
618
}
616
619
ProjectionElem :: Index ( ref $( $mutability) * operand) => {
617
620
self . visit_operand( operand, location) ;
@@ -635,7 +638,7 @@ macro_rules! make_mir_visitor {
635
638
is_user_variable: _,
636
639
} = * local_decl;
637
640
638
- self . visit_ty( ty) ;
641
+ self . visit_ty( ty, PositionalInfo :: SourceInfo ( * source_info ) ) ;
639
642
self . visit_source_info( source_info) ;
640
643
}
641
644
@@ -658,7 +661,7 @@ macro_rules! make_mir_visitor {
658
661
} = * constant;
659
662
660
663
self . visit_span( span) ;
661
- self . visit_ty( ty) ;
664
+ self . visit_ty( ty, PositionalInfo :: Location ( location ) ) ;
662
665
self . visit_literal( literal, location) ;
663
666
}
664
667
@@ -669,7 +672,7 @@ macro_rules! make_mir_visitor {
669
672
Literal :: Item { ref $( $mutability) * def_id,
670
673
ref $( $mutability) * substs } => {
671
674
self . visit_def_id( def_id, location) ;
672
- self . visit_substs( substs) ;
675
+ self . visit_substs( substs, location ) ;
673
676
}
674
677
Literal :: Value { ref $( $mutability) * value } => {
675
678
self . visit_const_val( value, location) ;
@@ -734,6 +737,12 @@ macro_rules! make_mir_visitor {
734
737
make_mir_visitor ! ( Visitor , ) ;
735
738
make_mir_visitor ! ( MutVisitor , mut ) ;
736
739
740
+ pub enum PositionalInfo {
741
+ Location ( Location ) ,
742
+ SourceInfo ( SourceInfo ) ,
743
+ Span ( Span ) ,
744
+ }
745
+
737
746
#[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
738
747
pub enum LvalueContext < ' tcx > {
739
748
// Appears as LHS of an assignment
0 commit comments