Following the improvement for the diagnostic of the error reported in this issue #69276, it would be nice (depending on how #61949 is prioritized) to have the same error message when instead of returning Self the function returns Result<Self, Error>.
When Self is returned I get a nice error message (on rustc 1.47):
struct S<'a>(&'a i32);
impl<'a> S<'a> {
async fn new(i: &'a i32) -> Self {
S(&22)
}
}
error[E0760]: `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope
--> src/lib.rs:4:33
|
4 | async fn new(i: &'a i32) -> Self {
| ^^^^ help: consider spelling out the type instead: `S<'a>`
But if Result<Self, Error> is used I get:
struct S<'a>(&'a i32);
impl<'a> S<'a> {
async fn new(i: &'a i32) -> Result<Self, ()> {
Ok(S(&22))
}
}
error[E0760]: `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope
--> src/lib.rs:4:33
|
4 | async fn new(i: &'a i32) -> Result<Self, ()> {
| ^^^^^^^^^^^^^^^^
with no suggestion to spell the type.
Link to Playground
Following the improvement for the diagnostic of the error reported in this issue #69276, it would be nice (depending on how #61949 is prioritized) to have the same error message when instead of returning
Selfthe function returnsResult<Self, Error>.When
Selfis returned I get a nice error message (on rustc 1.47):But if
Result<Self, Error>is used I get:with no suggestion to spell the type.
Link to Playground