rust-lang / rust-lang/rust

Nonsensical "trait bound is not satisfied" error on trait method definition

Open
#161,621 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-dyn-trait A-trait-system C-bug I-prioritize regression-from-stable-to-stable T-types WG-trait-system-refactor
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

I tried this code:

use std::ops::Deref;

// Imagine mapping ((T, U), V) to fn(T, U) -> V
trait SignatureToFnPtr {
    type Ptr;
}

trait DerefsToFn<Args>
where
    (Args, Self::Output): SignatureToFnPtr,
    Self: Deref<Target = <(Args, Self::Output) as SignatureToFnPtr>::Ptr>,
{
    type Output;
    fn method(&self);
}

I expected to see this happen: the code compiles correctly.

Instead, this happened:

error[E0277]: the trait bound `(Args, <RustaceansAreAwesome as DerefsToFn<Args>>::Output): SignatureToFnPtr` is not satisfied
  --> src/lib.rs:14:5
   |
14 |     fn method(&self);
   |     ^^^^^^^^^^^^^^^^^ the trait `SignatureToFnPtr` is not implemented for `(Args, <RustaceansAreAwesome as DerefsToFn<Args>>::Output)`
  1. RustaceansAreAwesome look like an implementation detail that shouldn't have leaked.
  2. (Args, Self::Output): SignatureToFnPtr should follow from the where bound on the trait definition.
  3. The error is not shown if fn method(&self) is replaced with fn method(self).

This looks like two different regressions in the two trait solvers. I bisected the old solver regression to #138174, @jnkel bisected the next solver regression to #156976. Tentatively marking as regression-from-stable-to-stable, but it's old enough that this might not be useful (the last version where this worked by default is nightly-2025-03-12)...

Meta

rustc --version --verbose:

rustc 1.100.0-nightly (f7d782a3b 2026-08-19)
binary: rustc
commit-hash: f7d782a3be46d6bb4b9792fe69a61db389ba1769
commit-date: 2026-08-19
host: x86_64-unknown-linux-gnu
release: 1.100.0-nightly
LLVM version: 23.1.0

@rustbot label +A-trait-system +T-compiler +regression-from-stable-to-stable

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 running the supplied Rust reproduction with the reported nightly version and compare behavior with the last working nightly. Read the trait-system regressions identified in #138174 and #156976 to understand the solver differences. Done means the reproduction no longer emits the leaked implementation detail or incorrect unsatisfied-bound error, while preserving the intended reference-receiver 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
Active
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.