@@ -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
+ _: Lookup ) {
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,11 @@ 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
+ let lookup = Lookup :: Src ( SourceInfo {
273
+ span: mir. span,
274
+ scope: ARGUMENT_VISIBILITY_SCOPE ,
275
+ } ) ;
276
+ self . visit_ty( & $( $mutability) * mir. return_ty, lookup) ;
270
277
271
278
for local_decl in & $( $mutability) * mir. local_decls {
272
279
self . visit_local_decl( local_decl) ;
@@ -385,7 +392,7 @@ macro_rules! make_mir_visitor {
385
392
ref values,
386
393
ref targets } => {
387
394
self . visit_operand( discr, source_location) ;
388
- self . visit_ty( switch_ty) ;
395
+ self . visit_ty( switch_ty, Lookup :: Loc ( source_location ) ) ;
389
396
for value in & values[ ..] {
390
397
self . visit_const_int( value, source_location) ;
391
398
}
@@ -489,7 +496,7 @@ macro_rules! make_mir_visitor {
489
496
ref $( $mutability) * operand,
490
497
ref $( $mutability) * ty) => {
491
498
self . visit_operand( operand, location) ;
492
- self . visit_ty( ty) ;
499
+ self . visit_ty( ty, Lookup :: Loc ( location ) ) ;
493
500
}
494
501
495
502
Rvalue :: BinaryOp ( _bin_op,
@@ -511,28 +518,28 @@ macro_rules! make_mir_visitor {
511
518
}
512
519
513
520
Rvalue :: NullaryOp ( _op, ref $( $mutability) * ty) => {
514
- self . visit_ty( ty) ;
521
+ self . visit_ty( ty, Lookup :: Loc ( location ) ) ;
515
522
}
516
523
517
524
Rvalue :: Aggregate ( ref $( $mutability) * kind,
518
525
ref $( $mutability) * operands) => {
519
526
let kind = & $( $mutability) * * * kind;
520
527
match * kind {
521
528
AggregateKind :: Array ( ref $( $mutability) * ty) => {
522
- self . visit_ty( ty) ;
529
+ self . visit_ty( ty, Lookup :: Loc ( location ) ) ;
523
530
}
524
531
AggregateKind :: Tuple => {
525
532
}
526
533
AggregateKind :: Adt ( _adt_def,
527
534
_variant_index,
528
535
ref $( $mutability) * substs,
529
536
_active_field_index) => {
530
- self . visit_substs( substs) ;
537
+ self . visit_substs( substs, location ) ;
531
538
}
532
539
AggregateKind :: Closure ( ref $( $mutability) * def_id,
533
540
ref $( $mutability) * closure_substs) => {
534
541
self . visit_def_id( def_id, location) ;
535
- self . visit_closure_substs( closure_substs) ;
542
+ self . visit_closure_substs( closure_substs, location ) ;
536
543
}
537
544
}
538
545
@@ -581,7 +588,7 @@ macro_rules! make_mir_visitor {
581
588
ref $( $mutability) * ty,
582
589
} = * static_;
583
590
self . visit_def_id( def_id, location) ;
584
- self . visit_ty( ty) ;
591
+ self . visit_ty( ty, Lookup :: Loc ( location ) ) ;
585
592
}
586
593
587
594
fn super_projection( & mut self ,
@@ -611,7 +618,7 @@ macro_rules! make_mir_visitor {
611
618
ProjectionElem :: Subslice { from: _, to: _ } => {
612
619
}
613
620
ProjectionElem :: Field ( _field, ref $( $mutability) * ty) => {
614
- self . visit_ty( ty) ;
621
+ self . visit_ty( ty, Lookup :: Loc ( location ) ) ;
615
622
}
616
623
ProjectionElem :: Index ( ref $( $mutability) * operand) => {
617
624
self . visit_operand( operand, location) ;
@@ -635,7 +642,7 @@ macro_rules! make_mir_visitor {
635
642
is_user_variable: _,
636
643
} = * local_decl;
637
644
638
- self . visit_ty( ty) ;
645
+ self . visit_ty( ty, Lookup :: Src ( * source_info ) ) ;
639
646
self . visit_source_info( source_info) ;
640
647
}
641
648
@@ -658,7 +665,7 @@ macro_rules! make_mir_visitor {
658
665
} = * constant;
659
666
660
667
self . visit_span( span) ;
661
- self . visit_ty( ty) ;
668
+ self . visit_ty( ty, Lookup :: Loc ( location ) ) ;
662
669
self . visit_literal( literal, location) ;
663
670
}
664
671
@@ -669,7 +676,7 @@ macro_rules! make_mir_visitor {
669
676
Literal :: Item { ref $( $mutability) * def_id,
670
677
ref $( $mutability) * substs } => {
671
678
self . visit_def_id( def_id, location) ;
672
- self . visit_substs( substs) ;
679
+ self . visit_substs( substs, location ) ;
673
680
}
674
681
Literal :: Value { ref $( $mutability) * value } => {
675
682
self . visit_const_val( value, location) ;
@@ -734,6 +741,11 @@ macro_rules! make_mir_visitor {
734
741
make_mir_visitor ! ( Visitor , ) ;
735
742
make_mir_visitor ! ( MutVisitor , mut ) ;
736
743
744
+ pub enum Lookup {
745
+ Loc ( Location ) ,
746
+ Src ( SourceInfo ) ,
747
+ }
748
+
737
749
#[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
738
750
pub enum LvalueContext < ' tcx > {
739
751
// Appears as LHS of an assignment
0 commit comments