Skip to content

Commit 5b48feb

Browse files
committed
Ensure doc link maps have one entry per module.
1 parent f391bc6 commit 5b48feb

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
@@ -1581,6 +1581,10 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
15811581
let table = tcx.associated_types_for_impl_traits_in_associated_fn(def_id);
15821582
record_defaulted_array!(self.tables.associated_types_for_impl_traits_in_associated_fn[def_id] <- table);
15831583
}
1584+
if let DefKind::Mod = tcx.def_kind(def_id) {
1585+
record!(self.tables.doc_link_resolutions[def_id] <- tcx.doc_link_resolutions(def_id));
1586+
record_array!(self.tables.doc_link_traits_in_scope[def_id] <- tcx.doc_link_traits_in_scope(def_id));
1587+
}
15841588
}
15851589

15861590
for (def_id, impls) in &tcx.crate_inherent_impls(()).0.inherent_impls {
@@ -1589,14 +1593,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
15891593
def_id.index
15901594
}));
15911595
}
1592-
1593-
for (def_id, res_map) in &tcx.resolutions(()).doc_link_resolutions {
1594-
record!(self.tables.doc_link_resolutions[def_id.to_def_id()] <- res_map);
1595-
}
1596-
1597-
for (def_id, traits) in &tcx.resolutions(()).doc_link_traits_in_scope {
1598-
record_array!(self.tables.doc_link_traits_in_scope[def_id.to_def_id()] <- traits);
1599-
}
16001596
}
16011597

16021598
#[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
@@ -1559,12 +1559,15 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
15591559
}
15601560

15611561
fn with_mod_rib<T>(&mut self, id: NodeId, f: impl FnOnce(&mut Self) -> T) -> T {
1562-
let module = self.r.expect_module(self.r.local_def_id(id).to_def_id());
1562+
let def_id = self.r.local_def_id(id);
1563+
let module = self.r.expect_module(def_id.to_def_id());
15631564
// Move down in the graph.
15641565
let orig_module = replace(&mut self.parent_scope.module, module);
15651566
self.with_rib(ValueNS, RibKind::Module(module), |this| {
15661567
this.with_rib(TypeNS, RibKind::Module(module), |this| {
15671568
let ret = f(this);
1569+
this.r.doc_link_resolutions.entry(def_id).or_default();
1570+
this.r.doc_link_traits_in_scope.entry(def_id).or_default();
15681571
this.parent_scope.module = orig_module;
15691572
ret
15701573
})
@@ -5247,6 +5250,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
52475250
BuiltinLintDiag::UnusedLabel,
52485251
);
52495252
}
5253+
self.doc_link_resolutions.entry(CRATE_DEF_ID).or_default();
5254+
self.doc_link_traits_in_scope.entry(CRATE_DEF_ID).or_default();
52505255
}
52515256
}
52525257

0 commit comments

Comments
 (0)