resolve: Fix incorrect results of opt_def_kind
query for some built-in macros
Previously it always returned `MacroKind::Bang` while some of those macros are actually attributes and derives
This commit is contained in:
parent
4b043faba3
commit
17b1afdbb2
17 changed files with 35 additions and 19 deletions
|
@ -990,6 +990,9 @@ pub struct Resolver<'a> {
|
|||
crate_loader: CrateLoader<'a>,
|
||||
macro_names: FxHashSet<Ident>,
|
||||
builtin_macros: FxHashMap<Symbol, BuiltinMacroState>,
|
||||
/// A small map keeping true kinds of built-in macros that appear to be fn-like on
|
||||
/// the surface (`macro` items in libcore), but are actually attributes or derives.
|
||||
builtin_macro_kinds: FxHashMap<LocalDefId, MacroKind>,
|
||||
registered_attrs: FxHashSet<Ident>,
|
||||
registered_tools: RegisteredTools,
|
||||
macro_use_prelude: FxHashMap<Symbol, &'a NameBinding<'a>>,
|
||||
|
@ -1261,6 +1264,10 @@ impl ResolverAstLowering for Resolver<'_> {
|
|||
|
||||
def_id
|
||||
}
|
||||
|
||||
fn decl_macro_kind(&self, def_id: LocalDefId) -> MacroKind {
|
||||
self.builtin_macro_kinds.get(&def_id).copied().unwrap_or(MacroKind::Bang)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Resolver<'a> {
|
||||
|
@ -1381,6 +1388,7 @@ impl<'a> Resolver<'a> {
|
|||
crate_loader: CrateLoader::new(session, metadata_loader, crate_name),
|
||||
macro_names: FxHashSet::default(),
|
||||
builtin_macros: Default::default(),
|
||||
builtin_macro_kinds: Default::default(),
|
||||
registered_attrs,
|
||||
registered_tools,
|
||||
macro_use_prelude: FxHashMap::default(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue