-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Open
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)A-specializationArea: Trait impl specializationArea: Trait impl specializationC-bugCategory: This is a bug.Category: This is a bug.F-const_trait_impl`#![feature(const_trait_impl)]``#![feature(const_trait_impl)]`F-min_specialization`#![feature(min_specialization)]``#![feature(min_specialization)]`PG-const-traitsProject group: Const traitsProject group: Const traitsT-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Description
#![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)
Metadata
Metadata
Assignees
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)A-specializationArea: Trait impl specializationArea: Trait impl specializationC-bugCategory: This is a bug.Category: This is a bug.F-const_trait_impl`#![feature(const_trait_impl)]``#![feature(const_trait_impl)]`F-min_specialization`#![feature(min_specialization)]``#![feature(min_specialization)]`PG-const-traitsProject group: Const traitsProject group: Const traitsT-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.