Skip to content

Commit 30f78d4

Browse files
authored
Rollup merge of #143603 - Periodic1911:clarify_keepfistlast, r=compiler-errors
Clarify the meaning of `AttributeOrder::KeepFirst` and `AttributeOrder::KeepLast` Clarify the meaning of `KeepLast` and `KeepFirst` for #131229 (comment) Just a minor clarification, but me and `@JonathanBrouwer` have confused these two a few times so I think it's warranted. r? `@oli-obk` cc `@JonathanBrouwer`
2 parents ab2304b + 6254afa commit 30f78d4

File tree

1 file changed

+15
-1
lines changed
  • compiler/rustc_attr_parsing/src/attributes

1 file changed

+15
-1
lines changed

compiler/rustc_attr_parsing/src/attributes/mod.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,14 @@ impl<S: Stage> OnDuplicate<S> {
217217
// them will be merged in another PR
218218
#[allow(unused)]
219219
pub(crate) enum AttributeOrder {
220-
/// Duplicates after the first attribute will be an error.
220+
/// Duplicates after the first attribute will be an error. I.e. only keep the lowest attribute.
221+
///
222+
/// Attributes are processed from bottom to top, so this raises an error on all the attributes
223+
/// further above the lowest one:
224+
/// ```
225+
/// #[stable(since="1.0")] //~ WARNING duplicated attribute
226+
/// #[stable(since="2.0")]
227+
/// ```
221228
///
222229
/// This should be used where duplicates would be ignored, but carry extra
223230
/// meaning that could cause confusion. For example, `#[stable(since="1.0")]
@@ -227,6 +234,13 @@ pub(crate) enum AttributeOrder {
227234
/// Duplicates preceding the last instance of the attribute will be a
228235
/// warning, with a note that this will be an error in the future.
229236
///
237+
/// Attributes are processed from bottom to top, so this raises a warning on all the attributes
238+
/// below the higher one:
239+
/// ```
240+
/// #[path="foo.rs"]
241+
/// #[path="bar.rs"] //~ WARNING duplicated attribute
242+
/// ```
243+
///
230244
/// This is the same as `FutureWarnFollowing`, except the last attribute is
231245
/// the one that is "used". Ideally these can eventually migrate to
232246
/// `ErrorPreceding`.

0 commit comments

Comments
 (0)