cannot specialize const trait impl with non-const
Open
Nobody has claimed this yet.
C-bug
F-const_trait_impl
F-min_specialization
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
#![feature(const_trait_impl, min_specialization)]
#[allow(dead_code)]
const 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
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
Start by compiling the provided minimal reproduction with rustc 1.92.0-nightly and compare the const and non-const implementations. Trace the compiler's overlap check for const trait implementations; done means determining whether the conflict is intentional or correcting the behavior to allow the expected specialization.
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
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100