rust-lang / rust-lang/rust

Unable to see through associated type with where clause on GAT

Open
#122,745 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-associated-items A-GATs A-trait-system C-bug fixed-by-next-solver T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Ran into an issue when using GATs with a where clause. I wasn't able to find an existing issue, although I swear I've seen something similar reported before - apologies if this is a duplicate.

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=84875b21dcdc81ddc2e1526c2e9b6cc5

It looks like the Self::Output type isn't realized early enough? Ran with latest stable and nightly. This does work with the next trait solver. I feel like this can be reduced further, but I was unable to do so.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Rust Playground reproduction and compare its behavior on stable and nightly, then investigate the next trait solver result noted in the report. The issue is resolved when the GAT with a where clause can realize the Self::Output associated type without requiring the next trait solver.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.