-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
#[expect(unconditional_recursion)]
const fn codegen_diverge<T>() {
codegen_diverge::<(T,)>();
}
const fn only_const_callable() -> usize {
if false {
codegen_diverge::<()>();
}
2
}
const OK: usize = only_const_callable();
fn main() {
println!("{}", OK);
println!("{}", const { only_const_callable() });
// println!("{}", only_const_callable()); // error
}
We only actually recursively instantiate codegen_diverge
during mono item collection. This means using only_const_callable
at runtime results in a post monomophization error. CTFE lazily instantiates functions on demand so it never overflows.
Jules-Bertholet and Nadrieril
Metadata
Metadata
Assignees
Labels
No labels