Skip to content

Enforce min_const_fn by default in staged_api with opt-out #64285

Closed
@Centril

Description

@Centril

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:


Context: Centril@93ad760#r34994115 (also see my branch master...Centril:stabilize-vec-new-const)

Conversation replayed (keep-safe):

@oli-obk:

One thing that could be done is what's essentially the opposite scheme. Everything requires min_const_fn by default, unless it has an additional rustc_not_min_const_fn attribute (which makes the function uncallable from any min_const_fn).

Or rename the attribute to rustc_require_min_const_fn, to make it sound less like an override

@Centril:

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 for staged_api crates?

@oli-obk:

user land const fn just keeps doing what it does now. As long as there's a const fn feature gate active, everything is not min_const_fn. The reason we have a complex scheme in libstd is stability. Users using nightly with feature gates already opt out of stability.

Metadata

Metadata

Labels

A-attributesArea: Attributes (`#[…]`, `#![…]`)A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)A-stabilityArea: `#[stable]`, `#[unstable]` etc.C-enhancementCategory: An issue proposing an enhancement or a PR with one.P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions