diff options
| author | Eduard-Mihai Burtescu <eddyb@lyken.rs> | 2021-10-10 18:18:30 +0300 |
|---|---|---|
| committer | Eduard-Mihai Burtescu <eddyb@lyken.rs> | 2021-10-10 18:18:30 +0300 |
| commit | 152e40377aefe966486515c392d741f851510a8a (patch) | |
| tree | f122f7b95d4d4f31d7878951efe7167230058dcd | |
| parent | 9e8356c6adf119f983651d533d2b307544086cf9 (diff) | |
| download | rust-152e40377aefe966486515c392d741f851510a8a.tar.gz rust-152e40377aefe966486515c392d741f851510a8a.zip | |
ty::pretty: document "dummy Span extern crate" special-case in `try_print_visible_def_path_recur`.
| -rw-r--r-- | compiler/rustc_middle/src/ty/print/pretty.rs | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 2610a76b281..ae0cc97c704 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -350,18 +350,19 @@ pub trait PrettyPrinter<'tcx>: match self.tcx().extern_crate(def_id) { Some(&ExternCrate { src, dependency_of, span, .. }) => match (src, dependency_of) { (ExternCrateSource::Extern(def_id), LOCAL_CRATE) => { - debug!("try_print_visible_def_path: def_id={:?}", def_id); - return Ok(( - if !span.is_dummy() { - self.print_def_path(def_id, &[])? - } else { - self.path_crate(cnum)? - }, - true, - )); + // NOTE(eddyb) the only reason `span` might be dummy, + // that we're aware of, is that it's the `std`/`core` + // `extern crate` injected by default. + // FIXME(eddyb) find something better to key this on, + // or avoid ending up with `ExternCrateSource::Extern`, + // for the injected `std`/`core`. + if span.is_dummy() { + return Ok((self.path_crate(cnum)?, true)); + } + + return Ok((self.print_def_path(def_id, &[])?, true)); } (ExternCrateSource::Path, LOCAL_CRATE) => { - debug!("try_print_visible_def_path: def_id={:?}", def_id); return Ok((self.path_crate(cnum)?, true)); } _ => {} |
