`rustc_const_unstable` on private items is confusing
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Problem
Right now, private items that use const-unstable things need one of the following:
rustc_const_unstable, to mark them as part of an unstable featurerustc_const_stable_indirect, to mark these uses of const-unstable features as okay to be used indirectly in const-stable functions
This can be particularly confusing when trying to assign features to these functions, since in particular, either of these attributes is okay to add to any private item, regardless of whether they actually need it.
The main issue is that we want to track what const features are indirectly exposed to stable, but that we don't want to recursively inspect function bodies to do this.
Proposal
So, I propose a new solution: rustc_forward_const_fn_unstable.
This is similar to rustc_allow_const_fn_unstable, but specifically for private items, and it has slightly different semantics:
- The features mentioned in the attribute must exist, be unstable, and be used in the body of the function.
- After being processed, the function is treated as unstable with all the different features listed. (and the correct issues)
This effectively punts a rustc_allow_const_fn_unstable attribute down the line to a caller function if needed, helps avoid the issue where people just add the same const unstable feature to all methods they need it on, and avoids unnecessarily adding unstable features to const methods that don't require them.
Effectively, it bypasses the issue discussed in this review thread.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the existing rustc_allow_const_fn_unstable behavior described in the issue and the linked review thread. Identify the compiler entry points and tests that govern rustc_const_unstable and rustc_const_stable_indirect, then determine how the proposed rustc_forward_const_fn_unstable semantics should be validated. Done means the new attribute enforces the stated feature checks and forwarding behavior without recursive body inspection.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100