@@ -1103,6 +1103,45 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcEffectiveVisibilityParser {
11031103 const CREATE : fn ( Span ) -> AttributeKind = |_| AttributeKind :: RustcEffectiveVisibility ;
11041104}
11051105
1106+ pub ( crate ) struct RustcDiagnosticItemParser ;
1107+
1108+ impl < S : Stage > SingleAttributeParser < S > for RustcDiagnosticItemParser {
1109+ const PATH : & [ Symbol ] = & [ sym:: rustc_diagnostic_item] ;
1110+ const ATTRIBUTE_ORDER : AttributeOrder = AttributeOrder :: KeepOutermost ;
1111+ const ON_DUPLICATE : OnDuplicate < S > = OnDuplicate :: Error ;
1112+ const ALLOWED_TARGETS : AllowedTargets = AllowedTargets :: AllowList ( & [
1113+ Allow ( Target :: Trait ) ,
1114+ Allow ( Target :: Struct ) ,
1115+ Allow ( Target :: Enum ) ,
1116+ Allow ( Target :: MacroDef ) ,
1117+ Allow ( Target :: TyAlias ) ,
1118+ Allow ( Target :: AssocTy ) ,
1119+ Allow ( Target :: AssocConst ) ,
1120+ Allow ( Target :: Fn ) ,
1121+ Allow ( Target :: Const ) ,
1122+ Allow ( Target :: Mod ) ,
1123+ Allow ( Target :: Impl { of_trait : false } ) ,
1124+ Allow ( Target :: Method ( MethodKind :: Inherent ) ) ,
1125+ Allow ( Target :: Method ( MethodKind :: Trait { body : false } ) ) ,
1126+ Allow ( Target :: Method ( MethodKind :: Trait { body : true } ) ) ,
1127+ Allow ( Target :: Method ( MethodKind :: TraitImpl ) ) ,
1128+ Allow ( Target :: Crate ) ,
1129+ ] ) ;
1130+ const TEMPLATE : AttributeTemplate = template ! ( NameValueStr : "name" ) ;
1131+
1132+ fn convert ( cx : & mut AcceptContext < ' _ , ' _ , S > , args : & ArgParser ) -> Option < AttributeKind > {
1133+ let Some ( nv) = args. name_value ( ) else {
1134+ cx. expected_name_value ( cx. attr_span , None ) ;
1135+ return None ;
1136+ } ;
1137+ let Some ( value) = nv. value_as_str ( ) else {
1138+ cx. expected_string_literal ( nv. value_span , Some ( nv. value_as_lit ( ) ) ) ;
1139+ return None ;
1140+ } ;
1141+ Some ( AttributeKind :: RustcDiagnosticItem ( value) )
1142+ }
1143+ }
1144+
11061145pub ( crate ) struct RustcSymbolName ;
11071146
11081147impl < S : Stage > SingleAttributeParser < S > for RustcSymbolName {
0 commit comments