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

Bad suggestion when encountering type Foo<T> in trait #84439

Closed
estebank opened this issue Apr 22, 2021 · 3 comments
Closed

Bad suggestion when encountering type Foo<T> in trait #84439

estebank opened this issue Apr 22, 2021 · 3 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-GATs Area: Generic associated types (GATs) A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` 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

@estebank
Copy link
Contributor

estebank commented Apr 22, 2021

Incorrect suggestion:

error[E0658]: generic associated types are unstable
 --> src/lib.rs:2:5
  |
2 |     type Member<T>;
  |     ^^^^^^^^^^^^^^^
  |
  = note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information

error[E0107]: missing generics for associated type `CollectionFamily::Member`
 --> src/lib.rs:2:10
  |
2 |     type Member<T>;
  |          ^^^^^^ expected 1 type argument
  |
note: associated type defined here, with 1 type parameter: `T`
 --> src/lib.rs:2:10
  |
2 |     type Member<T>;
  |          ^^^^^^ -
help: use angle brackets to add missing type argument
  |
2 |     type Member<T><T>;
  |                ^^^

We need to correctly track the span for the obligation to suggest somewhat reasonable code.

Taken from #78671

@estebank estebank added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. labels Apr 22, 2021
@ABouttefeux
Copy link
Contributor

@rustbot claim

@jackh726
Copy link
Member

I'm pretty sure this is just a duplicate of #81801

@jackh726 jackh726 added the F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs label Apr 22, 2021
@jackh726
Copy link
Member

Well, it actually literally is except this uses a type instead of a lifetime. Fixed by #82272. I'm going to go ahead and close this.

@ABouttefeux ABouttefeux removed their assignment Apr 22, 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-diagnostics Area: Messages for errors, warnings, and lints A-GATs Area: Generic associated types (GATs) A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` 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

No branches or pull requests

4 participants