@@ -210,17 +210,20 @@ macro_rules! make_mir_visitor {
210210 }
211211
212212 fn visit_ty( & mut self ,
213- ty: & $( $mutability) * Ty <' tcx>) {
213+ ty: & $( $mutability) * Ty <' tcx>,
214+ _: PositionalInfo ) {
214215 self . super_ty( ty) ;
215216 }
216217
217218 fn visit_substs( & mut self ,
218- substs: & $( $mutability) * & ' tcx Substs <' tcx>) {
219+ substs: & $( $mutability) * & ' tcx Substs <' tcx>,
220+ _: Location ) {
219221 self . super_substs( substs) ;
220222 }
221223
222224 fn visit_closure_substs( & mut self ,
223- substs: & $( $mutability) * ClosureSubsts <' tcx>) {
225+ substs: & $( $mutability) * ClosureSubsts <' tcx>,
226+ _: Location ) {
224227 self . super_closure_substs( substs) ;
225228 }
226229
@@ -266,7 +269,7 @@ macro_rules! make_mir_visitor {
266269 self . visit_visibility_scope_data( scope) ;
267270 }
268271
269- self . visit_ty( & $( $mutability) * mir. return_ty) ;
272+ self . visit_ty( & $( $mutability) * mir. return_ty, PositionalInfo :: Span ( mir . span ) ) ;
270273
271274 for local_decl in & $( $mutability) * mir. local_decls {
272275 self . visit_local_decl( local_decl) ;
@@ -385,7 +388,7 @@ macro_rules! make_mir_visitor {
385388 ref values,
386389 ref targets } => {
387390 self . visit_operand( discr, source_location) ;
388- self . visit_ty( switch_ty) ;
391+ self . visit_ty( switch_ty, PositionalInfo :: Location ( source_location ) ) ;
389392 for value in & values[ ..] {
390393 self . visit_const_int( value, source_location) ;
391394 }
@@ -489,7 +492,7 @@ macro_rules! make_mir_visitor {
489492 ref $( $mutability) * operand,
490493 ref $( $mutability) * ty) => {
491494 self . visit_operand( operand, location) ;
492- self . visit_ty( ty) ;
495+ self . visit_ty( ty, PositionalInfo :: Location ( location ) ) ;
493496 }
494497
495498 Rvalue :: BinaryOp ( _bin_op,
@@ -511,28 +514,28 @@ macro_rules! make_mir_visitor {
511514 }
512515
513516 Rvalue :: NullaryOp ( _op, ref $( $mutability) * ty) => {
514- self . visit_ty( ty) ;
517+ self . visit_ty( ty, PositionalInfo :: Location ( location ) ) ;
515518 }
516519
517520 Rvalue :: Aggregate ( ref $( $mutability) * kind,
518521 ref $( $mutability) * operands) => {
519522 let kind = & $( $mutability) * * * kind;
520523 match * kind {
521524 AggregateKind :: Array ( ref $( $mutability) * ty) => {
522- self . visit_ty( ty) ;
525+ self . visit_ty( ty, PositionalInfo :: Location ( location ) ) ;
523526 }
524527 AggregateKind :: Tuple => {
525528 }
526529 AggregateKind :: Adt ( _adt_def,
527530 _variant_index,
528531 ref $( $mutability) * substs,
529532 _active_field_index) => {
530- self . visit_substs( substs) ;
533+ self . visit_substs( substs, location ) ;
531534 }
532535 AggregateKind :: Closure ( ref $( $mutability) * def_id,
533536 ref $( $mutability) * closure_substs) => {
534537 self . visit_def_id( def_id, location) ;
535- self . visit_closure_substs( closure_substs) ;
538+ self . visit_closure_substs( closure_substs, location ) ;
536539 }
537540 }
538541
@@ -581,7 +584,7 @@ macro_rules! make_mir_visitor {
581584 ref $( $mutability) * ty,
582585 } = * static_;
583586 self . visit_def_id( def_id, location) ;
584- self . visit_ty( ty) ;
587+ self . visit_ty( ty, PositionalInfo :: Location ( location ) ) ;
585588 }
586589
587590 fn super_projection( & mut self ,
@@ -611,7 +614,7 @@ macro_rules! make_mir_visitor {
611614 ProjectionElem :: Subslice { from: _, to: _ } => {
612615 }
613616 ProjectionElem :: Field ( _field, ref $( $mutability) * ty) => {
614- self . visit_ty( ty) ;
617+ self . visit_ty( ty, PositionalInfo :: Location ( location ) ) ;
615618 }
616619 ProjectionElem :: Index ( ref $( $mutability) * operand) => {
617620 self . visit_operand( operand, location) ;
@@ -635,7 +638,7 @@ macro_rules! make_mir_visitor {
635638 is_user_variable: _,
636639 } = * local_decl;
637640
638- self . visit_ty( ty) ;
641+ self . visit_ty( ty, PositionalInfo :: SourceInfo ( * source_info ) ) ;
639642 self . visit_source_info( source_info) ;
640643 }
641644
@@ -658,7 +661,7 @@ macro_rules! make_mir_visitor {
658661 } = * constant;
659662
660663 self . visit_span( span) ;
661- self . visit_ty( ty) ;
664+ self . visit_ty( ty, PositionalInfo :: Location ( location ) ) ;
662665 self . visit_literal( literal, location) ;
663666 }
664667
@@ -669,7 +672,7 @@ macro_rules! make_mir_visitor {
669672 Literal :: Item { ref $( $mutability) * def_id,
670673 ref $( $mutability) * substs } => {
671674 self . visit_def_id( def_id, location) ;
672- self . visit_substs( substs) ;
675+ self . visit_substs( substs, location ) ;
673676 }
674677 Literal :: Value { ref $( $mutability) * value } => {
675678 self . visit_const_val( value, location) ;
@@ -734,6 +737,12 @@ macro_rules! make_mir_visitor {
734737make_mir_visitor ! ( Visitor , ) ;
735738make_mir_visitor ! ( MutVisitor , mut ) ;
736739
740+ pub enum PositionalInfo {
741+ Location ( Location ) ,
742+ SourceInfo ( SourceInfo ) ,
743+ Span ( Span ) ,
744+ }
745+
737746#[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
738747pub enum LvalueContext < ' tcx > {
739748 // Appears as LHS of an assignment
0 commit comments