@@ -3,7 +3,10 @@ use rustc_feature::{AttributeTemplate, template};
3
3
use rustc_session:: parse:: feature_err;
4
4
use rustc_span:: { Span , Symbol , sym} ;
5
5
6
- use super :: { AcceptMapping , AttributeOrder , AttributeParser , OnDuplicate , SingleAttributeParser } ;
6
+ use super :: {
7
+ AcceptMapping , AttributeOrder , AttributeParser , NoArgsAttributeParser , OnDuplicate ,
8
+ SingleAttributeParser ,
9
+ } ;
7
10
use crate :: context:: { AcceptContext , FinalizeContext , Stage } ;
8
11
use crate :: parser:: ArgParser ;
9
12
use crate :: session_diagnostics:: { NakedFunctionIncompatibleAttribute , NullOnExport } ;
@@ -43,19 +46,12 @@ impl<S: Stage> SingleAttributeParser<S> for OptimizeParser {
43
46
44
47
pub ( crate ) struct ColdParser ;
45
48
46
- impl < S : Stage > SingleAttributeParser < S > for ColdParser {
49
+ impl < S : Stage > NoArgsAttributeParser < S > for ColdParser {
47
50
const PATH : & [ Symbol ] = & [ sym:: cold] ;
48
- const ATTRIBUTE_ORDER : AttributeOrder = AttributeOrder :: KeepLast ;
49
51
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
- }
57
52
58
- Some ( AttributeKind :: Cold ( cx. attr_span ) )
53
+ fn create ( span : Span ) -> AttributeKind {
54
+ AttributeKind :: Cold ( span)
59
55
}
60
56
}
61
57
@@ -194,38 +190,22 @@ impl<S: Stage> AttributeParser<S> for NakedParser {
194
190
}
195
191
196
192
pub ( crate ) struct TrackCallerParser ;
197
-
198
- impl < S : Stage > SingleAttributeParser < S > for TrackCallerParser {
193
+ impl < S : Stage > NoArgsAttributeParser < S > for TrackCallerParser {
199
194
const PATH : & [ Symbol ] = & [ sym:: track_caller] ;
200
- const ATTRIBUTE_ORDER : AttributeOrder = AttributeOrder :: KeepLast ;
201
195
const ON_DUPLICATE : OnDuplicate < S > = OnDuplicate :: Warn ;
202
- const TEMPLATE : AttributeTemplate = template ! ( Word ) ;
203
196
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)
211
199
}
212
200
}
213
201
214
202
pub ( 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] ;
219
205
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
- }
227
206
228
- Some ( AttributeKind :: NoMangle ( cx. attr_span ) )
207
+ fn create ( span : Span ) -> AttributeKind {
208
+ AttributeKind :: NoMangle ( span)
229
209
}
230
210
}
231
211
0 commit comments