-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Closed
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsAsyncAwait-PolishAsync-await issues that are part of the "polish" areaAsync-await issues that are part of the "polish" areaAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.fixed-by-NLLBugs fixed, but only when NLL is enabled.Bugs fixed, but only when NLL is enabled.
Description
struct Struct { }
impl Struct {
async fn async_fn(self: &Struct, f: &u32) -> &u32 {
f
}
fn sync_fn(self: &Struct, f: &u32) -> &u32 {
f
}
}Output (playground)
Compiling playground v0.0.1 (/playground)
error[E0623]: lifetime mismatch
--> src/main.rs:5:9
|
4 | async fn async_fn(self: &Struct, f: &u32) -> &u32 {
| ------- ----
| |
| this parameter and the return type are declared with different lifetimes...
5 | f
| ^ ...but data from `f` is returned here
error[E0623]: lifetime mismatch
--> src/main.rs:9:9
|
8 | fn sync_fn(self: &Struct, f: &u32) -> &u32 {
| ---- ----
| |
| this parameter and the return type are declared with different lifetimes...
9 | f
| ^ ...but data from `f` is returned here
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0623`.
error: could not compile `playground`.
To learn more, run the command again with --verbose.
The error in sync_fn is correct, but the one for async_fn incorrectly claims the return type lifetime is different from self's lifetime, when they are in fact the same per the elision rules.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsAsyncAwait-PolishAsync-await issues that are part of the "polish" areaAsync-await issues that are part of the "polish" areaAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.fixed-by-NLLBugs fixed, but only when NLL is enabled.Bugs fixed, but only when NLL is enabled.
Type
Projects
Status
Done