about summary refs log tree commit diff
path: root/tests/ui/test-attrs
diff options
context:
space:
mode:
authorStuart Cook <Zalathar@users.noreply.github.com>2025-08-07 20:49:40 +1000
committerGitHub <noreply@github.com>2025-08-07 20:49:40 +1000
commit995ca3e532b48b689567533e6b736675e38b741e (patch)
tree1c5813b2b57e49b0d87f0ca85c20f12d3a54b48c /tests/ui/test-attrs
parent5e781d05f6595762b363521d0524badb25255439 (diff)
parent4281e05a209a15a4b2de63ea5a552fc59f8bd0f1 (diff)
downloadrust-995ca3e532b48b689567533e6b736675e38b741e.tar.gz
rust-995ca3e532b48b689567533e6b736675e38b741e.zip
Rollup merge of #143808 - JonathanBrouwer:should_panic_parser, r=jdonszelmann
Port `#[should_panic]` to the new attribute parsing infrastructure

Ports `#[should_panic]` to the new attribute parsing infrastructure for https://github.com/rust-lang/rust/issues/131229#issuecomment-2971351163

r? ```@jdonszelmann```
Diffstat (limited to 'tests/ui/test-attrs')
-rw-r--r--tests/ui/test-attrs/test-should-panic-attr.rs13
-rw-r--r--tests/ui/test-attrs/test-should-panic-attr.stderr80
2 files changed, 72 insertions, 21 deletions
diff --git a/tests/ui/test-attrs/test-should-panic-attr.rs b/tests/ui/test-attrs/test-should-panic-attr.rs
index df2893b63ed..af54689551c 100644
--- a/tests/ui/test-attrs/test-should-panic-attr.rs
+++ b/tests/ui/test-attrs/test-should-panic-attr.rs
@@ -1,4 +1,3 @@
-//@ check-pass
 //@ compile-flags: --test
 
 #[test]
@@ -9,28 +8,32 @@ fn test1() {
 
 #[test]
 #[should_panic(expected)]
-//~^ WARN: argument must be of the form:
+//~^ ERROR malformed `should_panic` attribute input
+//~| NOTE expected this to be of the form `expected = "..."`
 fn test2() {
     panic!();
 }
 
 #[test]
 #[should_panic(expect)]
-//~^ WARN: argument must be of the form:
+//~^ ERROR malformed `should_panic` attribute input
+//~| NOTE the only valid argument here is "expected"
 fn test3() {
     panic!();
 }
 
 #[test]
 #[should_panic(expected(foo, bar))]
-//~^ WARN: argument must be of the form:
+//~^ ERROR malformed `should_panic` attribute input
+//~| NOTE expected this to be of the form `expected = "..."`
 fn test4() {
     panic!();
 }
 
 #[test]
 #[should_panic(expected = "foo", bar)]
-//~^ WARN: argument must be of the form:
+//~^ ERROR malformed `should_panic` attribute input
+//~| NOTE expected a single argument here
 fn test5() {
     panic!();
 }
diff --git a/tests/ui/test-attrs/test-should-panic-attr.stderr b/tests/ui/test-attrs/test-should-panic-attr.stderr
index 492d1d5e03a..5dfc8e503e8 100644
--- a/tests/ui/test-attrs/test-should-panic-attr.stderr
+++ b/tests/ui/test-attrs/test-should-panic-attr.stderr
@@ -1,34 +1,82 @@
-warning: argument must be of the form: `expected = "error message"`
-  --> $DIR/test-should-panic-attr.rs:11:1
+error[E0539]: malformed `should_panic` attribute input
+  --> $DIR/test-should-panic-attr.rs:10:1
    |
 LL | #[should_panic(expected)]
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^
+   | ^^^^^^^^^^^^^^^--------^^
+   |                |
+   |                expected this to be of the form `expected = "..."`
+   |
+help: try changing it to one of the following valid forms of the attribute
+   |
+LL - #[should_panic(expected)]
+LL + #[should_panic = "reason"]
+   |
+LL | #[should_panic(expected = "reason")]
+   |                         ++++++++++
+LL - #[should_panic(expected)]
+LL + #[should_panic]
    |
-   = note: errors in this attribute were erroneously allowed and will become a hard error in a future release
 
-warning: argument must be of the form: `expected = "error message"`
+error[E0539]: malformed `should_panic` attribute input
   --> $DIR/test-should-panic-attr.rs:18:1
    |
 LL | #[should_panic(expect)]
-   | ^^^^^^^^^^^^^^^^^^^^^^^
+   | ^^^^^^^^^^^^^^--------^
+   |               |
+   |               the only valid argument here is "expected"
+   |
+help: try changing it to one of the following valid forms of the attribute
+   |
+LL - #[should_panic(expect)]
+LL + #[should_panic = "reason"]
+   |
+LL | #[should_panic(expected = "reason")]
+   |                      +++++++++++++
+LL - #[should_panic(expect)]
+LL + #[should_panic]
    |
-   = note: errors in this attribute were erroneously allowed and will become a hard error in a future release
 
-warning: argument must be of the form: `expected = "error message"`
-  --> $DIR/test-should-panic-attr.rs:25:1
+error[E0539]: malformed `should_panic` attribute input
+  --> $DIR/test-should-panic-attr.rs:26:1
    |
 LL | #[should_panic(expected(foo, bar))]
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   | ^^^^^^^^^^^^^^^------------------^^
+   |                |
+   |                expected this to be of the form `expected = "..."`
+   |
+help: try changing it to one of the following valid forms of the attribute
+   |
+LL - #[should_panic(expected(foo, bar))]
+LL + #[should_panic = "reason"]
+   |
+LL - #[should_panic(expected(foo, bar))]
+LL + #[should_panic(expected = "reason")]
+   |
+LL - #[should_panic(expected(foo, bar))]
+LL + #[should_panic]
    |
-   = note: errors in this attribute were erroneously allowed and will become a hard error in a future release
 
-warning: argument must be of the form: `expected = "error message"`
-  --> $DIR/test-should-panic-attr.rs:32:1
+error[E0805]: malformed `should_panic` attribute input
+  --> $DIR/test-should-panic-attr.rs:34:1
    |
 LL | #[should_panic(expected = "foo", bar)]
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   | ^^^^^^^^^^^^^^-----------------------^
+   |               |
+   |               expected a single argument here
+   |
+help: try changing it to one of the following valid forms of the attribute
+   |
+LL - #[should_panic(expected = "foo", bar)]
+LL + #[should_panic = "reason"]
+   |
+LL - #[should_panic(expected = "foo", bar)]
+LL + #[should_panic(expected = "reason")]
+   |
+LL - #[should_panic(expected = "foo", bar)]
+LL + #[should_panic]
    |
-   = note: errors in this attribute were erroneously allowed and will become a hard error in a future release
 
-warning: 4 warnings emitted
+error: aborting due to 4 previous errors
 
+Some errors have detailed explanations: E0539, E0805.
+For more information about an error, try `rustc --explain E0539`.