@@ -8,7 +8,9 @@ use rustc_ast::tokenstream::{
8
8
use rustc_ast:: { self as ast, AttrStyle , Attribute , HasAttrs , HasTokens , MetaItem , NodeId } ;
9
9
use rustc_attr as attr;
10
10
use rustc_data_structures:: flat_map_in_place:: FlatMapInPlace ;
11
- use rustc_feature:: { Features , ACCEPTED_FEATURES , REMOVED_FEATURES , UNSTABLE_FEATURES } ;
11
+ use rustc_feature:: {
12
+ AttributeSafety , Features , ACCEPTED_FEATURES , REMOVED_FEATURES , UNSTABLE_FEATURES ,
13
+ } ;
12
14
use rustc_lint_defs:: BuiltinLintDiag ;
13
15
use rustc_parse:: validate_attr;
14
16
use rustc_session:: parse:: feature_err;
@@ -263,6 +265,13 @@ impl<'a> StripUnconfigured<'a> {
263
265
/// is in the original source file. Gives a compiler error if the syntax of
264
266
/// the attribute is incorrect.
265
267
pub ( crate ) fn expand_cfg_attr ( & self , cfg_attr : & Attribute , recursive : bool ) -> Vec < Attribute > {
268
+ validate_attr:: check_attribute_safety (
269
+ self . features . unwrap_or ( & Features :: default ( ) ) ,
270
+ & self . sess . psess ,
271
+ AttributeSafety :: Normal ,
272
+ & cfg_attr,
273
+ ) ;
274
+
266
275
let Some ( ( cfg_predicate, expanded_attrs) ) =
267
276
rustc_parse:: parse_cfg_attr ( cfg_attr, & self . sess . psess )
268
277
else {
@@ -385,6 +394,13 @@ impl<'a> StripUnconfigured<'a> {
385
394
return ( true , None ) ;
386
395
}
387
396
} ;
397
+
398
+ validate_attr:: deny_builtin_meta_unsafety (
399
+ self . features . unwrap_or ( & Features :: default ( ) ) ,
400
+ & self . sess . psess ,
401
+ & meta_item,
402
+ ) ;
403
+
388
404
(
389
405
parse_cfg ( & meta_item, self . sess ) . map_or ( true , |meta_item| {
390
406
attr:: cfg_matches ( meta_item, & self . sess , self . lint_node_id , self . features )
0 commit comments