Skip to content

Commit 0b3db4e

Browse files
committed
Use native duplicate attribute check
1 parent bfdf234 commit 0b3db4e

File tree

6 files changed

+31
-32
lines changed

6 files changed

+31
-32
lines changed

compiler/rustc_attr/src/builtin.rs

-8
Original file line numberDiff line numberDiff line change
@@ -679,14 +679,6 @@ where
679679
continue;
680680
}
681681

682-
if let Some((_, span)) = &depr {
683-
struct_span_err!(diagnostic, attr.span, E0550, "multiple deprecated attributes")
684-
.span_label(attr.span, "repeated deprecation attribute")
685-
.span_label(*span, "first deprecation attribute")
686-
.emit();
687-
break;
688-
}
689-
690682
// FIXME(jhpratt) remove this eventually
691683
if attr.has_name(sym::rustc_deprecated) {
692684
diagnostic

compiler/rustc_feature/src/builtin_attrs.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
304304
List: r#"/*opt*/ since = "version", /*opt*/ note = "reason""#,
305305
NameValueStr: "reason"
306306
),
307-
// This has special duplicate handling in E0550 to handle duplicates with rustc_deprecated
308-
DuplicatesOk
307+
ErrorFollowing
309308
),
310309

311310
// Crate properties:
@@ -463,10 +462,10 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
463462
// ==========================================================================
464463

465464
ungated!(feature, CrateLevel, template!(List: "name1, name2, ..."), DuplicatesOk),
466-
// DuplicatesOk since it has its own validation
465+
// FIXME(jhpratt) remove this eventually
467466
ungated!(
468467
rustc_deprecated, Normal,
469-
template!(List: r#"since = "version", note = "...""#), DuplicatesOk // See E0550
468+
template!(List: r#"since = "version", note = "...""#), ErrorFollowing
470469
),
471470
// DuplicatesOk since it has its own validation
472471
ungated!(

src/test/ui/deprecation/deprecation-sanity.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ mod bogus_attribute_types_1 {
2424
}
2525

2626
#[deprecated(since = "a", note = "b")]
27-
#[deprecated(since = "a", note = "b")] //~ ERROR multiple deprecated attributes
27+
#[deprecated(since = "a", note = "b")] //~ ERROR multiple `deprecated` attributes
2828
fn multiple1() { }
2929

3030
#[deprecated(since = "a", since = "b", note = "c")] //~ ERROR multiple 'since' items

src/test/ui/deprecation/deprecation-sanity.stderr

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
error: multiple `deprecated` attributes
2+
--> $DIR/deprecation-sanity.rs:27:1
3+
|
4+
LL | #[deprecated(since = "a", note = "b")]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
6+
|
7+
note: attribute also specified here
8+
--> $DIR/deprecation-sanity.rs:26:1
9+
|
10+
LL | #[deprecated(since = "a", note = "b")]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
113
error[E0541]: unknown meta item 'reason'
214
--> $DIR/deprecation-sanity.rs:4:43
315
|
@@ -40,14 +52,6 @@ error[E0565]: item in `deprecated` must be a key/value pair
4052
LL | #[deprecated("test")]
4153
| ^^^^^^
4254

43-
error[E0550]: multiple deprecated attributes
44-
--> $DIR/deprecation-sanity.rs:27:1
45-
|
46-
LL | #[deprecated(since = "a", note = "b")]
47-
| -------------------------------------- first deprecation attribute
48-
LL | #[deprecated(since = "a", note = "b")]
49-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ repeated deprecation attribute
50-
5155
error[E0538]: multiple 'since' items
5256
--> $DIR/deprecation-sanity.rs:30:27
5357
|
@@ -64,5 +68,5 @@ LL | #[deprecated = "hello"]
6468

6569
error: aborting due to 10 previous errors
6670

67-
Some errors have detailed explanations: E0538, E0541, E0550, E0551, E0565.
71+
Some errors have detailed explanations: E0538, E0541, E0551, E0565.
6872
For more information about an error, try `rustc --explain E0538`.

src/test/ui/stability-attribute/stability-attribute-sanity.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fn multiple3() { }
5959

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

src/test/ui/stability-attribute/stability-attribute-sanity.stderr

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
error: multiple `deprecated` attributes
2+
--> $DIR/stability-attribute-sanity.rs:62:1
3+
|
4+
LL | #[deprecated(since = "b", note = "text")]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
6+
|
7+
note: attribute also specified here
8+
--> $DIR/stability-attribute-sanity.rs:61:1
9+
|
10+
LL | #[deprecated(since = "b", note = "text")]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
113
error[E0541]: unknown meta item 'reason'
214
--> $DIR/stability-attribute-sanity.rs:8:42
315
|
@@ -82,14 +94,6 @@ error[E0544]: multiple stability levels
8294
LL | #[stable(feature = "a", since = "b")]
8395
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8496

85-
error[E0550]: multiple deprecated attributes
86-
--> $DIR/stability-attribute-sanity.rs:62:1
87-
|
88-
LL | #[deprecated(since = "b", note = "text")]
89-
| ----------------------------------------- first deprecation attribute
90-
LL | #[deprecated(since = "b", note = "text")]
91-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ repeated deprecation attribute
92-
9397
error[E0544]: multiple stability levels
9498
--> $DIR/stability-attribute-sanity.rs:64:1
9599
|
@@ -128,5 +132,5 @@ LL | #[stable(feature = "a", since = "1.0.0")]
128132

129133
error: aborting due to 20 previous errors
130134

131-
Some errors have detailed explanations: E0539, E0541, E0542, E0543, E0544, E0546, E0547, E0549, E0550.
135+
Some errors have detailed explanations: E0539, E0541, E0542, E0543, E0544, E0546, E0547, E0549.
132136
For more information about an error, try `rustc --explain E0539`.

0 commit comments

Comments
 (0)