rust-lang / rust-lang/rust

Associated Type bound in GAT Parameter incorrectly errors as unsatisfied

Open
#144,127 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I tried this code:

trait TypeFn<T> {
    type Output;
}
trait Boo {
    type Arg;
    type CallCopy<F: TypeFn<Self::Arg, Output: Copy>>;
}
impl Boo for () {
    type Arg = ();
    type CallCopy<F: TypeFn<Self::Arg, Output: Copy>> = F;
}

I expected to see this happen: The code compiles.

Instead, this happened: The code errored with

error[E0277]: the trait bound `F: TypeFn<()>` is not satisfied
  --> error.rs:10:5
   |
10 |     type CallCopy<F: TypeFn<Self::Arg, Output: Copy>> = F;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `TypeFn<()>` is not implemented for `F`

error[E0276]: impl has stricter requirements than trait
  --> error.rs:10:22
   |
6  |     type CallCopy<F: TypeFn<Self::Arg, Output: Copy>>;
   |     ------------------------------------------------- definition of `CallCopy` from trait
...
10 |     type CallCopy<F: TypeFn<Self::Arg, Output: Copy>> = F;
   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `F: TypeFn<()>`

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0276, E0277.
For more information about an error, try `rustc --explain E0276`.
Meta

rustc --version --verbose:

rustc 1.88.0 (6b00bc388 2025-06-23)
binary: rustc
commit-hash: 6b00bc3880198600130e1cf62b8f8a93494488cc
commit-date: 2025-06-23
host: x86_64-unknown-linux-gnu
release: 1.88.0
LLVM version: 20.1.5

The error persists on nightly:

rustc 1.90.0-nightly (e46629662 2025-07-17)
binary: rustc
commit-hash: e4662966273ed58b51f9ff8d682accc202aa1210
commit-date: 2025-07-17
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.8

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 by compiling the minimal Rust example in the issue on the reported stable and nightly versions, then investigate the compiler path handling GAT parameter bounds and associated-type Output: Copy constraints. Done means the example no longer emits E0277 or E0276 and a regression test covers the accepted bound behavior.

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.