Closed
Description
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.
Metadata
Metadata
Assignees
Labels
Area: Async & AwaitArea: Messages for errors, warnings, and lintsArea: Suggestions generated by the compiler applied by `cargo fix`Async-await issues that have been triaged during a working group meeting.Category: An issue proposing an enhancement or a PR with one.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Projects
Status
Done