@@ -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 ;
@@ -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
@@ -167,37 +163,21 @@ impl<S: Stage> AttributeParser<S> for NakedParser {
167
163
}
168
164
169
165
pub ( crate ) struct TrackCallerParser ;
170
-
171
- impl < S : Stage > SingleAttributeParser < S > for TrackCallerParser {
166
+ impl < S : Stage > NoArgsAttributeParser < S > for TrackCallerParser {
172
167
const PATH : & [ Symbol ] = & [ sym:: track_caller] ;
173
- const ATTRIBUTE_ORDER : AttributeOrder = AttributeOrder :: KeepLast ;
174
168
const ON_DUPLICATE : OnDuplicate < S > = OnDuplicate :: Warn ;
175
- const TEMPLATE : AttributeTemplate = template ! ( Word ) ;
176
169
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)
184
172
}
185
173
}
186
174
187
175
pub ( 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] ;
192
178
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
- }
200
179
201
- Some ( AttributeKind :: NoMangle ( cx. attr_span ) )
180
+ fn create ( span : Span ) -> AttributeKind {
181
+ AttributeKind :: NoMangle ( span)
202
182
}
203
183
}
0 commit comments