Skip to content

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

@Jules-Bertholet

Description

@Jules-Bertholet

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 #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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-associated-itemsArea: Associated items (types, constants & functions)A-dyn-traitArea: trait objects, vtable layoutC-bugCategory: This is a bug.F-trait_alias`#![feature(trait_alias)]`T-typesRelevant to the types team, which will review and decide on the PR/issue.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions