Open
Description
Crates using staged_api
are forbidden from calling const unstable functions from stable const functions. However, this restriction does not extend to the initializers of consts or statics. Although unlikely, this could allow for "backdoor stabilization" of various const-eval features. For example, the following would lock in the current implementation of const_if_match
.
#![stable(feature = "bar", since = "1.34")]
#![feature(staged_api)]
#![feature(const_if_match)]
#![feature(foo)]
#[rustc_const_unstable(feature = "foo", issue = "0")]
const fn foo() -> i32 {
if true { 0 } else { 1 }
}
#[stable(feature = "bar", since = "1.34")]
pub const BAR: i32 = foo();
If BAR
were a const fn
instead of a const
, that example would be rejected.
#[rustc_const_stable(feature = "bar", since = "1.34")]
pub const fn bar() -> i32 {
foo()
}
cc @rust-lang/wg-const-eval