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

GAT: incorrect suggestion on missing lifetime #81961

Closed
lcnr opened this issue Feb 10, 2021 · 0 comments · Fixed by #82272
Closed

GAT: incorrect suggestion on missing lifetime #81961

lcnr opened this issue Feb 10, 2021 · 0 comments · Fixed by #82272
Labels
A-associated-items Area: Associated items (types, constants & functions) A-const-generics Area: const generics (parameters and arguments) A-GATs Area: Generic associated types (GATs) C-bug Category: This is a bug. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@lcnr
Copy link
Contributor

lcnr commented Feb 10, 2021

#![feature(generic_associated_types)]
trait Foo {
    type Assoc<'a, const N: usize>;
}

fn foo<T: Foo>() {
    let _: <T as Foo>::Assoc<3>;
}

results in the following error:

error[E0107]: this associated type takes 1 lifetime argument but 0 lifetime arguments were supplied
 --> src/lib.rs:7:24
  |
7 |     let _: <T as Foo>::Assoc<3>;
  |                        ^^^^^ expected 1 lifetime argument
  |
note: associated type defined here, with 1 lifetime parameter: `'a`
 --> src/lib.rs:3:10
  |
3 |     type Assoc<'a, const N: usize>;
  |          ^^^^^ --
help: add missing lifetime argument
  |
7 |     let _: <T as Foo>::Assoc<'a3>;
  |                              ^^

Note that we suggest <T as Foo>::Assoc<'a3> here, which is missing a comma.

@lcnr lcnr added C-bug Category: This is a bug. F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. labels Feb 10, 2021
@estebank estebank added A-associated-items Area: Associated items (types, constants & functions) A-const-generics Area: const generics (parameters and arguments) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 10, 2021
@bors bors closed this as completed in ba8d7e2 May 11, 2021
@fmease fmease added the A-GATs Area: Generic associated types (GATs) label Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items (types, constants & functions) A-const-generics Area: const generics (parameters and arguments) A-GATs Area: Generic associated types (GATs) C-bug Category: This is a bug. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants