Add ui test of Generic<&'a str> source
This commit is contained in:
parent
0859205018
commit
d30890b4f7
|
@ -1,3 +1,4 @@
|
|||
use std::fmt::Debug;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
|
@ -8,6 +9,16 @@ struct Error<'a>(#[from] Inner<'a>);
|
|||
#[error("{0}")]
|
||||
struct Inner<'a>(&'a str);
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
enum Enum<'a> {
|
||||
#[error("error")]
|
||||
Foo(#[from] Generic<&'a str>),
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("{0:?}")]
|
||||
struct Generic<T: Debug>(T);
|
||||
|
||||
fn main() -> Result<(), Error<'static>> {
|
||||
Err(Error(Inner("some text")))
|
||||
}
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
error: non-static lifetimes are not allowed in the source of an error, because std::error::Error requires the source is dyn Error + 'static
|
||||
--> $DIR/lifetime.rs:5:26
|
||||
--> $DIR/lifetime.rs:6:26
|
||||
|
|
||||
5 | struct Error<'a>(#[from] Inner<'a>);
|
||||
6 | struct Error<'a>(#[from] Inner<'a>);
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: non-static lifetimes are not allowed in the source of an error, because std::error::Error requires the source is dyn Error + 'static
|
||||
--> $DIR/lifetime.rs:15:17
|
||||
|
|
||||
15 | Foo(#[from] Generic<&'a str>),
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
Loading…
Reference in New Issue