1
Fork 0

Use native duplicate attribute check

This commit is contained in:
Jacob Pratt 2022-04-11 20:43:42 -04:00
parent bfdf234fae
commit 0b3db4e4ee
No known key found for this signature in database
GPG key ID: B80E19E4662B5AA4
6 changed files with 31 additions and 32 deletions

View file

@ -679,14 +679,6 @@ where
continue; continue;
} }
if let Some((_, span)) = &depr {
struct_span_err!(diagnostic, attr.span, E0550, "multiple deprecated attributes")
.span_label(attr.span, "repeated deprecation attribute")
.span_label(*span, "first deprecation attribute")
.emit();
break;
}
// FIXME(jhpratt) remove this eventually // FIXME(jhpratt) remove this eventually
if attr.has_name(sym::rustc_deprecated) { if attr.has_name(sym::rustc_deprecated) {
diagnostic diagnostic

View file

@ -304,8 +304,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
List: r#"/*opt*/ since = "version", /*opt*/ note = "reason""#, List: r#"/*opt*/ since = "version", /*opt*/ note = "reason""#,
NameValueStr: "reason" NameValueStr: "reason"
), ),
// This has special duplicate handling in E0550 to handle duplicates with rustc_deprecated ErrorFollowing
DuplicatesOk
), ),
// Crate properties: // Crate properties:
@ -463,10 +462,10 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
// ========================================================================== // ==========================================================================
ungated!(feature, CrateLevel, template!(List: "name1, name2, ..."), DuplicatesOk), ungated!(feature, CrateLevel, template!(List: "name1, name2, ..."), DuplicatesOk),
// DuplicatesOk since it has its own validation // FIXME(jhpratt) remove this eventually
ungated!( ungated!(
rustc_deprecated, Normal, rustc_deprecated, Normal,
template!(List: r#"since = "version", note = "...""#), DuplicatesOk // See E0550 template!(List: r#"since = "version", note = "...""#), ErrorFollowing
), ),
// DuplicatesOk since it has its own validation // DuplicatesOk since it has its own validation
ungated!( ungated!(

View file

@ -24,7 +24,7 @@ mod bogus_attribute_types_1 {
} }
#[deprecated(since = "a", note = "b")] #[deprecated(since = "a", note = "b")]
#[deprecated(since = "a", note = "b")] //~ ERROR multiple deprecated attributes #[deprecated(since = "a", note = "b")] //~ ERROR multiple `deprecated` attributes
fn multiple1() { } fn multiple1() { }
#[deprecated(since = "a", since = "b", note = "c")] //~ ERROR multiple 'since' items #[deprecated(since = "a", since = "b", note = "c")] //~ ERROR multiple 'since' items

View file

@ -1,3 +1,15 @@
error: multiple `deprecated` attributes
--> $DIR/deprecation-sanity.rs:27:1
|
LL | #[deprecated(since = "a", note = "b")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
|
note: attribute also specified here
--> $DIR/deprecation-sanity.rs:26:1
|
LL | #[deprecated(since = "a", note = "b")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0541]: unknown meta item 'reason' error[E0541]: unknown meta item 'reason'
--> $DIR/deprecation-sanity.rs:4:43 --> $DIR/deprecation-sanity.rs:4:43
| |
@ -40,14 +52,6 @@ error[E0565]: item in `deprecated` must be a key/value pair
LL | #[deprecated("test")] LL | #[deprecated("test")]
| ^^^^^^ | ^^^^^^
error[E0550]: multiple deprecated attributes
--> $DIR/deprecation-sanity.rs:27:1
|
LL | #[deprecated(since = "a", note = "b")]
| -------------------------------------- first deprecation attribute
LL | #[deprecated(since = "a", note = "b")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ repeated deprecation attribute
error[E0538]: multiple 'since' items error[E0538]: multiple 'since' items
--> $DIR/deprecation-sanity.rs:30:27 --> $DIR/deprecation-sanity.rs:30:27
| |
@ -64,5 +68,5 @@ LL | #[deprecated = "hello"]
error: aborting due to 10 previous errors error: aborting due to 10 previous errors
Some errors have detailed explanations: E0538, E0541, E0550, E0551, E0565. Some errors have detailed explanations: E0538, E0541, E0551, E0565.
For more information about an error, try `rustc --explain E0538`. For more information about an error, try `rustc --explain E0538`.

View file

@ -59,7 +59,7 @@ fn multiple3() { }
#[stable(feature = "a", since = "b")] //~ ERROR invalid stability version found #[stable(feature = "a", since = "b")] //~ ERROR invalid stability version found
#[deprecated(since = "b", note = "text")] #[deprecated(since = "b", note = "text")]
#[deprecated(since = "b", note = "text")] //~ ERROR multiple deprecated attributes #[deprecated(since = "b", note = "text")] //~ ERROR multiple `deprecated` attributes
#[rustc_const_unstable(feature = "c", issue = "none")] #[rustc_const_unstable(feature = "c", issue = "none")]
#[rustc_const_unstable(feature = "d", issue = "none")] //~ ERROR multiple stability levels #[rustc_const_unstable(feature = "d", issue = "none")] //~ ERROR multiple stability levels
pub const fn multiple4() { } pub const fn multiple4() { }

View file

@ -1,3 +1,15 @@
error: multiple `deprecated` attributes
--> $DIR/stability-attribute-sanity.rs:62:1
|
LL | #[deprecated(since = "b", note = "text")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
|
note: attribute also specified here
--> $DIR/stability-attribute-sanity.rs:61:1
|
LL | #[deprecated(since = "b", note = "text")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0541]: unknown meta item 'reason' error[E0541]: unknown meta item 'reason'
--> $DIR/stability-attribute-sanity.rs:8:42 --> $DIR/stability-attribute-sanity.rs:8:42
| |
@ -82,14 +94,6 @@ error[E0544]: multiple stability levels
LL | #[stable(feature = "a", since = "b")] LL | #[stable(feature = "a", since = "b")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0550]: multiple deprecated attributes
--> $DIR/stability-attribute-sanity.rs:62:1
|
LL | #[deprecated(since = "b", note = "text")]
| ----------------------------------------- first deprecation attribute
LL | #[deprecated(since = "b", note = "text")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ repeated deprecation attribute
error[E0544]: multiple stability levels error[E0544]: multiple stability levels
--> $DIR/stability-attribute-sanity.rs:64:1 --> $DIR/stability-attribute-sanity.rs:64:1
| |
@ -128,5 +132,5 @@ LL | #[stable(feature = "a", since = "1.0.0")]
error: aborting due to 20 previous errors error: aborting due to 20 previous errors
Some errors have detailed explanations: E0539, E0541, E0542, E0543, E0544, E0546, E0547, E0549, E0550. Some errors have detailed explanations: E0539, E0541, E0542, E0543, E0544, E0546, E0547, E0549.
For more information about an error, try `rustc --explain E0539`. For more information about an error, try `rustc --explain E0539`.