Repository navigation
Nonsensical "trait bound is not satisfied" error on trait method definition #161621
Copy link
Copy link
Closed
Closed
Copy link
Labels
A-dyn-traitArea: trait objects, vtable layoutArea: trait objects, vtable layoutA-trait-systemArea: Trait systemArea: Trait systemC-bugCategory: This is a bug.Category: This is a bug.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)The Rustc Trait System Refactor Initiative (-Znext-solver)regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
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)`
RustaceansAreAwesomelook like an implementation detail that shouldn't have leaked.(Args, Self::Output): SignatureToFnPtrshould follow from thewherebound on the trait definition.- The error is not shown if
fn method(&self)is replaced withfn 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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-dyn-traitArea: trait objects, vtable layoutArea: trait objects, vtable layoutA-trait-systemArea: Trait systemArea: Trait systemC-bugCategory: This is a bug.Category: This is a bug.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)The Rustc Trait System Refactor Initiative (-Znext-solver)regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Activity
purplesyringa commentedon Aug 23, 2026
@rustbot label +A-dyn-trait
Since this looks related to dynamic dispatch (thanks @jnkel)
teor2345 commentedon Sep 21, 2026
The
RustaceansAreAwesomeis a synthetic type parameter which comes from here:rust/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs
Line 686 in d287eb7
Separately from fixing this bug, it would be useful to rename it to something that better reflects its purpose, for example,
DispachCheckPlaceholder.HaineSensei commentedon Sep 21, 2026
I found this while working on my own project, and was directed here from this zulip conversation:
and got the same sort of error:
Have reduced it a bit further than what I had in the Zulip chat: the method no longer references
A::Pointor evenA.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 +nightly --version --verbose:Rollup merge of rust-lang#163200 - dianne:dyn-satisfies-bounds, r=oli…
Rollup merge of rust-lang#163200 - dianne:dyn-satisfies-bounds, r=oli…
Rollup merge of rust-lang#163200 - dianne:dyn-satisfies-bounds, r=oli…
Rollup merge of rust-lang#163200 - dianne:dyn-satisfies-bounds, r=oli…
Unrolled build for #163200 in rollup 163472
Rollup merge of #163200 - dianne:dyn-satisfies-bounds, r=oli-obk
Rollup merge of rust-lang#163958 - dianne:fix-rustaceansareawesome-ta…
Rollup merge of rust-lang#163958 - dianne:fix-rustaceansareawesome-ta…
Rollup merge of rust-lang#163958 - dianne:fix-rustaceansareawesome-ta…
Rollup merge of rust-lang#163958 - dianne:fix-rustaceansareawesome-ta…
Unrolled build for #163958 in rollup 164005
Rollup merge of #163958 - dianne:fix-rustaceansareawesome-take-2-part…