-
-
Notifications
You must be signed in to change notification settings - Fork 17.7k
HRTB with GAT behaving differently in associated type bound vs where clause #90573
Copy link
Copy link
Open
Labels
A-GATsArea: Generic associated types (GATs)Area: Generic associated types (GATs)A-higher-rankedArea: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)Area: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Activity
Metadata
Metadata
Assignees
Labels
A-GATsArea: Generic associated types (GATs)Area: Generic associated types (GATs)A-higher-rankedArea: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)Area: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
I tried this code:
(Playground.)
I expected to see this happen: I had expected compilation to succeed.
Instead, this happened: Compilation fails with the error message below.
Error message
Everything seems to work fine if instead I provide the HRTB on an associated type instead, like so:
I was surprised by this difference, so I initially opened a question about this on the rust-lang users forum. There, people more knowledgeable than I suggested that this might be a GAT-related bug, with some uncertainty as to whether this is the same issue as in #89196.
Meta
rustc --version --verbose: