@@ -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 , NullOnExport } ;
@@ -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
@@ -194,38 +190,22 @@ impl<S: Stage> AttributeParser<S> for NakedParser {
194190}
195191
196192pub ( crate ) struct TrackCallerParser ;
197-
198- impl < S : Stage > SingleAttributeParser < S > for TrackCallerParser {
193+ impl < S : Stage > NoArgsAttributeParser < S > for TrackCallerParser {
199194 const PATH : & [ Symbol ] = & [ sym:: track_caller] ;
200- const ATTRIBUTE_ORDER : AttributeOrder = AttributeOrder :: KeepLast ;
201195 const ON_DUPLICATE : OnDuplicate < S > = OnDuplicate :: Warn ;
202- const TEMPLATE : AttributeTemplate = template ! ( Word ) ;
203196
204- fn convert ( cx : & mut AcceptContext < ' _ , ' _ , S > , args : & ArgParser < ' _ > ) -> Option < AttributeKind > {
205- if let Err ( span) = args. no_args ( ) {
206- cx. expected_no_args ( span) ;
207- return None ;
208- }
209-
210- Some ( AttributeKind :: TrackCaller ( cx. attr_span ) )
197+ fn create ( span : Span ) -> AttributeKind {
198+ AttributeKind :: TrackCaller ( span)
211199 }
212200}
213201
214202pub ( crate ) struct NoMangleParser ;
215-
216- impl < S : Stage > SingleAttributeParser < S > for NoMangleParser {
217- const PATH : & [ rustc_span:: Symbol ] = & [ sym:: no_mangle] ;
218- const ATTRIBUTE_ORDER : AttributeOrder = AttributeOrder :: KeepLast ;
203+ impl < S : Stage > NoArgsAttributeParser < S > for NoMangleParser {
204+ const PATH : & [ Symbol ] = & [ sym:: no_mangle] ;
219205 const ON_DUPLICATE : OnDuplicate < S > = OnDuplicate :: Warn ;
220- const TEMPLATE : AttributeTemplate = template ! ( Word ) ;
221-
222- fn convert ( cx : & mut AcceptContext < ' _ , ' _ , S > , args : & ArgParser < ' _ > ) -> Option < AttributeKind > {
223- if let Err ( span) = args. no_args ( ) {
224- cx. expected_no_args ( span) ;
225- return None ;
226- }
227206
228- Some ( AttributeKind :: NoMangle ( cx. attr_span ) )
207+ fn create ( span : Span ) -> AttributeKind {
208+ AttributeKind :: NoMangle ( span)
229209 }
230210}
231211
0 commit comments