min_specialization with const traits can call non-const function in consteval
Open
@fee1-dead is already working on this.
Since Jul 22, 2026.
A-const-eval
A-specialization
C-bug
F-const_trait_impl
F-min_specialization
PG-const-traits
T-types
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Edit: See the comment below for a simpler version.
#![feature(min_specialization, const_trait_impl)]
struct Dummy;
const trait One {
fn one();
}
impl One for Dummy {
fn one() {
println!("wut");
}
}
const trait Two {
fn two();
}
impl<T: One, U> const Two for (T, U) {
default fn two() {
unreachable!();
}
}
impl<T: [const] One> const Two for (T, i32) {
fn two() {
T::one();
}
}
const trait Three {
fn three();
}
impl<T: One, U> const Three for (T, U) {
fn three() {
<(T, U)>::two();
}
}
const A: () = {
<(Dummy, i32)>::three();
};
fn main() {}
error[E0080]: calling non-const function `<Dummy as One>::one`
--> src/main.rs:38:5
|
38 | <(Dummy, i32)>::three();
| ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `A` failed inside this call
|
note: inside `<(Dummy, i32) as Three>::three`
--> src/main.rs:33:9
|
33 | <(T, U)>::two();
| ^^^^^^^^^^^^^^^
note: inside `<(Dummy, i32) as Two>::two`
--> src/main.rs:24:9
|
24 | T::one();
| ^^^^^^^^ the failure occurred here
For more information about this error, try `rustc --explain E0080`.
This code manages to get through const checking without any errors, and only produces an error while "executing" consteval and running into the non-const function. This seems incorrect. The compiler is supposed to disallow calling non-const functions in consteval before actually running consteval.
Meta
Reproducible on the playground with version 1.93.0-nightly (2025-10-27 adaa838976ff99a4f066)
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.
Assessment
This issue has not been assessed yet.