about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNoah Lev <camelidcamel@gmail.com>2022-01-06 15:06:35 -0800
committerNoah Lev <camelidcamel@gmail.com>2022-01-10 19:23:26 -0800
commita5f09f74d6dc0f52fd2c73fca0a9e5bb99eb756c (patch)
tree9963c433a95e6aac7e0ae1611de2ef22024ba002 /src
parent591ec49df312ec4cbcdec0f082f123f473c182a9 (diff)
downloadrust-a5f09f74d6dc0f52fd2c73fca0a9e5bb99eb756c.tar.gz
rust-a5f09f74d6dc0f52fd2c73fca0a9e5bb99eb756c.zip
Update comment and make code clearer
I'm still not sure why this hack works so seemingly well.
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/passes/collect_intra_doc_links.rs9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs
index dd2fa9d6273..13e1992a31c 100644
--- a/src/librustdoc/passes/collect_intra_doc_links.rs
+++ b/src/librustdoc/passes/collect_intra_doc_links.rs
@@ -6,13 +6,12 @@ use rustc_ast as ast;
 use rustc_data_structures::{fx::FxHashMap, stable_set::FxHashSet};
 use rustc_errors::{Applicability, DiagnosticBuilder};
 use rustc_expand::base::SyntaxExtensionKind;
-use rustc_hir as hir;
 use rustc_hir::def::{
     DefKind,
     Namespace::{self, *},
     PerNS,
 };
-use rustc_hir::def_id::{CrateNum, DefId};
+use rustc_hir::def_id::{CrateNum, DefId, CRATE_DEF_ID};
 use rustc_middle::ty::{DefIdTree, Ty, TyCtxt};
 use rustc_middle::{bug, span_bug, ty};
 use rustc_resolve::ParentScope;
@@ -1736,9 +1735,9 @@ impl Disambiguator {
     fn descr(self) -> &'static str {
         match self {
             Self::Namespace(n) => n.descr(),
-            // HACK(jynelson): by looking at the source I saw the DefId we pass
-            // for `expected.descr()` doesn't matter, since it's not a crate
-            Self::Kind(k) => k.descr(DefId::local(hir::def_id::DefIndex::from_usize(0))),
+            // HACK(jynelson): the source of `DefKind::descr` only uses the DefId for
+            // printing "module" vs "crate" so using the wrong ID is not a huge problem
+            Self::Kind(k) => k.descr(CRATE_DEF_ID.to_def_id()),
             Self::Primitive => "builtin type",
         }
     }