@@ -38,7 +38,6 @@ use syntax::visit::{self, Visitor};
3838use syntax:: print:: pprust:: {
3939 bounds_to_string,
4040 generic_params_to_string,
41- path_to_string,
4241 ty_to_string
4342} ;
4443use syntax:: ptr:: P ;
@@ -218,95 +217,21 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
218217 self . dumper . compilation_opts ( data) ;
219218 }
220219
221- // Return all non-empty prefixes of a path.
222- // For each prefix, we return the span for the last segment in the prefix and
223- // a str representation of the entire prefix.
224- fn process_path_prefixes ( & self , path : & ast:: Path ) -> Vec < ( Span , String ) > {
225- let segments = & path. segments [ if path. is_global ( ) { 1 } else { 0 } ..] ;
226-
227- let mut result = Vec :: with_capacity ( segments. len ( ) ) ;
228- let mut segs = Vec :: with_capacity ( segments. len ( ) ) ;
229-
230- for ( i, seg) in segments. iter ( ) . enumerate ( ) {
231- segs. push ( seg. clone ( ) ) ;
232- let sub_path = ast:: Path {
233- span : seg. ident . span , // span for the last segment
234- segments : segs,
235- } ;
236- let qualname = if i == 0 && path. is_global ( ) {
237- format ! ( "::{}" , path_to_string( & sub_path) )
238- } else {
239- path_to_string ( & sub_path)
240- } ;
241- result. push ( ( seg. ident . span , qualname) ) ;
242- segs = sub_path. segments ;
243- }
244-
245- result
246- }
247-
248220 fn write_sub_paths ( & mut self , path : & ast:: Path ) {
249- let sub_paths = self . process_path_prefixes ( path) ;
250- for ( span, _) in sub_paths {
251- let span = self . span_from_span ( span) ;
252- self . dumper . dump_ref ( Ref {
253- kind : RefKind :: Mod ,
254- span,
255- ref_id : :: null_id ( ) ,
256- } ) ;
221+ for seg in & path. segments {
222+ if let Some ( data) = self . save_ctxt . get_path_segment_data ( seg) {
223+ self . dumper . dump_ref ( data) ;
224+ }
257225 }
258226 }
259227
260228 // As write_sub_paths, but does not process the last ident in the path (assuming it
261229 // will be processed elsewhere). See note on write_sub_paths about global.
262230 fn write_sub_paths_truncated ( & mut self , path : & ast:: Path ) {
263- let sub_paths = self . process_path_prefixes ( path) ;
264- let len = sub_paths. len ( ) ;
265- if len <= 1 {
266- return ;
267- }
268-
269- for ( span, _) in sub_paths. into_iter ( ) . take ( len - 1 ) {
270- let span = self . span_from_span ( span) ;
271- self . dumper . dump_ref ( Ref {
272- kind : RefKind :: Mod ,
273- span,
274- ref_id : :: null_id ( ) ,
275- } ) ;
276- }
277- }
278-
279- // As write_sub_paths, but expects a path of the form module_path::trait::method
280- // Where trait could actually be a struct too.
281- fn write_sub_path_trait_truncated ( & mut self , path : & ast:: Path ) {
282- let sub_paths = self . process_path_prefixes ( path) ;
283- let len = sub_paths. len ( ) ;
284- if len <= 1 {
285- return ;
286- }
287- let sub_paths = & sub_paths[ ..( len - 1 ) ] ;
288-
289- // write the trait part of the sub-path
290- let ( ref span, _) = sub_paths[ len - 2 ] ;
291- let span = self . span_from_span ( * span) ;
292- self . dumper . dump_ref ( Ref {
293- kind : RefKind :: Type ,
294- ref_id : :: null_id ( ) ,
295- span,
296- } ) ;
297-
298- // write the other sub-paths
299- if len <= 2 {
300- return ;
301- }
302- let sub_paths = & sub_paths[ ..len - 2 ] ;
303- for & ( ref span, _) in sub_paths {
304- let span = self . span_from_span ( * span) ;
305- self . dumper . dump_ref ( Ref {
306- kind : RefKind :: Mod ,
307- span,
308- ref_id : :: null_id ( ) ,
309- } ) ;
231+ for seg in & path. segments [ ..path. segments . len ( ) - 1 ] {
232+ if let Some ( data) = self . save_ctxt . get_path_segment_data ( seg) {
233+ self . dumper . dump_ref ( data) ;
234+ }
310235 }
311236 }
312237
@@ -876,29 +801,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
876801 }
877802 }
878803
879- // Modules or types in the path prefix.
880- match self . save_ctxt . get_path_def ( id) {
881- HirDef :: Method ( did) => {
882- let ti = self . tcx . associated_item ( did) ;
883- if ti. kind == ty:: AssociatedKind :: Method && ti. method_has_self_argument {
884- self . write_sub_path_trait_truncated ( path) ;
885- }
886- }
887- HirDef :: Fn ( ..) |
888- HirDef :: Const ( ..) |
889- HirDef :: Static ( ..) |
890- HirDef :: StructCtor ( ..) |
891- HirDef :: VariantCtor ( ..) |
892- HirDef :: AssociatedConst ( ..) |
893- HirDef :: Local ( ..) |
894- HirDef :: Upvar ( ..) |
895- HirDef :: Struct ( ..) |
896- HirDef :: Union ( ..) |
897- HirDef :: Variant ( ..) |
898- HirDef :: TyAlias ( ..) |
899- HirDef :: AssociatedTy ( ..) => self . write_sub_paths_truncated ( path) ,
900- _ => { }
901- }
804+ self . write_sub_paths_truncated ( path) ;
902805 }
903806
904807 fn process_struct_lit (
0 commit comments