@@ -1074,6 +1074,21 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
1074
1074
self . collect ( kind, InvocationKind :: Attr { attr, traits, item } )
1075
1075
}
1076
1076
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
+
1077
1092
/// If `item` is an attr invocation, remove and return the macro attribute and derive traits.
1078
1093
fn classify_item < T > ( & mut self , mut item : T ) -> ( Option < ast:: Attribute > , Vec < Path > , T )
1079
1094
where T : HasAttrs ,
@@ -1087,7 +1102,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
1087
1102
return attrs;
1088
1103
}
1089
1104
1090
- attr = find_attr_invoc ( & mut attrs) ;
1105
+ attr = self . find_attr_invoc ( & mut attrs) ;
1091
1106
traits = collect_derives ( & mut self . cx , & mut attrs) ;
1092
1107
attrs
1093
1108
} ) ;
@@ -1108,7 +1123,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
1108
1123
return attrs;
1109
1124
}
1110
1125
1111
- attr = find_attr_invoc ( & mut attrs) ;
1126
+ attr = self . find_attr_invoc ( & mut attrs) ;
1112
1127
attrs
1113
1128
} ) ;
1114
1129
@@ -1145,12 +1160,6 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
1145
1160
}
1146
1161
}
1147
1162
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
-
1154
1163
impl < ' a , ' b > Folder for InvocationCollector < ' a , ' b > {
1155
1164
fn fold_expr ( & mut self , expr : P < ast:: Expr > ) -> P < ast:: Expr > {
1156
1165
let mut expr = self . cfg . configure_expr ( expr) . into_inner ( ) ;
@@ -1582,6 +1591,12 @@ impl<'feat> ExpansionConfig<'feat> {
1582
1591
fn proc_macro_expr = proc_macro_expr,
1583
1592
fn proc_macro_non_items = proc_macro_non_items,
1584
1593
}
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
+ }
1585
1600
}
1586
1601
1587
1602
// A Marker adds the given mark to the syntax context.
0 commit comments