@@ -20,7 +20,7 @@ use rustc_hir as hir;
2020use rustc_hir:: def:: { DefKind as HirDefKind , Res } ;
2121use rustc_hir:: def_id:: { DefId , LocalDefId } ;
2222use rustc_hir:: intravisit:: { self , Visitor } ;
23- use rustc_hir_pretty:: { bounds_to_string, generic_params_to_string, ty_to_string} ;
23+ use rustc_hir_pretty:: { bounds_to_string, fn_to_string , generic_params_to_string, ty_to_string} ;
2424use rustc_middle:: hir:: map:: Map ;
2525use rustc_middle:: span_bug;
2626use rustc_middle:: ty:: { self , DefIdTree , TyCtxt } ;
@@ -199,23 +199,23 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
199199 self . dumper . compilation_opts ( data) ;
200200 }
201201
202- fn write_sub_paths ( & mut self , path : & ' tcx hir:: Path < ' tcx > ) {
203- for seg in path . segments {
202+ fn write_segments ( & mut self , segments : impl IntoIterator < Item = & ' tcx hir:: PathSegment < ' tcx > > ) {
203+ for seg in segments {
204204 if let Some ( data) = self . save_ctxt . get_path_segment_data ( seg) {
205205 self . dumper . dump_ref ( data) ;
206206 }
207207 }
208208 }
209209
210+ fn write_sub_paths ( & mut self , path : & ' tcx hir:: Path < ' tcx > ) {
211+ self . write_segments ( path. segments )
212+ }
213+
210214 // As write_sub_paths, but does not process the last ident in the path (assuming it
211215 // will be processed elsewhere). See note on write_sub_paths about global.
212216 fn write_sub_paths_truncated ( & mut self , path : & ' tcx hir:: Path < ' tcx > ) {
213217 if let [ segments @ .., _] = path. segments {
214- for seg in segments {
215- if let Some ( data) = self . save_ctxt . get_path_segment_data ( seg) {
216- self . dumper . dump_ref ( data) ;
217- }
218- }
218+ self . write_segments ( segments)
219219 }
220220 }
221221
@@ -276,7 +276,8 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
276276 }
277277 v. process_generic_params ( & generics, & method_data. qualname , hir_id) ;
278278
279- method_data. value = crate :: make_signature ( & sig. decl , & generics) ;
279+ method_data. value =
280+ fn_to_string ( sig. decl , sig. header , Some ( ident. name ) , generics, vis, & [ ] , None ) ;
280281 method_data. sig = sig:: method_signature ( hir_id, ident, generics, sig, & v. save_ctxt ) ;
281282
282283 v. dumper . dump_def ( & access_from_vis ! ( v. save_ctxt, vis, hir_id) , method_data) ;
@@ -643,7 +644,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
643644 self . nest_tables ( map. local_def_id ( item. hir_id ) , |v| {
644645 v. visit_ty ( & typ) ;
645646 if let & Some ( ref trait_ref) = trait_ref {
646- v. process_path ( trait_ref. hir_ref_id , & trait_ref. path ) ;
647+ v. process_path ( trait_ref. hir_ref_id , & hir :: QPath :: Resolved ( None , & trait_ref. path ) ) ;
647648 }
648649 v. process_generic_params ( generics, "" , item. hir_id ) ;
649650 for impl_item in impl_items {
@@ -746,7 +747,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
746747 }
747748 }
748749
749- fn dump_path_ref ( & mut self , id : hir:: HirId , path : & hir:: Path < ' tcx > ) {
750+ fn dump_path_ref ( & mut self , id : hir:: HirId , path : & hir:: QPath < ' tcx > ) {
750751 let path_data = self . save_ctxt . get_path_data ( id, path) ;
751752 if let Some ( path_data) = path_data {
752753 self . dumper . dump_ref ( path_data) ;
@@ -760,14 +761,30 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
760761 }
761762 }
762763
763- fn process_path ( & mut self , id : hir:: HirId , path : & ' tcx hir:: Path < ' tcx > ) {
764- if self . span . filter_generated ( path. span ) {
764+ fn process_path ( & mut self , id : hir:: HirId , path : & hir:: QPath < ' tcx > ) {
765+ let span = match path {
766+ hir:: QPath :: Resolved ( _, path) => path. span ,
767+ hir:: QPath :: TypeRelative ( _, segment) => segment. ident . span ,
768+ } ;
769+ if self . span . filter_generated ( span) {
765770 return ;
766771 }
767772 self . dump_path_ref ( id, path) ;
768773
769774 // Type arguments
770- for seg in path. segments {
775+ let segments = match path {
776+ hir:: QPath :: Resolved ( ty, path) => {
777+ if let Some ( ty) = ty {
778+ self . visit_ty ( ty) ;
779+ }
780+ path. segments
781+ }
782+ hir:: QPath :: TypeRelative ( ty, segment) => {
783+ self . visit_ty ( ty) ;
784+ std:: slice:: from_ref ( * segment)
785+ }
786+ } ;
787+ for seg in segments {
771788 if let Some ( ref generic_args) = seg. args {
772789 for arg in generic_args. args {
773790 if let hir:: GenericArg :: Type ( ref ty) = arg {
@@ -777,7 +794,9 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
777794 }
778795 }
779796
780- self . write_sub_paths_truncated ( path) ;
797+ if let hir:: QPath :: Resolved ( _, path) = path {
798+ self . write_sub_paths_truncated ( path) ;
799+ }
781800 }
782801
783802 fn process_struct_lit (
@@ -931,9 +950,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
931950 }
932951
933952 for ( id, ref path) in collector. collected_paths {
934- if let hir:: QPath :: Resolved ( _, path) = path {
935- self . process_path ( id, path) ;
936- }
953+ self . process_path ( id, path) ;
937954 }
938955 }
939956
@@ -1135,7 +1152,10 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
11351152 fn process_bounds ( & mut self , bounds : hir:: GenericBounds < ' tcx > ) {
11361153 for bound in bounds {
11371154 if let hir:: GenericBound :: Trait ( ref trait_ref, _) = * bound {
1138- self . process_path ( trait_ref. trait_ref . hir_ref_id , & trait_ref. trait_ref . path )
1155+ self . process_path (
1156+ trait_ref. trait_ref . hir_ref_id ,
1157+ & hir:: QPath :: Resolved ( None , & trait_ref. trait_ref . path ) ,
1158+ )
11391159 }
11401160 }
11411161 }
@@ -1330,13 +1350,16 @@ impl<'l, 'tcx> Visitor<'tcx> for DumpVisitor<'l, 'tcx> {
13301350 fn visit_ty ( & mut self , t : & ' tcx hir:: Ty < ' tcx > ) {
13311351 self . process_macro_use ( t. span ) ;
13321352 match t. kind {
1333- hir:: TyKind :: Path ( hir :: QPath :: Resolved ( _ , path) ) => {
1353+ hir:: TyKind :: Path ( ref path) => {
13341354 if generated_code ( t. span ) {
13351355 return ;
13361356 }
13371357
13381358 if let Some ( id) = self . lookup_def_id ( t. hir_id ) {
1339- let sub_span = path. segments . last ( ) . unwrap ( ) . ident . span ;
1359+ let sub_span = match path {
1360+ hir:: QPath :: Resolved ( _, path) => path. segments . last ( ) . unwrap ( ) . ident . span ,
1361+ hir:: QPath :: TypeRelative ( _, segment) => segment. ident . span ,
1362+ } ;
13401363 let span = self . span_from_span ( sub_span) ;
13411364 self . dumper . dump_ref ( Ref {
13421365 kind : RefKind :: Type ,
@@ -1345,8 +1368,10 @@ impl<'l, 'tcx> Visitor<'tcx> for DumpVisitor<'l, 'tcx> {
13451368 } ) ;
13461369 }
13471370
1348- self . write_sub_paths_truncated ( path) ;
1349- intravisit:: walk_path ( self , path) ;
1371+ if let hir:: QPath :: Resolved ( _, path) = path {
1372+ self . write_sub_paths_truncated ( path) ;
1373+ }
1374+ intravisit:: walk_qpath ( self , path, t. hir_id , t. span ) ;
13501375 }
13511376 hir:: TyKind :: Array ( ref ty, ref anon_const) => {
13521377 self . visit_ty ( ty) ;
@@ -1355,6 +1380,10 @@ impl<'l, 'tcx> Visitor<'tcx> for DumpVisitor<'l, 'tcx> {
13551380 v. visit_expr ( & map. body ( anon_const. body ) . value )
13561381 } ) ;
13571382 }
1383+ hir:: TyKind :: Def ( item_id, _) => {
1384+ let item = self . tcx . hir ( ) . item ( item_id. id ) ;
1385+ self . nest_tables ( self . tcx . hir ( ) . local_def_id ( item_id. id ) , |v| v. visit_item ( item) ) ;
1386+ }
13581387 _ => intravisit:: walk_ty ( self , t) ,
13591388 }
13601389 }
@@ -1432,8 +1461,8 @@ impl<'l, 'tcx> Visitor<'tcx> for DumpVisitor<'l, 'tcx> {
14321461 self . visit_expr ( & arm. body ) ;
14331462 }
14341463
1435- fn visit_path ( & mut self , p : & ' tcx hir:: Path < ' tcx > , id : hir:: HirId ) {
1436- self . process_path ( id, p ) ;
1464+ fn visit_qpath ( & mut self , path : & ' tcx hir:: QPath < ' tcx > , id : hir:: HirId , _ : Span ) {
1465+ self . process_path ( id, path ) ;
14371466 }
14381467
14391468 fn visit_stmt ( & mut self , s : & ' tcx hir:: Stmt < ' tcx > ) {
0 commit comments