@@ -3,7 +3,10 @@ use rustc_feature::{AttributeTemplate, template};
33use rustc_session:: parse:: feature_err;
44use rustc_span:: { Span , Symbol , sym} ;
55
6- use super :: { AcceptMapping , AttributeOrder , AttributeParser , OnDuplicate , SingleAttributeParser } ;
6+ use super :: {
7+ AcceptMapping , AttributeOrder , AttributeParser , NoArgsAttributeParser , OnDuplicate ,
8+ SingleAttributeParser ,
9+ } ;
710use crate :: context:: { AcceptContext , FinalizeContext , Stage } ;
811use crate :: parser:: ArgParser ;
912use crate :: session_diagnostics:: NakedFunctionIncompatibleAttribute ;
@@ -43,19 +46,12 @@ impl<S: Stage> SingleAttributeParser<S> for OptimizeParser {
4346
4447pub ( crate ) struct ColdParser ;
4548
46- impl < S : Stage > SingleAttributeParser < S > for ColdParser {
49+ impl < S : Stage > NoArgsAttributeParser < S > for ColdParser {
4750 const PATH : & [ Symbol ] = & [ sym:: cold] ;
48- const ATTRIBUTE_ORDER : AttributeOrder = AttributeOrder :: KeepLast ;
4951 const ON_DUPLICATE : OnDuplicate < S > = OnDuplicate :: Warn ;
50- const TEMPLATE : AttributeTemplate = template ! ( Word ) ;
51-
52- fn convert ( cx : & mut AcceptContext < ' _ , ' _ , S > , args : & ArgParser < ' _ > ) -> Option < AttributeKind > {
53- if let Err ( span) = args. no_args ( ) {
54- cx. expected_no_args ( span) ;
55- return None ;
56- }
5752
58- Some ( AttributeKind :: Cold ( cx. attr_span ) )
53+ fn create ( span : Span ) -> AttributeKind {
54+ AttributeKind :: Cold ( span)
5955 }
6056}
6157
@@ -167,37 +163,21 @@ impl<S: Stage> AttributeParser<S> for NakedParser {
167163}
168164
169165pub ( crate ) struct TrackCallerParser ;
170-
171- impl < S : Stage > SingleAttributeParser < S > for TrackCallerParser {
166+ impl < S : Stage > NoArgsAttributeParser < S > for TrackCallerParser {
172167 const PATH : & [ Symbol ] = & [ sym:: track_caller] ;
173- const ATTRIBUTE_ORDER : AttributeOrder = AttributeOrder :: KeepLast ;
174168 const ON_DUPLICATE : OnDuplicate < S > = OnDuplicate :: Warn ;
175- const TEMPLATE : AttributeTemplate = template ! ( Word ) ;
176169
177- fn convert ( cx : & mut AcceptContext < ' _ , ' _ , S > , args : & ArgParser < ' _ > ) -> Option < AttributeKind > {
178- if let Err ( span) = args. no_args ( ) {
179- cx. expected_no_args ( span) ;
180- return None ;
181- }
182-
183- Some ( AttributeKind :: TrackCaller ( cx. attr_span ) )
170+ fn create ( span : Span ) -> AttributeKind {
171+ AttributeKind :: TrackCaller ( span)
184172 }
185173}
186174
187175pub ( crate ) struct NoMangleParser ;
188-
189- impl < S : Stage > SingleAttributeParser < S > for NoMangleParser {
190- const PATH : & [ rustc_span:: Symbol ] = & [ sym:: no_mangle] ;
191- const ATTRIBUTE_ORDER : AttributeOrder = AttributeOrder :: KeepLast ;
176+ impl < S : Stage > NoArgsAttributeParser < S > for NoMangleParser {
177+ const PATH : & [ Symbol ] = & [ sym:: no_mangle] ;
192178 const ON_DUPLICATE : OnDuplicate < S > = OnDuplicate :: Warn ;
193- const TEMPLATE : AttributeTemplate = template ! ( Word ) ;
194-
195- fn convert ( cx : & mut AcceptContext < ' _ , ' _ , S > , args : & ArgParser < ' _ > ) -> Option < AttributeKind > {
196- if let Err ( span) = args. no_args ( ) {
197- cx. expected_no_args ( span) ;
198- return None ;
199- }
200179
201- Some ( AttributeKind :: NoMangle ( cx. attr_span ) )
180+ fn create ( span : Span ) -> AttributeKind {
181+ AttributeKind :: NoMangle ( span)
202182 }
203183}
0 commit comments