rust-lang / rust-lang/rust

-Z allow-features does not apply to -Z flags

Open
#139,890 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-CLI A-stability C-bug T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

I tried this code: rustc -Z allow-features= -Z always-encode-mir

I expected to see this happen: rustc gives a hard error that always-encode-mir was not listed in allow-features.

Instead, this happened: rustc silently accepts the -Z flag.

It feels very natural to me that this should apply to flags, not just source code, by the same logic you'd want it anywhere: it gives the person running the build control over what unstable features they use, instead of unknowingly enabling features from the myriad sources that cargo picks up rustflags.

Meta

rustc --version --verbose:

rustc 1.87.0-nightly (43f0014ef 2025-03-25)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing rustc -Z allow-features= -Z always-encode-mir with the reported nightly compiler, then trace how allow-features is checked against command-line -Z flags. Confirm the current behavior and identify the relevant compiler tests or flag-validation entry point. Done means an unlisted unstable flag produces a hard error while an allowed flag remains accepted.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.