mbe: Handle local macro_rules attr resolution
Teach the resolver to consider `macro_rules` macros when looking for a local attribute. When looking for an attribute and considering a `macro_rules` macro, load the macro in order to see if it has attribute rules. Include a FIXME about tracking multiple macro kinds for a Def instead.
This commit is contained in:
parent
34be8abb70
commit
549c2fee9f
1 changed files with 16 additions and 4 deletions
|
|
@ -625,9 +625,21 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
};
|
||||
|
||||
match result {
|
||||
Ok((binding, flags))
|
||||
if sub_namespace_match(binding.macro_kind(), macro_kind) =>
|
||||
{
|
||||
Ok((binding, flags)) => {
|
||||
let binding_macro_kind = binding.macro_kind();
|
||||
// If we're looking for an attribute, that might be supported by a
|
||||
// `macro_rules!` macro.
|
||||
// FIXME: Replace this with tracking multiple macro kinds for one Def.
|
||||
if !(sub_namespace_match(binding_macro_kind, macro_kind)
|
||||
|| (binding_macro_kind == Some(MacroKind::Bang)
|
||||
&& macro_kind == Some(MacroKind::Attr)
|
||||
&& this
|
||||
.get_macro(binding.res())
|
||||
.is_some_and(|macro_data| macro_data.attr_ext.is_some())))
|
||||
{
|
||||
return None;
|
||||
}
|
||||
|
||||
if finalize.is_none() || matches!(scope_set, ScopeSet::Late(..)) {
|
||||
return Some(Ok(binding));
|
||||
}
|
||||
|
|
@ -704,7 +716,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
innermost_result = Some((binding, flags));
|
||||
}
|
||||
}
|
||||
Ok(..) | Err(Determinacy::Determined) => {}
|
||||
Err(Determinacy::Determined) => {}
|
||||
Err(Determinacy::Undetermined) => determinacy = Determinacy::Undetermined,
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue