Skip to content

Commit 9b51f63

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 cb288e3 + 6254afa commit 9b51f63

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

0 commit comments

Comments
 (0)