-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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-stabilityArea: `#[stable]`, `#[unstable]` etc.Area: `#[stable]`, `#[unstable]` etc.C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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
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-stabilityArea: `#[stable]`, `#[unstable]` etc.Area: `#[stable]`, `#[unstable]` etc.C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.