Skip to content

Commit 152e403

Browse files
committed
ty::pretty: document "dummy Span extern crate" special-case in try_print_visible_def_path_recur.
1 parent 9e8356c commit 152e403

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

compiler/rustc_middle/src/ty/print/pretty.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -350,18 +350,19 @@ 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+
return Ok((self.print_def_path(def_id, &[])?, true));
362364
}
363365
(ExternCrateSource::Path, LOCAL_CRATE) => {
364-
debug!("try_print_visible_def_path: def_id={:?}", def_id);
365366
return Ok((self.path_crate(cnum)?, true));
366367
}
367368
_ => {}

0 commit comments

Comments
 (0)