1+ use rustc_feature:: AttributeStability ;
12use rustc_hir:: attrs:: { CoverageAttrKind , OptimizeAttr , RtsanSetting , SanitizerSet , UsedBy } ;
23use rustc_session:: errors:: feature_err;
34use rustc_span:: edition:: Edition :: Edition2024 ;
@@ -22,6 +23,7 @@ impl SingleAttributeParser for OptimizeParser {
2223 Allow ( Target :: Method ( MethodKind :: Inherent ) ) ,
2324 ] ) ;
2425 const TEMPLATE : AttributeTemplate = template ! ( List : & [ "size" , "speed" , "none" ] ) ;
26+ const STABILITY : AttributeStability = unstable ! ( optimize_attribute) ;
2527
2628 fn convert ( cx : & mut AcceptContext < ' _ , ' _ > , args : & ArgParser ) -> Option < AttributeKind > {
2729 let single = cx. expect_single_element_list ( args, cx. attr_span ) ?;
@@ -54,6 +56,7 @@ impl NoArgsAttributeParser for ColdParser {
5456 Allow ( Target :: ForeignFn ) ,
5557 Allow ( Target :: Closure ) ,
5658 ] ) ;
59+ const STABILITY : AttributeStability = AttributeStability :: Stable ;
5760 const CREATE : fn ( Span ) -> AttributeKind = |_| AttributeKind :: Cold ;
5861}
5962
@@ -73,6 +76,7 @@ impl SingleAttributeParser for CoverageParser {
7376 Allow ( Target :: Crate ) ,
7477 ] ) ;
7578 const TEMPLATE : AttributeTemplate = template ! ( OneOf : & [ sym:: off, sym:: on] ) ;
79+ const STABILITY : AttributeStability = unstable ! ( coverage_attribute) ;
7680
7781 fn convert ( cx : & mut AcceptContext < ' _ , ' _ > , args : & ArgParser ) -> Option < AttributeKind > {
7882 let arg = cx. expect_single_element_list ( args, cx. attr_span ) ?;
@@ -116,6 +120,7 @@ impl SingleAttributeParser for ExportNameParser {
116120 Warn ( Target :: MacroCall ) ,
117121 ] ) ;
118122 const TEMPLATE : AttributeTemplate = template ! ( NameValueStr : "name" ) ;
123+ const STABILITY : AttributeStability = AttributeStability :: Stable ;
119124
120125 fn convert ( cx : & mut AcceptContext < ' _ , ' _ > , args : & ArgParser ) -> Option < AttributeKind > {
121126 let nv = cx. expect_name_value ( args, cx. attr_span , None ) ?;
@@ -143,6 +148,7 @@ impl SingleAttributeParser for RustcObjcClassParser {
143148 const ALLOWED_TARGETS : AllowedTargets =
144149 AllowedTargets :: AllowList ( & [ Allow ( Target :: ForeignStatic ) ] ) ;
145150 const TEMPLATE : AttributeTemplate = template ! ( NameValueStr : "ClassName" ) ;
151+ const STABILITY : AttributeStability = unstable ! ( rustc_attrs) ;
146152
147153 fn convert ( cx : & mut AcceptContext < ' _ , ' _ > , args : & ArgParser ) -> Option < AttributeKind > {
148154 let nv = cx. expect_name_value ( args, cx. attr_span , None ) ?;
@@ -170,6 +176,7 @@ impl SingleAttributeParser for RustcObjcSelectorParser {
170176 const ALLOWED_TARGETS : AllowedTargets =
171177 AllowedTargets :: AllowList ( & [ Allow ( Target :: ForeignStatic ) ] ) ;
172178 const TEMPLATE : AttributeTemplate = template ! ( NameValueStr : "methodName" ) ;
179+ const STABILITY : AttributeStability = unstable ! ( rustc_attrs) ;
173180
174181 fn convert ( cx : & mut AcceptContext < ' _ , ' _ > , args : & ArgParser ) -> Option < AttributeKind > {
175182 let nv = cx. expect_name_value ( args, cx. attr_span , None ) ?;
@@ -197,7 +204,7 @@ pub(crate) struct NakedParser {
197204
198205impl AttributeParser for NakedParser {
199206 const ATTRIBUTES : AcceptMapping < Self > =
200- & [ ( & [ sym:: naked] , template ! ( Word ) , |this, cx, args| {
207+ & [ ( & [ sym:: naked] , template ! ( Word ) , AttributeStability :: Stable , |this, cx, args| {
201208 let Some ( ( ) ) = cx. expect_no_args ( args) else {
202209 return ;
203210 } ;
@@ -331,6 +338,7 @@ impl NoArgsAttributeParser for TrackCallerParser {
331338 Warn ( Target :: Field ) ,
332339 Warn ( Target :: MacroCall ) ,
333340 ] ) ;
341+ const STABILITY : AttributeStability = AttributeStability :: Stable ;
334342 const CREATE : fn ( Span ) -> AttributeKind = AttributeKind :: TrackCaller ;
335343}
336344
@@ -347,6 +355,7 @@ impl NoArgsAttributeParser for NoMangleParser {
347355 AllowSilent ( Target :: Const ) , // Handled in the `InvalidNoMangleItems` pass
348356 Error ( Target :: Closure ) ,
349357 ] ) ;
358+ const STABILITY : AttributeStability = AttributeStability :: Stable ;
350359 const CREATE : fn ( Span ) -> AttributeKind = AttributeKind :: NoMangle ;
351360}
352361
@@ -365,6 +374,7 @@ impl AttributeParser for UsedParser {
365374 const ATTRIBUTES : AcceptMapping < Self > = & [ (
366375 & [ sym:: used] ,
367376 template ! ( Word , List : & [ "compiler" , "linker" ] ) ,
377+ AttributeStability :: Stable ,
368378 |group : & mut Self , cx, args| {
369379 let used_by = match args {
370380 ArgParser :: NoArgs => UsedBy :: Default ,
@@ -502,6 +512,7 @@ impl CombineAttributeParser for TargetFeatureParser {
502512 was_forced : false ,
503513 } ;
504514 const TEMPLATE : AttributeTemplate = template ! ( List : & [ "enable = \" feat1, feat2\" " ] ) ;
515+ const STABILITY : AttributeStability = AttributeStability :: Stable ;
505516
506517 fn extend (
507518 cx : & mut AcceptContext < ' _ , ' _ > ,
@@ -541,6 +552,7 @@ impl CombineAttributeParser for ForceTargetFeatureParser {
541552 Allow ( Target :: Method ( MethodKind :: Trait { body : true } ) ) ,
542553 Allow ( Target :: Method ( MethodKind :: TraitImpl ) ) ,
543554 ] ) ;
555+ const STABILITY : AttributeStability = unstable ! ( effective_target_features) ;
544556
545557 fn extend (
546558 cx : & mut AcceptContext < ' _ , ' _ > ,
@@ -554,10 +566,8 @@ pub(crate) struct SanitizeParser;
554566
555567impl SingleAttributeParser for SanitizeParser {
556568 const PATH : & [ Symbol ] = & [ sym:: sanitize] ;
557-
558569 // FIXME: still checked in check_attrs.rs
559570 const ALLOWED_TARGETS : AllowedTargets = AllowedTargets :: AllowList ( ALL_TARGETS ) ;
560-
561571 const TEMPLATE : AttributeTemplate = template ! ( List : & [
562572 r#"address = "on|off""# ,
563573 r#"kernel_address = "on|off""# ,
@@ -571,6 +581,7 @@ impl SingleAttributeParser for SanitizeParser {
571581 r#"thread = "on|off""# ,
572582 r#"realtime = "nonblocking|blocking|caller""# ,
573583 ] ) ;
584+ const STABILITY : AttributeStability = unstable ! ( sanitize) ;
574585
575586 fn convert ( cx : & mut AcceptContext < ' _ , ' _ > , args : & ArgParser ) -> Option < AttributeKind > {
576587 let list = cx. expect_list ( args, cx. attr_span ) ?;
@@ -667,6 +678,7 @@ impl NoArgsAttributeParser for ThreadLocalParser {
667678 const PATH : & [ Symbol ] = & [ sym:: thread_local] ;
668679 const ALLOWED_TARGETS : AllowedTargets =
669680 AllowedTargets :: AllowList ( & [ Allow ( Target :: Static ) , Allow ( Target :: ForeignStatic ) ] ) ;
681+ const STABILITY : AttributeStability = unstable ! ( thread_local) ;
670682 const CREATE : fn ( Span ) -> AttributeKind = |_| AttributeKind :: ThreadLocal ;
671683}
672684
@@ -675,6 +687,7 @@ pub(crate) struct RustcPassIndirectlyInNonRusticAbisParser;
675687impl NoArgsAttributeParser for RustcPassIndirectlyInNonRusticAbisParser {
676688 const PATH : & [ Symbol ] = & [ sym:: rustc_pass_indirectly_in_non_rustic_abis] ;
677689 const ALLOWED_TARGETS : AllowedTargets = AllowedTargets :: AllowList ( & [ Allow ( Target :: Struct ) ] ) ;
690+ const STABILITY : AttributeStability = unstable ! ( rustc_attrs) ;
678691 const CREATE : fn ( Span ) -> AttributeKind = AttributeKind :: RustcPassIndirectlyInNonRusticAbis ;
679692}
680693
@@ -684,6 +697,7 @@ impl NoArgsAttributeParser for RustcEiiForeignItemParser {
684697 const PATH : & [ Symbol ] = & [ sym:: rustc_eii_foreign_item] ;
685698 const ALLOWED_TARGETS : AllowedTargets =
686699 AllowedTargets :: AllowList ( & [ Allow ( Target :: ForeignFn ) , Allow ( Target :: ForeignStatic ) ] ) ;
700+ const STABILITY : AttributeStability = unstable ! ( eii_internals) ;
687701 const CREATE : fn ( Span ) -> AttributeKind = |_| AttributeKind :: RustcEiiForeignItem ;
688702}
689703
@@ -693,6 +707,7 @@ impl SingleAttributeParser for PatchableFunctionEntryParser {
693707 const PATH : & [ Symbol ] = & [ sym:: patchable_function_entry] ;
694708 const ALLOWED_TARGETS : AllowedTargets = AllowedTargets :: AllowList ( & [ Allow ( Target :: Fn ) ] ) ;
695709 const TEMPLATE : AttributeTemplate = template ! ( List : & [ "prefix_nops = m, entry_nops = n" ] ) ;
710+ const STABILITY : AttributeStability = unstable ! ( patchable_function_entry) ;
696711
697712 fn convert ( cx : & mut AcceptContext < ' _ , ' _ > , args : & ArgParser ) -> Option < AttributeKind > {
698713 let meta_item_list = cx. expect_list ( args, cx. attr_span ) ?;
0 commit comments