Tracking issue for migrating all remaining post-expansion feature gates to pre-expansion ones
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
[!TIP]
If you've arrived here because you encountered a feature gate warning for unstable syntax behind#[cfg(…)], here's how you can transform your code while keeping the unstable syntaxcfg-conditional:Before (triggers a feature gate warning):
#[cfg(feature = "nightly")] // or a different cfg-condition impl !Trait for Type {} // or a different unstable syntaxAfter (first approach) (idiomatic, doesn't trigger a warning):
macro_rules! generate { ($( $tt:tt )*) => { $( $tt )* } } #[cfg(feature = "nightly")] generate! { impl !Send for NotSend {} }After (second approach) (idiomatic, doesn't trigger a warning):
macro_rules! generate { // Of course, you can use macro metavariables to avoid code duplication etc. () => { impl !Trait for Type {} } } #[cfg(feature = "nightly")] generate!();If you'd like to see a more realistic example, head on over to https://github.com/arcnmx/packed-rs/pull/1/changes.
Steps
- Find the most recent relevant crater runs and manually reaudit affected crates
- check if at least some crates have been fixed downstream by now
- Collect all features where the crater run has happened a long time ago & issue a single crater run for all of them at once
For all the other ones that also don't emit a pre-expansion warning yet, add warnings immediately(done)no further input from T-compiler/T-lang should be needed since it's already legitimized by MCP 535.
Affected Syntactic Constructs
- item modifier
default(featurespecializationormin_specializationfor fns only)- we potentially want to drop this feature in favor of a different approach...
- ...so a syntax gate would make it easier to phase out the syntax later on
- issue a pre-expansion feature gate warning (legitimized by MCP 535)
- turn the warning into a hard error (needs crater, T-lang FCP)
- trait impl modifier
!(featurenegative_impls)- likely to be stabilized in 1–3 years, so a syntax gate isn't super pressing
- issue a pre-expansion feature gate warning (legitimized by MCP 535)
- turn the warning into a hard error (needs crater, T-lang FCP)
- expression
try { … }(featuretry_blocks)- already has a pre-expansion feature gate warning
- incredibly likely to be stabilized this year...
- ...so a syntax gate would be counterproductive / harmful (!)
- turn the warning into a hard error (needs crater, T-lang FCP)
- pattern
box $pat(featurebox_patterns)- already has a pre-expansion feature gate warning
- incredibly likely to be replaced with explicit or implicit deref patterns...
- ...so a syntax gate would make it easier to phase out the syntax later on
-
turn the warning into a hard error(needs crater, T-lang FCP) - remove the feature entirely instead (cratered, fcp'ed): https://github.com/rust-lang/rust/pull/156749
- pattern
$patpath { box $ident }, pseudo binding mode (featurebox_patterns)- incredibly likely to be replaced with explicit or implicit deref patterns...
- ...so a syntax gate would make it easier to phase out the syntax later on
- issue a pre-expansion feature gate warning (legitimized by MCP 535)
-
turn the warning into a hard error(needs crater, T-lang FCP) - remove the feature entirely instead (cratered, fcp'ed): https://github.com/rust-lang/rust/pull/156749
- item
trait $ident $genericparams = $bounds;(featuretrait_alias)- already has a pre-expansion feature gate warning
- turn the warning into a hard error (needs crater, T-lang FCP)
- trait item modifier
auto(featureauto_traits)- already has a pre-expansion feature gate warning
- turn the warning into a hard error (needs crater, T-lang FCP)
- (not fitting 100%) syntax
impl $traitref for .. {}(early version of a now removed predecessor of featureauto_traits)- most recent crater run: PR RUST-121072
- issue a pre-expansion feature gate warning (legitimized by MCP 535, maybe?)
- reevaluate RUST-121072's crater report & send downstream patches
- turn the warning into a hard error (needs T-lang FCP, maybe another crater run)
- item
macro $ident$macroparams { $ttstar }(featuredecl_macro)- already has a pre-expansion feature gate warning
- turn the warning into a hard error (needs crater, T-lang FCP)
- (not fitting 100%) predicates
$ty = $tyand$ty == $ty(no corresp. feature was ever added (cc RUST-22074, RUST-87471))- straight up hard error (crater: 0 regressions, needs T-lang FCP): PR RUST-153513
- attribute in certain expression contexts (feature
stmt_expr_attributes)- META: FIXME: elaborate
- see also https://github.com/rust-lang/rust/pull/159581
Pre-History (Incomplete)
- https://github.com/rust-lang/rust/pull/63545
- https://github.com/rust-lang/rust/pull/65742
- https://github.com/rust-lang/rust/issues/65860
- https://github.com/rust-lang/rust/pull/66004
- https://github.com/rust-lang/compiler-team/issues/535
- https://github.com/rust-lang/rust/pull/99935
- https://github.com/rust-lang/rust/pull/116393
- https://github.com/rust-lang/rust/pull/121072
Implementation History
- https://github.com/rust-lang/rust/pull/153513
- https://github.com/rust-lang/rust/pull/154475
- https://github.com/rust-lang/rust/pull/154527
Downstream Patches
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
No source files or tests are named. Start by reviewing the most recent relevant crater runs and the implementation-history pull requests, then audit the listed affected syntactic constructs and their downstream status. Done means completing the required crater, warning or hard-error decisions, and related compiler-team follow-up for the remaining checklist items.
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
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100