Skip to content

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

Open
@jyn514

Description

@jyn514

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-CLIArea: Command-line interface (CLI) to the compilerA-stabilityArea: `#[stable]`, `#[unstable]` etc.C-bugCategory: This is a bug.T-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