Description
We want to switch to a scheme where everything inside the standard library requires min_const_fn
by default. If an additional #[rustc_not_min_const_fn]
is present, then the function will be uncallable from any min_const_fn
.
It's also important to note that a function #[rustc_const_unstable(feature "foo")] const fn bar() {}
without #[rustc_not_min_const_fn]
should a) enforce that that the function is min_const_fn
even without the feature gate active, b) not be callable as min_const_fn
without the the feature gate active.
Relevant code exists in:
- https://github.com/rust-lang/rust/blob/master/src/librustc/ty/constness.rs
- https://github.com/rust-lang/rust/blob/master/src/librustc_mir/transform/qualify_min_const_fn.rs
- https://github.com/rust-lang/rust/blob/master/src/librustc_mir/transform/qualify_consts.rs
Context: Centril@93ad760#r34994115 (also see my branch master...Centril:stabilize-vec-new-const)
Conversation replayed (keep-safe):
One thing that could be done is what's essentially the opposite scheme. Everything requires
min_const_fn
by default, unless it has an additionalrustc_not_min_const_fn
attribute (which makes the function uncallable from anymin_const_fn
).Or rename the attribute to
rustc_require_min_const_fn
, to make it sound less like an override
One thing that could be done is what's essentially the opposite scheme.
Oh... I like that! -- but what about user-land
const fn
? Do we only enforce this forstaged_api
crates?
user land
const fn
just keeps doing what it does now. As long as there's aconst fn
feature gate active, everything is notmin_const_fn
. The reason we have a complex scheme in libstd is stability. Users using nightly with feature gates already opt out of stability.