-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
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
In general we don't require private functions to have stability attributes. Stable functions are free to call private functions, and stable const functions are free to call private const functions that have no stability attribute.
But when a private const function inherits a stability attribute from an enclosing module, it currently can no longer be called from stable const functions. I think this behavior is not correct. For a private function, I would think stability attributes should be irrelevant.
This is causing trouble in #75772 (comment).
#![feature(staged_api, const_fn)]
#![stable(feature = "repro", since = "0")]
mod detail {
#![unstable(feature = "detail", issue = "none")] // works if removed
pub(crate) const fn f() {}
// presumably other public stable things
}
#[stable(feature = "repro", since = "0")]
#[rustc_const_stable(feature = "repro", since = "0")]
pub const fn f() {
detail::f();
}
error[E0723]: can only call other `const fn` within a `const fn`, but `const detail::f` is not stable as `const fn`
--> src/lib.rs:15:5
|
15 | detail::f();
| ^^^^^^^^^^^
|
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
= help: add `#![feature(const_fn)]` to the crate attributes to enable
Cross referencing const fn
tracking issue #57563.
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.