Skip to content

Commit a5f09f7

Browse files
committed
Update comment and make code clearer
I'm still not sure why this hack works so seemingly well.
1 parent 591ec49 commit a5f09f7

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/librustdoc/passes/collect_intra_doc_links.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ use rustc_ast as ast;
66
use rustc_data_structures::{fx::FxHashMap, stable_set::FxHashSet};
77
use rustc_errors::{Applicability, DiagnosticBuilder};
88
use rustc_expand::base::SyntaxExtensionKind;
9-
use rustc_hir as hir;
109
use rustc_hir::def::{
1110
DefKind,
1211
Namespace::{self, *},
1312
PerNS,
1413
};
15-
use rustc_hir::def_id::{CrateNum, DefId};
14+
use rustc_hir::def_id::{CrateNum, DefId, CRATE_DEF_ID};
1615
use rustc_middle::ty::{DefIdTree, Ty, TyCtxt};
1716
use rustc_middle::{bug, span_bug, ty};
1817
use rustc_resolve::ParentScope;
@@ -1736,9 +1735,9 @@ impl Disambiguator {
17361735
fn descr(self) -> &'static str {
17371736
match self {
17381737
Self::Namespace(n) => n.descr(),
1739-
// HACK(jynelson): by looking at the source I saw the DefId we pass
1740-
// for `expected.descr()` doesn't matter, since it's not a crate
1741-
Self::Kind(k) => k.descr(DefId::local(hir::def_id::DefIndex::from_usize(0))),
1738+
// HACK(jynelson): the source of `DefKind::descr` only uses the DefId for
1739+
// printing "module" vs "crate" so using the wrong ID is not a huge problem
1740+
Self::Kind(k) => k.descr(CRATE_DEF_ID.to_def_id()),
17421741
Self::Primitive => "builtin type",
17431742
}
17441743
}

0 commit comments

Comments
 (0)