-
-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #258 from de-vri-es/as-dyn-error-span
Change span of `as_dyn_error()` to point compile error at attribute.
- Loading branch information
Showing
14 changed files
with
209 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use thiserror::Error; | ||
|
||
#[derive(Debug)] | ||
pub struct NotError; | ||
|
||
#[derive(Error, Debug)] | ||
#[error("...")] | ||
pub enum ErrorEnum { | ||
Broken(#[source] NotError), | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
error[E0599]: the method `as_dyn_error` exists for reference `&NotError`, but its trait bounds were not satisfied | ||
--> tests/ui/source-enum-unnamed-field-not-error.rs:9:14 | ||
| | ||
4 | pub struct NotError; | ||
| ------------------- | ||
| | | ||
| doesn't satisfy `NotError: AsDynError<'_>` | ||
| doesn't satisfy `NotError: std::error::Error` | ||
... | ||
9 | Broken(#[source] NotError), | ||
| ^^^^^^ method cannot be called on `&NotError` due to unsatisfied trait bounds | ||
| | ||
= note: the following trait bounds were not satisfied: | ||
`NotError: std::error::Error` | ||
which is required by `NotError: AsDynError<'_>` | ||
`&NotError: std::error::Error` | ||
which is required by `&NotError: AsDynError<'_>` | ||
note: the trait `std::error::Error` must be implemented | ||
--> $RUST/core/src/error.rs | ||
| | ||
| pub trait Error: Debug + Display { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use thiserror::Error; | ||
|
||
#[derive(Debug)] | ||
struct NotError; | ||
|
||
#[derive(Error, Debug)] | ||
#[error("...")] | ||
pub struct ErrorStruct(#[source] NotError); | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
error[E0599]: the method `as_dyn_error` exists for struct `NotError`, but its trait bounds were not satisfied | ||
--> tests/ui/source-struct-unnamed-field-not-error.rs:8:26 | ||
| | ||
4 | struct NotError; | ||
| --------------- | ||
| | | ||
| method `as_dyn_error` not found for this struct | ||
| doesn't satisfy `NotError: AsDynError<'_>` | ||
| doesn't satisfy `NotError: std::error::Error` | ||
... | ||
8 | pub struct ErrorStruct(#[source] NotError); | ||
| ^^^^^^ method cannot be called on `NotError` due to unsatisfied trait bounds | ||
| | ||
= note: the following trait bounds were not satisfied: | ||
`NotError: std::error::Error` | ||
which is required by `NotError: AsDynError<'_>` | ||
note: the trait `std::error::Error` must be implemented | ||
--> $RUST/core/src/error.rs | ||
| | ||
| pub trait Error: Debug + Display { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
use thiserror::Error; | ||
|
||
#[derive(Error, Debug)] | ||
pub enum Error { | ||
#[error(transparent)] | ||
Other { | ||
message: String, | ||
} | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
error[E0599]: the method `as_dyn_error` exists for reference `&String`, but its trait bounds were not satisfied | ||
--> tests/ui/transparent-enum-not-error.rs:5:13 | ||
| | ||
5 | #[error(transparent)] | ||
| ^^^^^^^^^^^ method cannot be called on `&String` due to unsatisfied trait bounds | ||
| | ||
::: $RUST/alloc/src/string.rs | ||
| | ||
| pub struct String { | ||
| ----------------- | ||
| | | ||
| doesn't satisfy `String: AsDynError<'_>` | ||
| doesn't satisfy `String: std::error::Error` | ||
| | ||
= note: the following trait bounds were not satisfied: | ||
`String: std::error::Error` | ||
which is required by `String: AsDynError<'_>` | ||
`&String: std::error::Error` | ||
which is required by `&String: AsDynError<'_>` | ||
`str: Sized` | ||
which is required by `str: AsDynError<'_>` | ||
`str: std::error::Error` | ||
which is required by `str: AsDynError<'_>` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use thiserror::Error; | ||
|
||
#[derive(Error, Debug)] | ||
pub enum Error { | ||
#[error(transparent)] | ||
Other(String), | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
error[E0599]: the method `as_dyn_error` exists for reference `&String`, but its trait bounds were not satisfied | ||
--> tests/ui/transparent-enum-unnamed-field-not-error.rs:5:13 | ||
| | ||
5 | #[error(transparent)] | ||
| ^^^^^^^^^^^ method cannot be called on `&String` due to unsatisfied trait bounds | ||
| | ||
::: $RUST/alloc/src/string.rs | ||
| | ||
| pub struct String { | ||
| ----------------- | ||
| | | ||
| doesn't satisfy `String: AsDynError<'_>` | ||
| doesn't satisfy `String: std::error::Error` | ||
| | ||
= note: the following trait bounds were not satisfied: | ||
`String: std::error::Error` | ||
which is required by `String: AsDynError<'_>` | ||
`&String: std::error::Error` | ||
which is required by `&String: AsDynError<'_>` | ||
`str: Sized` | ||
which is required by `str: AsDynError<'_>` | ||
`str: std::error::Error` | ||
which is required by `str: AsDynError<'_>` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use thiserror::Error; | ||
|
||
#[derive(Error, Debug)] | ||
#[error(transparent)] | ||
pub struct Error { | ||
message: String, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
error[E0599]: the method `as_dyn_error` exists for struct `String`, but its trait bounds were not satisfied | ||
--> tests/ui/transparent-struct-not-error.rs:4:9 | ||
| | ||
4 | #[error(transparent)] | ||
| ^^^^^^^^^^^ method cannot be called on `String` due to unsatisfied trait bounds | ||
| | ||
::: $RUST/alloc/src/string.rs | ||
| | ||
| pub struct String { | ||
| ----------------- | ||
| | | ||
| doesn't satisfy `String: AsDynError<'_>` | ||
| doesn't satisfy `String: std::error::Error` | ||
| | ||
= note: the following trait bounds were not satisfied: | ||
`String: std::error::Error` | ||
which is required by `String: AsDynError<'_>` | ||
`str: Sized` | ||
which is required by `str: AsDynError<'_>` | ||
`str: std::error::Error` | ||
which is required by `str: AsDynError<'_>` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
use thiserror::Error; | ||
|
||
#[derive(Error, Debug)] | ||
#[error(transparent)] | ||
pub struct Error(String); | ||
|
||
fn main() {} |
21 changes: 21 additions & 0 deletions
21
tests/ui/transparent-struct-unnamed-field-not-error.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
error[E0599]: the method `as_dyn_error` exists for struct `String`, but its trait bounds were not satisfied | ||
--> tests/ui/transparent-struct-unnamed-field-not-error.rs:4:9 | ||
| | ||
4 | #[error(transparent)] | ||
| ^^^^^^^^^^^ method cannot be called on `String` due to unsatisfied trait bounds | ||
| | ||
::: $RUST/alloc/src/string.rs | ||
| | ||
| pub struct String { | ||
| ----------------- | ||
| | | ||
| doesn't satisfy `String: AsDynError<'_>` | ||
| doesn't satisfy `String: std::error::Error` | ||
| | ||
= note: the following trait bounds were not satisfied: | ||
`String: std::error::Error` | ||
which is required by `String: AsDynError<'_>` | ||
`str: Sized` | ||
which is required by `str: AsDynError<'_>` | ||
`str: std::error::Error` | ||
which is required by `str: AsDynError<'_>` |