@@ -244,6 +244,9 @@ pub trait Visitor<'v> : Sized {
244
244
fn visit_lifetime_def ( & mut self , lifetime : & ' v LifetimeDef ) {
245
245
walk_lifetime_def ( self , lifetime)
246
246
}
247
+ fn visit_qpath ( & mut self , qpath : & ' v QPath , id : NodeId , span : Span ) {
248
+ walk_qpath ( self , qpath, id, span)
249
+ }
247
250
fn visit_path ( & mut self , path : & ' v Path , _id : NodeId ) {
248
251
walk_path ( self , path)
249
252
}
@@ -481,11 +484,8 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) {
481
484
walk_fn_decl ( visitor, & function_declaration. decl ) ;
482
485
walk_list ! ( visitor, visit_lifetime_def, & function_declaration. lifetimes) ;
483
486
}
484
- TyPath ( ref maybe_qself, ref path) => {
485
- if let Some ( ref qself) = * maybe_qself {
486
- visitor. visit_ty ( & qself. ty ) ;
487
- }
488
- visitor. visit_path ( path, typ. id ) ;
487
+ TyPath ( ref qpath) => {
488
+ visitor. visit_qpath ( qpath, typ. id , typ. span ) ;
489
489
}
490
490
TyObjectSum ( ref ty, ref bounds) => {
491
491
visitor. visit_ty ( ty) ;
@@ -508,6 +508,21 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) {
508
508
}
509
509
}
510
510
511
+ pub fn walk_qpath < ' v , V : Visitor < ' v > > ( visitor : & mut V , qpath : & ' v QPath , id : NodeId , span : Span ) {
512
+ match * qpath {
513
+ QPath :: Resolved ( ref maybe_qself, ref path) => {
514
+ if let Some ( ref qself) = * maybe_qself {
515
+ visitor. visit_ty ( qself) ;
516
+ }
517
+ visitor. visit_path ( path, id)
518
+ }
519
+ QPath :: TypeRelative ( ref qself, ref segment) => {
520
+ visitor. visit_ty ( qself) ;
521
+ visitor. visit_path_segment ( span, segment) ;
522
+ }
523
+ }
524
+ }
525
+
511
526
pub fn walk_path < ' v , V : Visitor < ' v > > ( visitor : & mut V , path : & ' v Path ) {
512
527
for segment in & path. segments {
513
528
visitor. visit_path_segment ( path. span , segment) ;
@@ -555,18 +570,15 @@ pub fn walk_assoc_type_binding<'v, V: Visitor<'v>>(visitor: &mut V,
555
570
pub fn walk_pat < ' v , V : Visitor < ' v > > ( visitor : & mut V , pattern : & ' v Pat ) {
556
571
visitor. visit_id ( pattern. id ) ;
557
572
match pattern. node {
558
- PatKind :: TupleStruct ( ref path , ref children, _) => {
559
- visitor. visit_path ( path , pattern. id ) ;
573
+ PatKind :: TupleStruct ( ref qpath , ref children, _) => {
574
+ visitor. visit_qpath ( qpath , pattern. id , pattern . span ) ;
560
575
walk_list ! ( visitor, visit_pat, children) ;
561
576
}
562
- PatKind :: Path ( ref opt_qself, ref path) => {
563
- if let Some ( ref qself) = * opt_qself {
564
- visitor. visit_ty ( & qself. ty ) ;
565
- }
566
- visitor. visit_path ( path, pattern. id )
577
+ PatKind :: Path ( ref qpath) => {
578
+ visitor. visit_qpath ( qpath, pattern. id , pattern. span ) ;
567
579
}
568
- PatKind :: Struct ( ref path , ref fields, _) => {
569
- visitor. visit_path ( path , pattern. id ) ;
580
+ PatKind :: Struct ( ref qpath , ref fields, _) => {
581
+ visitor. visit_qpath ( qpath , pattern. id , pattern . span ) ;
570
582
for field in fields {
571
583
visitor. visit_name ( field. span , field. node . name ) ;
572
584
visitor. visit_pat ( & field. node . pat )
@@ -840,8 +852,8 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
840
852
visitor. visit_expr ( element) ;
841
853
visitor. visit_expr ( count)
842
854
}
843
- ExprStruct ( ref path , ref fields, ref optional_base) => {
844
- visitor. visit_path ( path , expression. id ) ;
855
+ ExprStruct ( ref qpath , ref fields, ref optional_base) => {
856
+ visitor. visit_qpath ( qpath , expression. id , expression . span ) ;
845
857
for field in fields {
846
858
visitor. visit_name ( field. name . span , field. name . node ) ;
847
859
visitor. visit_expr ( & field. expr )
@@ -917,11 +929,8 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
917
929
visitor. visit_expr ( main_expression) ;
918
930
visitor. visit_expr ( index_expression)
919
931
}
920
- ExprPath ( ref maybe_qself, ref path) => {
921
- if let Some ( ref qself) = * maybe_qself {
922
- visitor. visit_ty ( & qself. ty ) ;
923
- }
924
- visitor. visit_path ( path, expression. id )
932
+ ExprPath ( ref qpath) => {
933
+ visitor. visit_qpath ( qpath, expression. id , expression. span ) ;
925
934
}
926
935
ExprBreak ( ref opt_sp_name, ref opt_expr) => {
927
936
walk_opt_sp_name ( visitor, opt_sp_name) ;
0 commit comments