Skip to content

cannot specialize const trait impl with non-const #147130

@Hezuikn-2

Description

@Hezuikn-2
#![feature(const_trait_impl, min_specialization)]

#[allow(dead_code)]
#[const_trait]
trait Trait {
    fn item();
}

impl<T> const Trait for T {
    default fn item() {}
}

// works when adding const here too
impl Trait for () {
    fn item() {}
}

fn main() {}
error[E0119]: conflicting implementations of trait `Trait` for type `()`
  --> conflict.rs:14:1
   |
 9 | impl<T> const Trait for T {
   | ------------------------- first implementation here
...
14 | impl Trait for () {
   | ^^^^^^^^^^^^^^^^^ conflicting implementation for `()`

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0119`.
rustc 1.92.0-nightly (4082d6a3f 2025-09-27)

i would like to expect this to work it may however be intentional behaviour

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-const_trait_impl`#![feature(const_trait_impl)]`F-min_specialization`#![feature(min_specialization)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions