Skip to content

Commit c6b3bee

Browse files
committed
Ensure doc link maps have one entry per module.
1 parent 73f1879 commit c6b3bee

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

compiler/rustc_metadata/src/rmeta/encoder.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -1538,6 +1538,10 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
15381538
let table = tcx.associated_types_for_impl_traits_in_associated_fn(def_id);
15391539
record_defaulted_array!(self.tables.associated_types_for_impl_traits_in_associated_fn[def_id] <- table);
15401540
}
1541+
if let DefKind::Mod = tcx.def_kind(def_id) {
1542+
record!(self.tables.doc_link_resolutions[def_id] <- tcx.doc_link_resolutions(def_id));
1543+
record_array!(self.tables.doc_link_traits_in_scope[def_id] <- tcx.doc_link_traits_in_scope(def_id));
1544+
}
15411545
}
15421546

15431547
for (def_id, impls) in &tcx.crate_inherent_impls(()).0.inherent_impls {
@@ -1546,14 +1550,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
15461550
def_id.index
15471551
}));
15481552
}
1549-
1550-
for (def_id, res_map) in &tcx.resolutions(()).doc_link_resolutions {
1551-
record!(self.tables.doc_link_resolutions[def_id.to_def_id()] <- res_map);
1552-
}
1553-
1554-
for (def_id, traits) in &tcx.resolutions(()).doc_link_traits_in_scope {
1555-
record_array!(self.tables.doc_link_traits_in_scope[def_id.to_def_id()] <- traits);
1556-
}
15571553
}
15581554

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

compiler/rustc_resolve/src/late.rs

+6-1
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
})
@@ -5053,6 +5056,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
50535056
BuiltinLintDiag::UnusedLabel,
50545057
);
50555058
}
5059+
self.doc_link_resolutions.entry(CRATE_DEF_ID).or_default();
5060+
self.doc_link_traits_in_scope.entry(CRATE_DEF_ID).or_default();
50565061
}
50575062
}
50585063

0 commit comments

Comments
 (0)