Skip to content

Commit 1b41853

Browse files
committed
Ensure doc link maps have one entry per module.
1 parent cdbeccc commit 1b41853

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,6 +1544,10 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
15441544
let table = tcx.associated_types_for_impl_traits_in_associated_fn(def_id);
15451545
record_defaulted_array!(self.tables.associated_types_for_impl_traits_in_associated_fn[def_id] <- table);
15461546
}
1547+
if let DefKind::Mod = tcx.def_kind(def_id) {
1548+
record!(self.tables.doc_link_resolutions[def_id] <- tcx.doc_link_resolutions(def_id));
1549+
record_array!(self.tables.doc_link_traits_in_scope[def_id] <- tcx.doc_link_traits_in_scope(def_id));
1550+
}
15471551
}
15481552

15491553
for (def_id, impls) in &tcx.crate_inherent_impls(()).0.inherent_impls {
@@ -1552,14 +1556,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
15521556
def_id.index
15531557
}));
15541558
}
1555-
1556-
for (def_id, res_map) in &tcx.resolutions(()).doc_link_resolutions {
1557-
record!(self.tables.doc_link_resolutions[def_id.to_def_id()] <- res_map);
1558-
}
1559-
1560-
for (def_id, traits) in &tcx.resolutions(()).doc_link_traits_in_scope {
1561-
record_array!(self.tables.doc_link_traits_in_scope[def_id.to_def_id()] <- traits);
1562-
}
15631559
}
15641560

15651561
#[instrument(level = "trace", skip(self))]

compiler/rustc_resolve/src/late.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1473,13 +1473,16 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
14731473
}
14741474

14751475
fn with_scope<T>(&mut self, id: NodeId, f: impl FnOnce(&mut Self) -> T) -> T {
1476-
if let Some(module) = self.r.get_module(self.r.local_def_id(id).to_def_id()) {
1476+
let def_id = self.r.local_def_id(id);
1477+
if let Some(module) = self.r.get_module(def_id.to_def_id()) {
14771478
// Move down in the graph.
14781479
let orig_module = replace(&mut self.parent_scope.module, module);
14791480
self.with_rib(ValueNS, RibKind::Module(module), |this| {
14801481
this.with_rib(TypeNS, RibKind::Module(module), |this| {
14811482
let ret = f(this);
14821483
this.parent_scope.module = orig_module;
1484+
this.r.doc_link_resolutions.entry(def_id).or_default();
1485+
this.r.doc_link_traits_in_scope.entry(def_id).or_default();
14831486
ret
14841487
})
14851488
})
@@ -5054,6 +5057,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
50545057
BuiltinLintDiag::UnusedLabel,
50555058
);
50565059
}
5060+
self.doc_link_resolutions.entry(CRATE_DEF_ID).or_default();
5061+
self.doc_link_traits_in_scope.entry(CRATE_DEF_ID).or_default();
50575062
}
50585063
}
50595064

0 commit comments

Comments
 (0)