rust-lang / rust-lang/rust

"conflicting associated type bounds when expanding trait alias", but there is no actual conflict

Open
#146,548 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-associated-items A-dyn-trait A-higher-ranked A-HIR-ty-lowering C-bug F-trait_alias T-types
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

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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.