@@ -195,11 +195,7 @@ impl<S: Stage> SingleAttributeParser<S> for RustcLintOptDenyFieldAccessParser {
195195 const ALLOWED_TARGETS : AllowedTargets = AllowedTargets :: AllowList ( & [ Allow ( Target :: Field ) ] ) ;
196196 const TEMPLATE : AttributeTemplate = template ! ( Word ) ;
197197 fn convert ( cx : & mut AcceptContext < ' _ , ' _ , S > , args : & ArgParser ) -> Option < AttributeKind > {
198- let Some ( arg) = args. list ( ) . and_then ( MetaItemListParser :: single) else {
199- let attr_span = cx. attr_span ;
200- cx. adcx ( ) . expected_single_argument ( attr_span, 2 ) ;
201- return None ;
202- } ;
198+ let arg = cx. single_element_list ( args, cx. attr_span ) ?;
203199
204200 let MetaItemOrLitParser :: Lit ( MetaItemLit { kind : LitKind :: Str ( lint_message, _) , .. } ) = arg
205201 else {
@@ -375,19 +371,10 @@ impl<S: Stage> SingleAttributeParser<S> for RustcDeprecatedSafe2024Parser {
375371 const TEMPLATE : AttributeTemplate = template ! ( List : & [ r#"audit_that = "...""# ] ) ;
376372
377373 fn convert ( cx : & mut AcceptContext < ' _ , ' _ , S > , args : & ArgParser ) -> Option < AttributeKind > {
378- let Some ( args) = args. list ( ) else {
379- let attr_span = cx. attr_span ;
380- cx. adcx ( ) . expected_list ( attr_span, args) ;
381- return None ;
382- } ;
383-
384- let Some ( single) = args. single ( ) else {
385- cx. adcx ( ) . expected_single_argument ( args. span , args. len ( ) ) ;
386- return None ;
387- } ;
374+ let single = cx. single_element_list ( args, cx. attr_span ) ?;
388375
389376 let Some ( arg) = single. meta_item ( ) else {
390- cx. adcx ( ) . expected_name_value ( args . span , None ) ;
377+ cx. adcx ( ) . expected_name_value ( single . span ( ) , None ) ;
391378 return None ;
392379 } ;
393380
@@ -1082,11 +1069,7 @@ impl<S: Stage> CombineAttributeParser<S> for RustcThenThisWouldNeedParser {
10821069 if !cx. cx . sess . opts . unstable_opts . query_dep_graph {
10831070 cx. emit_err ( AttributeRequiresOpt { span : cx. attr_span , opt : "-Z query-dep-graph" } ) ;
10841071 }
1085- let Some ( item) = args. list ( ) . and_then ( |l| l. single ( ) ) else {
1086- let inner_span = cx. inner_span ;
1087- cx. adcx ( ) . expected_single_argument ( inner_span, 2 ) ;
1088- return None ;
1089- } ;
1072+ let item = cx. single_element_list ( args, cx. attr_span ) ?;
10901073 let Some ( ident) = item. meta_item ( ) . and_then ( |item| item. ident ( ) ) else {
10911074 cx. adcx ( ) . expected_identifier ( item. span ( ) ) ;
10921075 return None ;
0 commit comments