Skip to content

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-dyn-traitArea: trait objects, vtable layoutA-trait-systemArea: Trait systemC-bugCategory: This is a bug.I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}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