Skip to content

Commit 787588b

Browse files
committed
Keep allowing invalid metaitem syntax in diagnostic attributes
1 parent 743fddb commit 787588b

File tree

4 files changed

+28
-10
lines changed

4 files changed

+28
-10
lines changed

compiler/rustc_attr_parsing/src/parser.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,9 @@ impl ArgParser {
113113
Some(match value {
114114
AttrArgs::Empty => Self::NoArgs,
115115
AttrArgs::Delimited(args) => {
116-
// The arguments of rustc_dummy are not validated if the arguments are delimited
117-
if parts == &[sym::rustc_dummy] {
116+
// The arguments of rustc_dummy and diagnostic attributes are not validated
117+
// if the arguments are delimited
118+
if parts == &[sym::rustc_dummy] || parts[0] == sym::diagnostic {
118119
return Some(ArgParser::List(MetaItemListParser {
119120
sub_parsers: ThinVec::new(),
120121
span: args.dspan.entire(),
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
warning: `#[diagnostic::do_not_recommend]` does not expect any arguments
2-
--> $DIR/does_not_acccept_args.rs:11:1
2+
--> $DIR/does_not_acccept_args.rs:12:1
33
|
44
LL | #[diagnostic::do_not_recommend(not_accepted)]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: `#[warn(malformed_diagnostic_attributes)]` (part of `#[warn(unknown_or_malformed_diagnostic_attributes)]`) on by default
88

99
warning: `#[diagnostic::do_not_recommend]` does not expect any arguments
10-
--> $DIR/does_not_acccept_args.rs:15:1
10+
--> $DIR/does_not_acccept_args.rs:16:1
1111
|
1212
LL | #[diagnostic::do_not_recommend(not_accepted = "foo")]
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1414

1515
warning: `#[diagnostic::do_not_recommend]` does not expect any arguments
16-
--> $DIR/does_not_acccept_args.rs:19:1
16+
--> $DIR/does_not_acccept_args.rs:20:1
1717
|
1818
LL | #[diagnostic::do_not_recommend(not_accepted(42))]
1919
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2020

21-
warning: 3 warnings emitted
21+
warning: `#[diagnostic::do_not_recommend]` does not expect any arguments
22+
--> $DIR/does_not_acccept_args.rs:24:1
23+
|
24+
LL | #[diagnostic::do_not_recommend(x = y + z)]
25+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
26+
27+
warning: 4 warnings emitted
2228

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
warning: `#[diagnostic::do_not_recommend]` does not expect any arguments
2-
--> $DIR/does_not_acccept_args.rs:11:1
2+
--> $DIR/does_not_acccept_args.rs:12:1
33
|
44
LL | #[diagnostic::do_not_recommend(not_accepted)]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: `#[warn(malformed_diagnostic_attributes)]` (part of `#[warn(unknown_or_malformed_diagnostic_attributes)]`) on by default
88

99
warning: `#[diagnostic::do_not_recommend]` does not expect any arguments
10-
--> $DIR/does_not_acccept_args.rs:15:1
10+
--> $DIR/does_not_acccept_args.rs:16:1
1111
|
1212
LL | #[diagnostic::do_not_recommend(not_accepted = "foo")]
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1414

1515
warning: `#[diagnostic::do_not_recommend]` does not expect any arguments
16-
--> $DIR/does_not_acccept_args.rs:19:1
16+
--> $DIR/does_not_acccept_args.rs:20:1
1717
|
1818
LL | #[diagnostic::do_not_recommend(not_accepted(42))]
1919
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2020

21-
warning: 3 warnings emitted
21+
warning: `#[diagnostic::do_not_recommend]` does not expect any arguments
22+
--> $DIR/does_not_acccept_args.rs:24:1
23+
|
24+
LL | #[diagnostic::do_not_recommend(x = y + z)]
25+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
26+
27+
warning: 4 warnings emitted
2228

tests/ui/diagnostic_namespace/do_not_recommend/does_not_acccept_args.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
trait Foo {}
88
trait Bar {}
99
trait Baz {}
10+
trait Boo {}
1011

1112
#[diagnostic::do_not_recommend(not_accepted)]
1213
//~^ WARNING `#[diagnostic::do_not_recommend]` does not expect any arguments
@@ -20,4 +21,8 @@ impl<T> Bar for T where T: Send {}
2021
//~^ WARNING `#[diagnostic::do_not_recommend]` does not expect any arguments
2122
impl<T> Baz for T where T: Send {}
2223

24+
#[diagnostic::do_not_recommend(x = y + z)]
25+
//~^ WARNING `#[diagnostic::do_not_recommend]` does not expect any arguments
26+
impl<T> Boo for T where T: Send {}
27+
2328
fn main() {}

0 commit comments

Comments
 (0)