@@ -17,7 +17,7 @@ use rustc_errors::struct_span_err;
1717use rustc_expand:: base:: Annotatable ;
1818use rustc_expand:: base:: { Indeterminate , ResolverExpand , SyntaxExtension , SyntaxExtensionKind } ;
1919use rustc_expand:: compile_declarative_macro;
20- use rustc_expand:: expand:: { AstFragment , Invocation , InvocationKind } ;
20+ use rustc_expand:: expand:: { AstFragment , Invocation , InvocationKind , SupportsMacroExpansion } ;
2121use rustc_feature:: is_builtin_attr_name;
2222use rustc_hir:: def:: { self , DefKind , NonMacroAttrKind } ;
2323use rustc_hir:: def_id;
@@ -278,12 +278,12 @@ impl<'a> ResolverExpand for Resolver<'a> {
278278
279279 // Derives are not included when `invocations` are collected, so we have to add them here.
280280 let parent_scope = & ParentScope { derives, ..parent_scope } ;
281- let require_inert = ! invoc. fragment_kind . supports_macro_expansion ( ) ;
281+ let supports_macro_expansion = invoc. fragment_kind . supports_macro_expansion ( ) ;
282282 let node_id = self . lint_node_id ( eager_expansion_root) ;
283283 let ( ext, res) = self . smart_resolve_macro_path (
284284 path,
285285 kind,
286- require_inert ,
286+ supports_macro_expansion ,
287287 inner_attr,
288288 parent_scope,
289289 node_id,
@@ -457,7 +457,7 @@ impl<'a> Resolver<'a> {
457457 & mut self ,
458458 path : & ast:: Path ,
459459 kind : MacroKind ,
460- require_inert : bool ,
460+ supports_macro_expansion : SupportsMacroExpansion ,
461461 inner_attr : bool ,
462462 parent_scope : & ParentScope < ' a > ,
463463 node_id : NodeId ,
@@ -505,8 +505,17 @@ impl<'a> Resolver<'a> {
505505
506506 let unexpected_res = if ext. macro_kind ( ) != kind {
507507 Some ( ( kind. article ( ) , kind. descr_expected ( ) ) )
508- } else if require_inert && matches ! ( res, Res :: Def ( ..) ) {
509- Some ( ( "a" , "non-macro attribute" ) )
508+ } else if matches ! ( res, Res :: Def ( ..) ) {
509+ match supports_macro_expansion {
510+ SupportsMacroExpansion :: No => Some ( ( "a" , "non-macro attribute" ) ) ,
511+ SupportsMacroExpansion :: Yes { supports_inner_attrs } => {
512+ if inner_attr && !supports_inner_attrs {
513+ Some ( ( "a" , "non-macro inner attribute" ) )
514+ } else {
515+ None
516+ }
517+ }
518+ }
510519 } else {
511520 None
512521 } ;
0 commit comments