@@ -140,15 +140,15 @@ impl<T: SingleAttributeParser<S>, S: Stage> AttributeParser<S> for Single<T, S>
140
140
if let Some ( pa) = T :: convert ( cx, args) {
141
141
match T :: ATTRIBUTE_ORDER {
142
142
// keep the first and report immediately. ignore this attribute
143
- AttributeOrder :: KeepFirst => {
143
+ AttributeOrder :: KeepInnermost => {
144
144
if let Some ( ( _, unused) ) = group. 1 {
145
145
T :: ON_DUPLICATE . exec :: < T > ( cx, cx. attr_span , unused) ;
146
146
return ;
147
147
}
148
148
}
149
149
// keep the new one and warn about the previous,
150
150
// then replace
151
- AttributeOrder :: KeepLast => {
151
+ AttributeOrder :: KeepOutermost => {
152
152
if let Some ( ( _, used) ) = group. 1 {
153
153
T :: ON_DUPLICATE . exec :: < T > ( cx, used, cx. attr_span ) ;
154
154
}
@@ -165,9 +165,6 @@ impl<T: SingleAttributeParser<S>, S: Stage> AttributeParser<S> for Single<T, S>
165
165
}
166
166
}
167
167
168
- // FIXME(jdonszelmann): logic is implemented but the attribute parsers needing
169
- // them will be merged in another PR
170
- #[ allow( unused) ]
171
168
pub ( crate ) enum OnDuplicate < S : Stage > {
172
169
/// Give a default warning
173
170
Warn ,
@@ -213,39 +210,29 @@ impl<S: Stage> OnDuplicate<S> {
213
210
}
214
211
}
215
212
}
216
- //
217
- // FIXME(jdonszelmann): logic is implemented but the attribute parsers needing
218
- // them will be merged in another PR
219
- #[ allow( unused) ]
213
+
220
214
pub ( crate ) enum AttributeOrder {
221
- /// Duplicates after the first attribute will be an error. I.e. only keep the lowest attribute.
215
+ /// Duplicates after the innermost instance of the attribute will be an error/warning.
216
+ /// Only keep the lowest attribute.
222
217
///
223
- /// Attributes are processed from bottom to top, so this raises an error on all the attributes
218
+ /// Attributes are processed from bottom to top, so this raises a warning/ error on all the attributes
224
219
/// further above the lowest one:
225
220
/// ```
226
221
/// #[stable(since="1.0")] //~ WARNING duplicated attribute
227
222
/// #[stable(since="2.0")]
228
223
/// ```
229
- ///
230
- /// This should be used where duplicates would be ignored, but carry extra
231
- /// meaning that could cause confusion. For example, `#[stable(since="1.0")]
232
- /// #[stable(since="2.0")]`, which version should be used for `stable`?
233
- KeepFirst ,
224
+ KeepInnermost ,
234
225
235
- /// Duplicates preceding the last instance of the attribute will be a
236
- /// warning, with a note that this will be an error in the future .
226
+ /// Duplicates before the outermost instance of the attribute will be an error/warning.
227
+ /// Only keep the highest attribute .
237
228
///
238
- /// Attributes are processed from bottom to top, so this raises a warning on all the attributes
239
- /// below the higher one:
229
+ /// Attributes are processed from bottom to top, so this raises a warning/error on all the attributes
230
+ /// below the highest one:
240
231
/// ```
241
232
/// #[path="foo.rs"]
242
233
/// #[path="bar.rs"] //~ WARNING duplicated attribute
243
234
/// ```
244
- ///
245
- /// This is the same as `FutureWarnFollowing`, except the last attribute is
246
- /// the one that is "used". Ideally these can eventually migrate to
247
- /// `ErrorPreceding`.
248
- KeepLast ,
235
+ KeepOutermost ,
249
236
}
250
237
251
238
/// An even simpler version of [`SingleAttributeParser`]:
@@ -271,7 +258,7 @@ impl<T: NoArgsAttributeParser<S>, S: Stage> Default for WithoutArgs<T, S> {
271
258
272
259
impl < T : NoArgsAttributeParser < S > , S : Stage > SingleAttributeParser < S > for WithoutArgs < T , S > {
273
260
const PATH : & [ Symbol ] = T :: PATH ;
274
- const ATTRIBUTE_ORDER : AttributeOrder = AttributeOrder :: KeepLast ;
261
+ const ATTRIBUTE_ORDER : AttributeOrder = AttributeOrder :: KeepOutermost ;
275
262
const ON_DUPLICATE : OnDuplicate < S > = T :: ON_DUPLICATE ;
276
263
const TEMPLATE : AttributeTemplate = template ! ( Word ) ;
277
264
0 commit comments