@@ -1074,6 +1074,21 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
10741074        self . collect ( kind,  InvocationKind :: Attr  {  attr,  traits,  item } ) 
10751075    } 
10761076
1077+     fn  find_attr_invoc ( & self ,  attrs :  & mut  Vec < ast:: Attribute > )  -> Option < ast:: Attribute >  { 
1078+         let  attr = attrs. iter ( ) 
1079+                         . position ( |a| !attr:: is_known ( a)  && !is_builtin_attr ( a) ) 
1080+                         . map ( |i| attrs. remove ( i) ) ; 
1081+         if  let  Some ( attr)  = & attr { 
1082+             if  !self . cx . ecfg . enable_custom_inner_attributes ( )  &&
1083+                attr. style  == ast:: AttrStyle :: Inner  && attr. path  != "test"  { 
1084+                 emit_feature_err ( & self . cx . parse_sess ,  "custom_inner_attributes" , 
1085+                                  attr. span ,  GateIssue :: Language , 
1086+                                  "non-builtin inner attributes are unstable" ) ; 
1087+             } 
1088+         } 
1089+         attr
1090+     } 
1091+ 
10771092    /// If `item` is an attr invocation, remove and return the macro attribute and derive traits. 
10781093fn  classify_item < T > ( & mut  self ,  mut  item :  T )  -> ( Option < ast:: Attribute > ,  Vec < Path > ,  T ) 
10791094        where  T :  HasAttrs , 
@@ -1087,7 +1102,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
10871102                return  attrs; 
10881103            } 
10891104
1090-             attr = find_attr_invoc ( & mut  attrs) ; 
1105+             attr = self . find_attr_invoc ( & mut  attrs) ; 
10911106            traits = collect_derives ( & mut  self . cx ,  & mut  attrs) ; 
10921107            attrs
10931108        } ) ; 
@@ -1108,7 +1123,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
11081123                return  attrs; 
11091124            } 
11101125
1111-             attr = find_attr_invoc ( & mut  attrs) ; 
1126+             attr = self . find_attr_invoc ( & mut  attrs) ; 
11121127            attrs
11131128        } ) ; 
11141129
@@ -1145,12 +1160,6 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
11451160    } 
11461161} 
11471162
1148- pub  fn  find_attr_invoc ( attrs :  & mut  Vec < ast:: Attribute > )  -> Option < ast:: Attribute >  { 
1149-     attrs. iter ( ) 
1150-          . position ( |a| !attr:: is_known ( a)  && !is_builtin_attr ( a) ) 
1151-          . map ( |i| attrs. remove ( i) ) 
1152- } 
1153- 
11541163impl < ' a ,  ' b >  Folder  for  InvocationCollector < ' a ,  ' b >  { 
11551164    fn  fold_expr ( & mut  self ,  expr :  P < ast:: Expr > )  -> P < ast:: Expr >  { 
11561165        let  mut  expr = self . cfg . configure_expr ( expr) . into_inner ( ) ; 
@@ -1582,6 +1591,12 @@ impl<'feat> ExpansionConfig<'feat> {
15821591        fn  proc_macro_expr = proc_macro_expr, 
15831592        fn  proc_macro_non_items = proc_macro_non_items, 
15841593    } 
1594+ 
1595+     fn  enable_custom_inner_attributes ( & self )  -> bool  { 
1596+         self . features . map_or ( false ,  |features| { 
1597+             features. custom_inner_attributes  || features. custom_attribute  || features. rustc_attrs 
1598+         } ) 
1599+     } 
15851600} 
15861601
15871602// A Marker adds the given mark to the syntax context. 
0 commit comments