@@ -117,11 +117,35 @@ impl<S: Stage> SingleAttributeParser<S> for RustcLegacyConstGenericsParser {
117117 }
118118}
119119
120+ pub ( crate ) struct RustcLintOptDenyFieldAccessParser ;
121+
122+ impl < S : Stage > SingleAttributeParser < S > for RustcLintOptDenyFieldAccessParser {
123+ const PATH : & [ Symbol ] = & [ sym:: rustc_lint_opt_deny_field_access] ;
124+ const ATTRIBUTE_ORDER : AttributeOrder = AttributeOrder :: KeepInnermost ;
125+ const ON_DUPLICATE : OnDuplicate < S > = OnDuplicate :: Error ;
126+ const ALLOWED_TARGETS : AllowedTargets = AllowedTargets :: AllowList ( & [ Allow ( Target :: Field ) ] ) ;
127+ const TEMPLATE : AttributeTemplate = template ! ( Word ) ;
128+ fn convert ( cx : & mut AcceptContext < ' _ , ' _ , S > , args : & ArgParser ) -> Option < AttributeKind > {
129+ let Some ( arg) = args. list ( ) . and_then ( MetaItemListParser :: single) else {
130+ cx. expected_single_argument ( cx. attr_span ) ;
131+ return None ;
132+ } ;
133+
134+ let MetaItemOrLitParser :: Lit ( MetaItemLit { kind : LitKind :: Str ( lint_message, _) , .. } ) = arg
135+ else {
136+ cx. expected_string_literal ( arg. span ( ) , arg. lit ( ) ) ;
137+ return None ;
138+ } ;
139+
140+ Some ( AttributeKind :: RustcLintOptDenyFieldAccess { lint_message : * lint_message } )
141+ }
142+ }
143+
120144pub ( crate ) struct RustcLintOptTyParser ;
121145
122146impl < S : Stage > NoArgsAttributeParser < S > for RustcLintOptTyParser {
123147 const PATH : & [ Symbol ] = & [ sym:: rustc_lint_opt_ty] ;
124- const ON_DUPLICATE : OnDuplicate < S > = OnDuplicate :: Warn ;
148+ const ON_DUPLICATE : OnDuplicate < S > = OnDuplicate :: Error ;
125149 const ALLOWED_TARGETS : AllowedTargets = AllowedTargets :: AllowList ( & [ Allow ( Target :: Struct ) ] ) ;
126150 const CREATE : fn ( Span ) -> AttributeKind = |_| AttributeKind :: RustcLintOptTy ;
127151}
@@ -130,7 +154,7 @@ pub(crate) struct RustcLintQueryInstabilityParser;
130154
131155impl < S : Stage > NoArgsAttributeParser < S > for RustcLintQueryInstabilityParser {
132156 const PATH : & [ Symbol ] = & [ sym:: rustc_lint_query_instability] ;
133- const ON_DUPLICATE : OnDuplicate < S > = OnDuplicate :: Warn ;
157+ const ON_DUPLICATE : OnDuplicate < S > = OnDuplicate :: Error ;
134158 const ALLOWED_TARGETS : AllowedTargets = AllowedTargets :: AllowList ( & [
135159 Allow ( Target :: Fn ) ,
136160 Allow ( Target :: Method ( MethodKind :: Inherent ) ) ,
0 commit comments