Rustc fails to infer appropriately general Fn*
trait implementation in the face of complex HRTBs with GATs
#99991
Labels
A-closures
Area: Closures (`|…| { … }`)
A-GATs
Area: Generic associated types (GATs)
A-higher-ranked
Area: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)
A-lifetimes
Area: Lifetimes / regions
C-bug
Category: This is a bug.
T-types
Relevant to the types team, which will review and decide on the PR/issue.
I tried this code:
I expected to see this happen: Code compiles without errors.
Instead, this happened:
Playground
The compiler needs closures to be explicitly coerced into a general enough type for the provided trait bounds to work. It's not the end of the world, because I can always use trait objects, but it's definitely an ergonomic issue. Also, it works just fine if you use a non-generic associated type.
Meta
Playground version:
The text was updated successfully, but these errors were encountered: