Skip to content

Commit 0357489

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

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
@@ -1507,6 +1507,10 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
15071507
let table = tcx.associated_types_for_impl_traits_in_associated_fn(def_id);
15081508
record_defaulted_array!(self.tables.associated_types_for_impl_traits_in_associated_fn[def_id] <- table);
15091509
}
1510+
if let DefKind::Mod = tcx.def_kind(def_id) {
1511+
record!(self.tables.doc_link_resolutions[def_id] <- tcx.doc_link_resolutions(def_id));
1512+
record_array!(self.tables.doc_link_traits_in_scope[def_id] <- tcx.doc_link_traits_in_scope(def_id));
1513+
}
15101514
}
15111515

15121516
for (def_id, impls) in &tcx.crate_inherent_impls(()).unwrap().inherent_impls {
@@ -1515,14 +1519,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
15151519
def_id.index
15161520
}));
15171521
}
1518-
1519-
for (def_id, res_map) in &tcx.resolutions(()).doc_link_resolutions {
1520-
record!(self.tables.doc_link_resolutions[def_id.to_def_id()] <- res_map);
1521-
}
1522-
1523-
for (def_id, traits) in &tcx.resolutions(()).doc_link_traits_in_scope {
1524-
record_array!(self.tables.doc_link_traits_in_scope[def_id.to_def_id()] <- traits);
1525-
}
15261522
}
15271523

15281524
#[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
@@ -1424,13 +1424,16 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
14241424
}
14251425

14261426
fn with_scope<T>(&mut self, id: NodeId, f: impl FnOnce(&mut Self) -> T) -> T {
1427-
if let Some(module) = self.r.get_module(self.r.local_def_id(id).to_def_id()) {
1427+
let def_id = self.r.local_def_id(id);
1428+
if let Some(module) = self.r.get_module(def_id.to_def_id()) {
14281429
// Move down in the graph.
14291430
let orig_module = replace(&mut self.parent_scope.module, module);
14301431
self.with_rib(ValueNS, RibKind::Module(module), |this| {
14311432
this.with_rib(TypeNS, RibKind::Module(module), |this| {
14321433
let ret = f(this);
14331434
this.parent_scope.module = orig_module;
1435+
this.r.doc_link_resolutions.entry(def_id).or_default();
1436+
this.r.doc_link_traits_in_scope.entry(def_id).or_default();
14341437
ret
14351438
})
14361439
})
@@ -4943,6 +4946,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
49434946
BuiltinLintDiag::UnusedLabel,
49444947
);
49454948
}
4949+
self.doc_link_resolutions.entry(CRATE_DEF_ID).or_default();
4950+
self.doc_link_traits_in_scope.entry(CRATE_DEF_ID).or_default();
49464951
}
49474952
}
49484953

0 commit comments

Comments
 (0)