GAT in path suggests wrong lifetime name when elided lifetime is rejected #103815
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-GATs
Area: Generic associated types (GATs)
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.
Usage of GATs must specify lifetime generic parameters even if they can be inferred, unlike structs and type aliases. Personally, I think this is the wrong choice, though I recognize the linting folks disagree. In any case, the diagnostic output for when
'_
is necessary isn't tested in enough scenarios.Given the following code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=dec1ee3c77e71e10d6217f53ebb0f86f
The current output is:
Ideally the output should look like:
The only difference here is that it suggests using
'_
before suggesting it use the lifetime parameter declared in the type definition. It really shouldn't consider any of the generic params in the GAT definition. Note that if I replace it withfn my_index<'b>(&'b self, n: usize) -> Self::Output
orfn my_index<'b>(&self, n: usize) -> Self::Output
, it suggests using'b
, as expected.The text was updated successfully, but these errors were encountered: