Skip to content

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

Closed

Description

@purplesyringa

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

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Aug 23, 2026
  2. purplesyringa commented on Aug 23, 2026

    @purplesyringa
    ContributorAuthor

    @rustbot label +A-dyn-trait

    Since this looks related to dynamic dispatch (thanks @jnkel)

  3. added
    T-typesRelevant to the types team, which will review and decide on the PR/issue.
    and removed
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Aug 24, 2026
  4. teor2345 commented on Sep 21, 2026

    @teor2345
    Member

    The RustaceansAreAwesome is a synthetic type parameter which comes from here:

    Ty::new_param(tcx, u32::MAX, rustc_span::sym::RustaceansAreAwesome);

    Separately from fixing this bug, it would be useful to rename it to something that better reflects its purpose, for example, DispachCheckPlaceholder.

  5. HaineSensei commented on Sep 21, 2026

    @HaineSensei

    I found this while working on my own project, and was directed here from this zulip conversation:

    trait Associator<S: ?Sized> {
        type Point;
    }
    
    trait Marker<T> {}
    
    trait Trait<A: Associator<Self> + ?Sized>: Marker<A::Point> {
        fn method(&self);
    }

    and got the same sort of error:

    error[E0277]: the trait bound `A: Associator<RustaceansAreAwesome>` is not satisfied
     --> repro.rs:8:5
      |
    8 |     fn method(&self);
      |     ^^^^^^^^^^^^^^^^^ the trait `Associator<RustaceansAreAwesome>` is not implemented for `A`
    

    Have reduced it a bit further than what I had in the Zulip chat: the method no longer references A::Point or even A.

    Looks like almost exactly the same situation as @purplesyringa's but with the supertrait replacing the where bound.

    A link to a playground with this behaviour:
    https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=8c1d408647e11a102db507b5a1a34b1c

    Meta

    rustc --version --verbose:

    rustc 1.98.1 (48a229cea 2026-09-01)
    binary: rustc
    commit-hash: 48a229ceaefd4985c50990b14116b6d856af0985
    commit-date: 2026-09-01
    host: x86_64-unknown-linux-gnu
    release: 1.98.1
    LLVM version: 22.1.8
    

    rustc +nightly --version --verbose:

    rustc 1.100.0-nightly (923c95cdf 2026-09-16)
    binary: rustc
    commit-hash: 923c95cdf5ba65cea505aa2ea829f578e1506ed8
    commit-date: 2026-09-16
    host: x86_64-unknown-linux-gnu
    release: 1.100.0-nightly
    LLVM version: 23.1.1
    
  6. self-assigned this
    on Sep 23, 2026
  7. added 4 commits that reference this issue on Sep 28, 2026
  8. added a commit that references this issue on Sep 29, 2026
  9. removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Sep 29, 2026
  10. added 4 commits that reference this issue on Oct 8, 2026
  11. added a commit that references this issue on Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-dyn-traitArea: trait objects, vtable layoutA-trait-systemArea: Trait systemC-bugCategory: This is a bug.T-typesRelevant to the types team, which will review and decide on the PR/issue.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions