Open
Description
I tried this code:
trait GAT {
type Assoc<'a>;
}
fn foo<A: GAT>(
f: impl for<'a> FnOnce(<A as GAT>::Assoc<'a>) -> <A as GAT>::Assoc<'a>,
) {}
And it fails to compile:
error[[E0582]](https://doc.rust-lang.org/stable/error-index.html#E0582): binding for associated type `Output` references lifetime `'a`, which does not appear in the trait input types
--> src/lib.rs:7:54
|
7 | f: impl for<'a> FnOnce(<A as GAT>::Assoc<'a>) -> <A as GAT>::Assoc<'a>,
| ^^^^^^^^^^^^^^^^^^^^^
For more information about this error, try `rustc --explain E0582`.
Even if it's not a bug, but the current type system limitations, the error description E0582 seems to be misleading(or is not well descriptive).
Meta
Checked with rustc:
- 1.67.0
- 1.68.0-beta.1
- 2023-01-30 001a77f
Metadata
Metadata
Assignees
Labels
Area: Generic associated types (GATs)Area: Associated items (types, constants & functions)Area: Messages for errors, warnings, and lintsArea: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)Area: Lifetimes / regionsDiagnostics: Confusing error or lint that should be reworked.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.Relevant to the compiler team, which will review and decide on the PR/issue.