@@ -91,7 +91,7 @@ impl<P: ItemPathPrinter> PrintCx<'a, 'gcx, 'tcx, P> {
91
91
}
92
92
93
93
DefPathData :: Impl => {
94
- self . default_print_impl_path ( def_id)
94
+ self . print_impl_path ( def_id)
95
95
}
96
96
97
97
// Unclear if there is any value in distinguishing these.
@@ -131,18 +131,6 @@ impl<P: ItemPathPrinter> PrintCx<'a, 'gcx, 'tcx, P> {
131
131
debug ! ( "default_print_impl_path: impl_def_id={:?}" , impl_def_id) ;
132
132
let parent_def_id = self . tcx . parent_def_id ( impl_def_id) . unwrap ( ) ;
133
133
134
- // Always use types for non-local impls, where types are always
135
- // available, and filename/line-number is mostly uninteresting.
136
- let use_types = !impl_def_id. is_local ( ) || {
137
- // Otherwise, use filename/line-number if forced.
138
- let force_no_types = FORCE_IMPL_FILENAME_LINE . with ( |f| f. get ( ) ) ;
139
- !force_no_types
140
- } ;
141
-
142
- if !use_types {
143
- return self . default_print_impl_path_fallback ( impl_def_id) ;
144
- }
145
-
146
134
// Decide whether to print the parent path for the impl.
147
135
// Logically, since impls are global, it's never needed, but
148
136
// users may find it useful. Currently, we omit the parent if
@@ -209,19 +197,6 @@ impl<P: ItemPathPrinter> PrintCx<'a, 'gcx, 'tcx, P> {
209
197
}
210
198
}
211
199
}
212
-
213
- fn default_print_impl_path_fallback ( & mut self , impl_def_id : DefId ) -> P :: Path {
214
- // If no type info is available, fall back to
215
- // pretty printing some span information. This should
216
- // only occur very early in the compiler pipeline.
217
- // FIXME(eddyb) this should just be using `tcx.def_span(impl_def_id)`
218
- let parent_def_id = self . tcx . parent_def_id ( impl_def_id) . unwrap ( ) ;
219
- let path = self . print_item_path ( parent_def_id) ;
220
- let node_id = self . tcx . hir ( ) . as_local_node_id ( impl_def_id) . unwrap ( ) ;
221
- let item = self . tcx . hir ( ) . expect_item ( node_id) ;
222
- let span_str = self . tcx . sess . source_map ( ) . span_to_string ( item. span ) ;
223
- self . path_append ( path, & format ! ( "<impl at {}>" , span_str) )
224
- }
225
200
}
226
201
227
202
impl < ' a , ' gcx , ' tcx > TyCtxt < ' a , ' gcx , ' tcx > {
@@ -290,6 +265,9 @@ pub trait ItemPathPrinter: Sized {
290
265
fn print_item_path ( self : & mut PrintCx < ' _ , ' _ , ' _ , Self > , def_id : DefId ) -> Self :: Path {
291
266
self . default_print_item_path ( def_id)
292
267
}
268
+ fn print_impl_path ( self : & mut PrintCx < ' _ , ' _ , ' _ , Self > , impl_def_id : DefId ) -> Self :: Path {
269
+ self . default_print_impl_path ( impl_def_id)
270
+ }
293
271
294
272
fn path_crate ( self : & mut PrintCx < ' _ , ' _ , ' _ , Self > , cnum : CrateNum ) -> Self :: Path ;
295
273
fn path_impl ( self : & mut PrintCx < ' _ , ' _ , ' _ , Self > , text : & str ) -> Self :: Path ;
@@ -472,6 +450,28 @@ impl ItemPathPrinter for LocalPathPrinter {
472
450
self . try_print_visible_item_path ( def_id)
473
451
. unwrap_or_else ( || self . default_print_item_path ( def_id) )
474
452
}
453
+ fn print_impl_path ( self : & mut PrintCx < ' _ , ' _ , ' _ , Self > , impl_def_id : DefId ) -> Self :: Path {
454
+ // Always use types for non-local impls, where types are always
455
+ // available, and filename/line-number is mostly uninteresting.
456
+ let use_types = !impl_def_id. is_local ( ) || {
457
+ // Otherwise, use filename/line-number if forced.
458
+ let force_no_types = FORCE_IMPL_FILENAME_LINE . with ( |f| f. get ( ) ) ;
459
+ !force_no_types
460
+ } ;
461
+
462
+ if !use_types {
463
+ // If no type info is available, fall back to
464
+ // pretty printing some span information. This should
465
+ // only occur very early in the compiler pipeline.
466
+ // FIXME(eddyb) this should just be using `tcx.def_span(impl_def_id)`
467
+ let parent_def_id = self . tcx . parent_def_id ( impl_def_id) . unwrap ( ) ;
468
+ let path = self . print_item_path ( parent_def_id) ;
469
+ let span = self . tcx . def_span ( impl_def_id) ;
470
+ return self . path_append ( path, & format ! ( "<impl at {:?}>" , span) ) ;
471
+ }
472
+
473
+ self . default_print_impl_path ( impl_def_id)
474
+ }
475
475
476
476
fn path_crate ( self : & mut PrintCx < ' _ , ' _ , ' _ , Self > , cnum : CrateNum ) -> Self :: Path {
477
477
if cnum == LOCAL_CRATE {
0 commit comments