Closed
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.