@@ -140,15 +140,15 @@ impl<T: SingleAttributeParser<S>, S: Stage> AttributeParser<S> for Single<T, S>
140140 if let Some ( pa) = T :: convert ( cx, args) {
141141 match T :: ATTRIBUTE_ORDER {
142142 // keep the first and report immediately. ignore this attribute
143- AttributeOrder :: KeepFirst => {
143+ AttributeOrder :: KeepInnermost => {
144144 if let Some ( ( _, unused) ) = group. 1 {
145145 T :: ON_DUPLICATE . exec :: < T > ( cx, cx. attr_span , unused) ;
146146 return ;
147147 }
148148 }
149149 // keep the new one and warn about the previous,
150150 // then replace
151- AttributeOrder :: KeepLast => {
151+ AttributeOrder :: KeepOutermost => {
152152 if let Some ( ( _, used) ) = group. 1 {
153153 T :: ON_DUPLICATE . exec :: < T > ( cx, used, cx. attr_span ) ;
154154 }
@@ -165,9 +165,6 @@ impl<T: SingleAttributeParser<S>, S: Stage> AttributeParser<S> for Single<T, S>
165165 }
166166}
167167
168- // FIXME(jdonszelmann): logic is implemented but the attribute parsers needing
169- // them will be merged in another PR
170- #[ allow( unused) ]
171168pub ( crate ) enum OnDuplicate < S : Stage > {
172169 /// Give a default warning
173170 Warn ,
@@ -213,39 +210,29 @@ impl<S: Stage> OnDuplicate<S> {
213210 }
214211 }
215212}
216- //
217- // FIXME(jdonszelmann): logic is implemented but the attribute parsers needing
218- // them will be merged in another PR
219- #[ allow( unused) ]
213+
220214pub ( 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.
222217 ///
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
224219 /// further above the lowest one:
225220 /// ```
226221 /// #[stable(since="1.0")] //~ WARNING duplicated attribute
227222 /// #[stable(since="2.0")]
228223 /// ```
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 ,
234225
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 .
237228 ///
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:
240231 /// ```
241232 /// #[path="foo.rs"]
242233 /// #[path="bar.rs"] //~ WARNING duplicated attribute
243234 /// ```
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 ,
249236}
250237
251238/// An even simpler version of [`SingleAttributeParser`]:
@@ -271,7 +258,7 @@ impl<T: NoArgsAttributeParser<S>, S: Stage> Default for WithoutArgs<T, S> {
271258
272259impl < T : NoArgsAttributeParser < S > , S : Stage > SingleAttributeParser < S > for WithoutArgs < T , S > {
273260 const PATH : & [ Symbol ] = T :: PATH ;
274- const ATTRIBUTE_ORDER : AttributeOrder = AttributeOrder :: KeepLast ;
261+ const ATTRIBUTE_ORDER : AttributeOrder = AttributeOrder :: KeepOutermost ;
275262 const ON_DUPLICATE : OnDuplicate < S > = T :: ON_DUPLICATE ;
276263 const TEMPLATE : AttributeTemplate = template ! ( Word ) ;
277264
0 commit comments