"conflicting associated type bounds when expanding trait alias", but there is no actual conflict
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code:
#![feature(trait_alias)]
trait Foo {
type Assoc;
}
trait Alias = Foo<Assoc = fn(&())>;
type Dyn = dyn Alias<Assoc = fn(&())>;
I expected to see this happen: It compiles, just as it would if fn(&()) were replaced with i32
Instead, this happened:
error: conflicting associated type bounds for `Assoc` when expanding trait alias
--> src/lib.rs:9:12
|
7 | trait Alias = Foo<Assoc = fn(&())>;
| --------------- `Assoc` is specified to be `for<'a> fn(&'a ())` here
8 |
9 | type Dyn = dyn Alias<Assoc = fn(&())>;
| ^^^^^^^^^^---------------^
| |
| `Assoc` is specified to be `for<'a> fn(&'a ())` here
AIUI this is a consequence of https://github.com/rust-lang/rust/pull/136458?
@rustbot label T-types F-trait_alias A-dyn-trait A-associated-items requires-nightly
Meta
rustc --version --verbose:
rustc 1.91.0-nightly (02c7b1a7a 2025-09-13)
binary: rustc
commit-hash: 02c7b1a7ac1d739663878030510508372e46f254
commit-date: 2025-09-13
host: x86_64-unknown-linux-gnu
release: 1.91.0-nightly
LLVM version: 21.1.1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the report from the minimal example in src/lib.rs using the nightly compiler version shown, then compare the fn(&()) case with the working i32 variant. Trace how the trait alias and dyn Alias associated type bounds are expanded; done means the fn(&()) example compiles without the spurious conflicting-bounds error.
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
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100