Skip to content

Commit

Permalink
Ui tests with compile_error resolved at call site
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jun 8, 2023
1 parent 6735d4b commit b534daf
Show file tree
Hide file tree
Showing 18 changed files with 88 additions and 1 deletion.
5 changes: 5 additions & 0 deletions tests/ui/bad-field-attr.stderr
@@ -1,5 +1,10 @@
error: #[error(transparent)] needs to go outside the enum or struct, not on an individual field
--> tests/ui/bad-field-attr.rs:5:18
|
3 | #[derive(Error, Debug)]
| ----- in this derive macro expansion
4 | #[error(transparent)]
5 | pub struct Error(#[error(transparent)] std::io::Error);
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)
2 changes: 1 addition & 1 deletion tests/ui/concat-display.stderr
Expand Up @@ -7,4 +7,4 @@ error: expected string literal
13 | error_type!(Error, "foo");
| ------------------------- in this macro invocation
|
= note: this error originates in the macro `error_type` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the derive macro `Error` which comes from the expansion of the macro `error_type` (in Nightly builds, run with -Z macro-backtrace for more info)
5 changes: 5 additions & 0 deletions tests/ui/duplicate-enum-source.stderr
@@ -1,5 +1,10 @@
error: duplicate #[source] attribute
--> tests/ui/duplicate-enum-source.rs:8:9
|
3 | #[derive(Error, Debug)]
| ----- in this derive macro expansion
...
8 | #[source]
| ^^^^^^^^^
|
= note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)
5 changes: 5 additions & 0 deletions tests/ui/duplicate-fmt.stderr
@@ -1,5 +1,10 @@
error: only one #[error(...)] attribute is allowed
--> tests/ui/duplicate-fmt.rs:5:1
|
3 | #[derive(Error, Debug)]
| ----- in this derive macro expansion
4 | #[error("...")]
5 | #[error("...")]
| ^^^^^^^^^^^^^^^
|
= note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)
5 changes: 5 additions & 0 deletions tests/ui/duplicate-struct-source.stderr
@@ -1,5 +1,10 @@
error: duplicate #[source] attribute
--> tests/ui/duplicate-struct-source.rs:7:5
|
3 | #[derive(Error, Debug)]
| ----- in this derive macro expansion
...
7 | #[source]
| ^^^^^^^^^
|
= note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)
5 changes: 5 additions & 0 deletions tests/ui/duplicate-transparent.stderr
@@ -1,5 +1,10 @@
error: duplicate #[error(transparent)] attribute
--> tests/ui/duplicate-transparent.rs:5:1
|
3 | #[derive(Error, Debug)]
| ----- in this derive macro expansion
4 | #[error(transparent)]
5 | #[error(transparent)]
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)
5 changes: 5 additions & 0 deletions tests/ui/from-backtrace-backtrace.stderr
@@ -1,5 +1,10 @@
error: deriving From requires no fields other than source and backtrace
--> tests/ui/from-backtrace-backtrace.rs:8:18
|
6 | #[derive(Error, Debug)]
| ----- in this derive macro expansion
7 | #[error("...")]
8 | pub struct Error(#[from] #[backtrace] std::io::Error, Backtrace);
| ^^^^^^^
|
= note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)
5 changes: 5 additions & 0 deletions tests/ui/from-not-source.stderr
@@ -1,5 +1,10 @@
error: #[from] is only supported on the source field, not any other field
--> tests/ui/from-not-source.rs:7:5
|
3 | #[derive(Debug, Error)]
| ----- in this derive macro expansion
...
7 | #[from]
| ^^^^^^^
|
= note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)
10 changes: 10 additions & 0 deletions tests/ui/lifetime.stderr
@@ -1,11 +1,21 @@
error: non-static lifetimes are not allowed in the source of an error, because std::error::Error requires the source is dyn Error + 'static
--> tests/ui/lifetime.rs:6:26
|
4 | #[derive(Error, Debug)]
| ----- in this derive macro expansion
5 | #[error("error")]
6 | struct Error<'a>(#[from] Inner<'a>);
| ^^^^^^^^^
|
= note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

error: non-static lifetimes are not allowed in the source of an error, because std::error::Error requires the source is dyn Error + 'static
--> tests/ui/lifetime.rs:15:17
|
12 | #[derive(Error, Debug)]
| ----- in this derive macro expansion
...
15 | Foo(#[from] Generic<&'a str>),
| ^^^^^^^^^^^^^^^^
|
= note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)
5 changes: 5 additions & 0 deletions tests/ui/missing-fmt.stderr
@@ -1,5 +1,10 @@
error: missing #[error("...")] display attribute
--> tests/ui/missing-fmt.rs:7:5
|
3 | #[derive(Error, Debug)]
| ----- in this derive macro expansion
...
7 | B(usize),
| ^^^^^^^^
|
= note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)
5 changes: 5 additions & 0 deletions tests/ui/transparent-display.stderr
@@ -1,5 +1,10 @@
error: cannot have both #[error(transparent)] and a display attribute
--> tests/ui/transparent-display.rs:5:1
|
3 | #[derive(Error, Debug)]
| ----- in this derive macro expansion
4 | #[error(transparent)]
5 | #[error("...")]
| ^^^^^^^^^^^^^^^
|
= note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)
5 changes: 5 additions & 0 deletions tests/ui/transparent-enum-many.stderr
@@ -1,6 +1,11 @@
error: #[error(transparent)] requires exactly one field
--> tests/ui/transparent-enum-many.rs:5:5
|
3 | #[derive(Error, Debug)]
| ----- in this derive macro expansion
4 | pub enum Error {
5 | / #[error(transparent)]
6 | | Other(anyhow::Error, String),
| |________________________________^
|
= note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)
5 changes: 5 additions & 0 deletions tests/ui/transparent-enum-source.stderr
@@ -1,5 +1,10 @@
error: transparent variant can't contain #[source]
--> tests/ui/transparent-enum-source.rs:6:11
|
3 | #[derive(Error, Debug)]
| ----- in this derive macro expansion
...
6 | Other(#[source] anyhow::Error),
| ^^^^^^^^^
|
= note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)
4 changes: 4 additions & 0 deletions tests/ui/transparent-struct-many.stderr
@@ -1,5 +1,9 @@
error: #[error(transparent)] requires exactly one field
--> tests/ui/transparent-struct-many.rs:4:1
|
3 | #[derive(Error, Debug)]
| ----- in this derive macro expansion
4 | #[error(transparent)]
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)
5 changes: 5 additions & 0 deletions tests/ui/transparent-struct-source.stderr
@@ -1,5 +1,10 @@
error: transparent error struct can't contain #[source]
--> tests/ui/transparent-struct-source.rs:5:18
|
3 | #[derive(Error, Debug)]
| ----- in this derive macro expansion
4 | #[error(transparent)]
5 | pub struct Error(#[source] anyhow::Error);
| ^^^^^^^^^
|
= note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)
5 changes: 5 additions & 0 deletions tests/ui/unexpected-field-fmt.stderr
@@ -1,5 +1,10 @@
error: not expected here; the #[error(...)] attribute belongs on top of a struct or an enum variant
--> tests/ui/unexpected-field-fmt.rs:6:9
|
3 | #[derive(Error, Debug)]
| ----- in this derive macro expansion
...
6 | #[error("...")]
| ^^^^^^^^^^^^^^^
|
= note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)
4 changes: 4 additions & 0 deletions tests/ui/unexpected-struct-source.stderr
@@ -1,5 +1,9 @@
error: not expected here; the #[source] attribute belongs on a specific field
--> tests/ui/unexpected-struct-source.rs:4:1
|
3 | #[derive(Error, Debug)]
| ----- in this derive macro expansion
4 | #[source]
| ^^^^^^^^^
|
= note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)
4 changes: 4 additions & 0 deletions tests/ui/union.stderr
@@ -1,8 +1,12 @@
error: union as errors are not supported
--> tests/ui/union.rs:4:1
|
3 | #[derive(Error)]
| ----- in this derive macro expansion
4 | / pub union U {
5 | | msg: &'static str,
6 | | num: usize,
7 | | }
| |_^
|
= note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

0 comments on commit b534daf

Please sign in to comment.