Skip to content

Commit d7e3bdd

Browse files
committed
Fix redundant "Error doesn't implement Display" in fallback
1 parent 7e5ff62 commit d7e3bdd

20 files changed

Lines changed: 7 additions & 280 deletions

impl/src/expand.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ fn fallback(input: &DeriveInput, error: syn::Error) -> TokenStream {
3737

3838
#[allow(unused_qualifications)]
3939
impl #impl_generics std::error::Error for #ty #ty_generics #where_clause {}
40+
41+
#[allow(unused_qualifications)]
42+
impl #impl_generics ::core::fmt::Display for #ty #ty_generics #where_clause {
43+
fn fmt(&self, __formatter: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
44+
::core::unreachable!()
45+
}
46+
}
4047
}
4148
}
4249

tests/ui/bad-field-attr.stderr

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,3 @@ error: #[error(transparent)] needs to go outside the enum or struct, not on an i
33
|
44
5 | pub struct Error(#[error(transparent)] std::io::Error);
55
| ^^^^^^^^^^^^^^^^^^^^^
6-
7-
error[E0277]: `Error` doesn't implement `std::fmt::Display`
8-
--> tests/ui/bad-field-attr.rs:5:12
9-
|
10-
5 | pub struct Error(#[error(transparent)] std::io::Error);
11-
| ^^^^^ `Error` cannot be formatted with the default formatter
12-
|
13-
= help: the trait `std::fmt::Display` is not implemented for `Error`
14-
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
15-
note: required by a bound in `std::error::Error`
16-
--> $RUST/core/src/error.rs
17-
|
18-
| pub trait Error: Debug + Display {
19-
| ^^^^^^^ required by this bound in `Error`

tests/ui/concat-display.stderr

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,3 @@ error: expected string literal
88
| ------------------------- in this macro invocation
99
|
1010
= note: this error originates in the macro `error_type` (in Nightly builds, run with -Z macro-backtrace for more info)
11-
12-
error[E0277]: `Error` doesn't implement `std::fmt::Display`
13-
--> tests/ui/concat-display.rs:13:13
14-
|
15-
13 | error_type!(Error, "foo");
16-
| ^^^^^ `Error` cannot be formatted with the default formatter
17-
|
18-
= help: the trait `std::fmt::Display` is not implemented for `Error`
19-
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
20-
note: required by a bound in `std::error::Error`
21-
--> $RUST/core/src/error.rs
22-
|
23-
| pub trait Error: Debug + Display {
24-
| ^^^^^^^ required by this bound in `Error`

tests/ui/duplicate-enum-source.stderr

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,3 @@ error: duplicate #[source] attribute
33
|
44
8 | #[source]
55
| ^^^^^^^^^
6-
7-
error[E0277]: `ErrorEnum` doesn't implement `std::fmt::Display`
8-
--> tests/ui/duplicate-enum-source.rs:4:10
9-
|
10-
4 | pub enum ErrorEnum {
11-
| ^^^^^^^^^ `ErrorEnum` cannot be formatted with the default formatter
12-
|
13-
= help: the trait `std::fmt::Display` is not implemented for `ErrorEnum`
14-
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
15-
note: required by a bound in `std::error::Error`
16-
--> $RUST/core/src/error.rs
17-
|
18-
| pub trait Error: Debug + Display {
19-
| ^^^^^^^ required by this bound in `Error`

tests/ui/duplicate-fmt.stderr

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,3 @@ error: only one #[error(...)] attribute is allowed
33
|
44
5 | #[error("...")]
55
| ^^^^^^^^^^^^^^^
6-
7-
error[E0277]: `Error` doesn't implement `std::fmt::Display`
8-
--> tests/ui/duplicate-fmt.rs:6:12
9-
|
10-
6 | pub struct Error;
11-
| ^^^^^ `Error` cannot be formatted with the default formatter
12-
|
13-
= help: the trait `std::fmt::Display` is not implemented for `Error`
14-
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
15-
note: required by a bound in `std::error::Error`
16-
--> $RUST/core/src/error.rs
17-
|
18-
| pub trait Error: Debug + Display {
19-
| ^^^^^^^ required by this bound in `Error`

tests/ui/duplicate-struct-source.stderr

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,3 @@ error: duplicate #[source] attribute
33
|
44
7 | #[source]
55
| ^^^^^^^^^
6-
7-
error[E0277]: `ErrorStruct` doesn't implement `std::fmt::Display`
8-
--> tests/ui/duplicate-struct-source.rs:4:12
9-
|
10-
4 | pub struct ErrorStruct {
11-
| ^^^^^^^^^^^ `ErrorStruct` cannot be formatted with the default formatter
12-
|
13-
= help: the trait `std::fmt::Display` is not implemented for `ErrorStruct`
14-
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
15-
note: required by a bound in `std::error::Error`
16-
--> $RUST/core/src/error.rs
17-
|
18-
| pub trait Error: Debug + Display {
19-
| ^^^^^^^ required by this bound in `Error`

tests/ui/duplicate-transparent.stderr

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,3 @@ error: duplicate #[error(transparent)] attribute
33
|
44
5 | #[error(transparent)]
55
| ^^^^^^^^^^^^^^^^^^^^^
6-
7-
error[E0277]: `Error` doesn't implement `std::fmt::Display`
8-
--> tests/ui/duplicate-transparent.rs:6:12
9-
|
10-
6 | pub struct Error(anyhow::Error);
11-
| ^^^^^ `Error` cannot be formatted with the default formatter
12-
|
13-
= help: the trait `std::fmt::Display` is not implemented for `Error`
14-
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
15-
note: required by a bound in `std::error::Error`
16-
--> $RUST/core/src/error.rs
17-
|
18-
| pub trait Error: Debug + Display {
19-
| ^^^^^^^ required by this bound in `Error`

tests/ui/from-backtrace-backtrace.stderr

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,3 @@ error: deriving From requires no fields other than source and backtrace
33
|
44
9 | #[from]
55
| ^^^^^^^
6-
7-
error[E0277]: `Error` doesn't implement `std::fmt::Display`
8-
--> tests/ui/from-backtrace-backtrace.rs:8:12
9-
|
10-
8 | pub struct Error(
11-
| ^^^^^ `Error` cannot be formatted with the default formatter
12-
|
13-
= help: the trait `std::fmt::Display` is not implemented for `Error`
14-
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
15-
note: required by a bound in `std::error::Error`
16-
--> $RUST/core/src/error.rs
17-
|
18-
| pub trait Error: Debug + Display {
19-
| ^^^^^^^ required by this bound in `Error`

tests/ui/from-not-source.stderr

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,3 @@ error: #[from] is only supported on the source field, not any other field
33
|
44
7 | #[from]
55
| ^^^^^^^
6-
7-
error[E0277]: `Error` doesn't implement `std::fmt::Display`
8-
--> tests/ui/from-not-source.rs:4:12
9-
|
10-
4 | pub struct Error {
11-
| ^^^^^ `Error` cannot be formatted with the default formatter
12-
|
13-
= help: the trait `std::fmt::Display` is not implemented for `Error`
14-
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
15-
note: required by a bound in `std::error::Error`
16-
--> $RUST/core/src/error.rs
17-
|
18-
| pub trait Error: Debug + Display {
19-
| ^^^^^^^ required by this bound in `Error`

tests/ui/invalid-input-impl-anyway.stderr

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,3 @@ error: expected attribute arguments in parentheses: #[error(...)]
33
|
44
4 | #[error]
55
| ^^^^^
6-
7-
error[E0277]: `MyError` doesn't implement `std::fmt::Display`
8-
--> tests/ui/invalid-input-impl-anyway.rs:5:12
9-
|
10-
5 | pub struct MyError;
11-
| ^^^^^^^ `MyError` cannot be formatted with the default formatter
12-
|
13-
= help: the trait `std::fmt::Display` is not implemented for `MyError`
14-
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
15-
note: required by a bound in `std::error::Error`
16-
--> $RUST/core/src/error.rs
17-
|
18-
| pub trait Error: Debug + Display {
19-
| ^^^^^^^ required by this bound in `Error`

0 commit comments

Comments
 (0)