Skip to content

Commit 2d69117

Browse files
committed
Auto merge of #96345 - petrochenkov:linclean, r=notriddle
rustdoc: Cleanup doc link resolution See individual commits for specific changes
2 parents 8019fa0 + 9ba5281 commit 2d69117

File tree

4 files changed

+248
-515
lines changed

4 files changed

+248
-515
lines changed

compiler/rustc_resolve/src/build_reduced_graph.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,6 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
12681268
};
12691269
let binding = (res, vis, span, expansion).to_name_binding(self.r.arenas);
12701270
self.r.set_binding_parent_module(binding, parent_scope.module);
1271-
self.r.all_macro_rules.insert(ident.name, res);
12721271
if is_macro_export {
12731272
let module = self.r.graph_root;
12741273
self.r.define(module, ident, MacroNS, (res, vis, span, expansion, IsMacroExport));

compiler/rustc_resolve/src/lib.rs

+7-11
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ use rustc_span::{Span, DUMMY_SP};
5959
use smallvec::{smallvec, SmallVec};
6060
use std::cell::{Cell, RefCell};
6161
use std::collections::BTreeSet;
62-
use std::{cmp, fmt, mem, ptr};
62+
use std::{cmp, fmt, ptr};
6363
use tracing::debug;
6464

6565
use diagnostics::{ImportSuggestion, LabelSuggestion, Suggestion};
@@ -966,8 +966,6 @@ pub struct Resolver<'a> {
966966
registered_attrs: FxHashSet<Ident>,
967967
registered_tools: RegisteredTools,
968968
macro_use_prelude: FxHashMap<Symbol, &'a NameBinding<'a>>,
969-
/// FIXME: The only user of this is a doc link resolution hack for rustdoc.
970-
all_macro_rules: FxHashMap<Symbol, Res>,
971969
macro_map: FxHashMap<DefId, Lrc<SyntaxExtension>>,
972970
dummy_ext_bang: Lrc<SyntaxExtension>,
973971
dummy_ext_derive: Lrc<SyntaxExtension>,
@@ -1360,7 +1358,6 @@ impl<'a> Resolver<'a> {
13601358
registered_attrs,
13611359
registered_tools,
13621360
macro_use_prelude: FxHashMap::default(),
1363-
all_macro_rules: Default::default(),
13641361
macro_map: FxHashMap::default(),
13651362
dummy_ext_bang: Lrc::new(SyntaxExtension::dummy_bang(session.edition())),
13661363
dummy_ext_derive: Lrc::new(SyntaxExtension::dummy_derive(session.edition())),
@@ -1912,11 +1909,6 @@ impl<'a> Resolver<'a> {
19121909
}
19131910
}
19141911

1915-
// For rustdoc.
1916-
pub fn take_all_macro_rules(&mut self) -> FxHashMap<Symbol, Res> {
1917-
mem::take(&mut self.all_macro_rules)
1918-
}
1919-
19201912
/// For rustdoc.
19211913
/// For local modules returns only reexports, for external modules returns all children.
19221914
pub fn module_children_or_reexports(&self, def_id: DefId) -> Vec<ModChild> {
@@ -1928,8 +1920,12 @@ impl<'a> Resolver<'a> {
19281920
}
19291921

19301922
/// For rustdoc.
1931-
pub fn macro_rules_scope(&self, def_id: LocalDefId) -> MacroRulesScopeRef<'a> {
1932-
*self.macro_rules_scopes.get(&def_id).expect("not a `macro_rules` item")
1923+
pub fn macro_rules_scope(&self, def_id: LocalDefId) -> (MacroRulesScopeRef<'a>, Res) {
1924+
let scope = *self.macro_rules_scopes.get(&def_id).expect("not a `macro_rules` item");
1925+
match scope.get() {
1926+
MacroRulesScope::Binding(mb) => (scope, mb.binding.res()),
1927+
_ => unreachable!(),
1928+
}
19331929
}
19341930

19351931
/// Retrieves the span of the given `DefId` if `DefId` is in the local crate.

0 commit comments

Comments
 (0)