Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message for "return type cannot contain a projection or Self..." #69276

Closed
tmandry opened this issue Feb 19, 2020 · 1 comment · Fixed by #72260
Closed

Improve error message for "return type cannot contain a projection or Self..." #69276

tmandry opened this issue Feb 19, 2020 · 1 comment · Fixed by #72260
Assignees
Labels
A-async-await Area: Async & Await A-diagnostics Area: Messages for errors, warnings, and lints AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. C-enhancement Category: An issue proposing an enhancement or a PR with one. D-papercut Diagnostics: An error or lint that needs small tweaks. D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@tmandry
Copy link
Member

tmandry commented Feb 19, 2020

Example (playground):

error: `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 {
  |                                 ^^^^
@tmandry tmandry added A-async-await Area: Async & Await A-diagnostics Area: Messages for errors, warnings, and lints AsyncAwait-OnDeck AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. D-papercut Diagnostics: An error or lint that needs small tweaks. D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. labels Feb 19, 2020
@jonas-schievink jonas-schievink added C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 19, 2020
@kornelski
Copy link
Contributor

I've ran into this case, which doesn't have a good diagnostic either:

struct Foo<'a>(&'a ());

impl<'a> Foo<'a> {
    async fn named(arg: &'a ()) -> Foo<'a> {
        Self(arg)
    }
    
    async fn selfie(arg: &'a ()) -> Self {
        Self(arg)
    }
}

@tmandry tmandry added the P-medium Medium priority label Mar 3, 2020
@csmoe csmoe self-assigned this May 11, 2020
RalfJung added a commit to RalfJung/rust that referenced this issue May 21, 2020
Spell out `Self` in async function return

Closes rust-lang#69276
r? @tmandry
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Jun 5, 2020
Spell out `Self` in async function return

Closes rust-lang#69276
r? @tmandry
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Jun 5, 2020
Spell out `Self` in async function return

Closes rust-lang#69276
r? @tmandry
@bors bors closed this as completed in 14dc34d Jun 5, 2020
@tmandry tmandry moved this to Done in wg-async work Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-async-await Area: Async & Await A-diagnostics Area: Messages for errors, warnings, and lints AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. C-enhancement Category: An issue proposing an enhancement or a PR with one. D-papercut Diagnostics: An error or lint that needs small tweaks. D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants