@@ -350,18 +350,26 @@ pub trait PrettyPrinter<'tcx>:
350350 match self . tcx ( ) . extern_crate ( def_id) {
351351 Some ( & ExternCrate { src, dependency_of, span, .. } ) => match ( src, dependency_of) {
352352 ( ExternCrateSource :: Extern ( def_id) , LOCAL_CRATE ) => {
353- debug ! ( "try_print_visible_def_path: def_id={:?}" , def_id) ;
354- return Ok ( (
355- if !span. is_dummy ( ) {
356- self . print_def_path ( def_id, & [ ] ) ?
357- } else {
358- self . path_crate ( cnum) ?
359- } ,
360- true ,
361- ) ) ;
353+ // NOTE(eddyb) the only reason `span` might be dummy,
354+ // that we're aware of, is that it's the `std`/`core`
355+ // `extern crate` injected by default.
356+ // FIXME(eddyb) find something better to key this on,
357+ // or avoid ending up with `ExternCrateSource::Extern`,
358+ // for the injected `std`/`core`.
359+ if span. is_dummy ( ) {
360+ return Ok ( ( self . path_crate ( cnum) ?, true ) ) ;
361+ }
362+
363+ // Disable `try_print_trimmed_def_path` behavior within
364+ // the `print_def_path` call, to avoid infinite recursion
365+ // in cases where the `extern crate foo` has non-trivial
366+ // parents, e.g. it's nested in `impl foo::Trait for Bar`
367+ // (see also issues #55779 and #87932).
368+ self = with_no_visible_paths ( || self . print_def_path ( def_id, & [ ] ) ) ?;
369+
370+ return Ok ( ( self , true ) ) ;
362371 }
363372 ( ExternCrateSource :: Path , LOCAL_CRATE ) => {
364- debug ! ( "try_print_visible_def_path: def_id={:?}" , def_id) ;
365373 return Ok ( ( self . path_crate ( cnum) ?, true ) ) ;
366374 }
367375 _ => { }
0 commit comments