Skip to content

Please document how many times a compiler flag is recognized, or stop for more occurences than needed #143312

Open
@zjp-CN

Description

@zjp-CN

I noticed some flags can be passed to the compiler multiple times and they are all used by the rustc, while some flags are able to be fed to rustc multiple times but only the first/last occurence is used.

Examples:

  • accepted and recognized multiple times
    • -L
    • -Zcrate-attr
    • ...
  • accepted multiple times, but only the first is recognized
  • accepted multiple times, but only the last is recognized
    • -Zallow-features
    • cap-lints linked above tends to be this in the future :)
To confirm that only the last -Zallow-features is recognized.

// tool-attr.rs
#[rapx::a]
fn main() {}
$ rustc tool-attr.rs -Zallow-features=register_tool -Zallow-features=asm_const -Zcrate-attr="feature(register_tool)" -Zcrate-attr="register_tool(rapx)"

error[E0725]: the feature `register_tool` is not in the list of allowed features
 --> <crate attribute>:1:12
  |
1 | #![feature(register_tool)]
  |            ^^^^^^^^^^^^^

error[E0658]: the `#[register_tool]` attribute is an experimental feature
 --> <crate attribute>:1:1
  |
1 | #![register_tool(rapx)]
  | ^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #66079 <https://github.com/rust-lang/rust/issues/66079> for more information
  = help: add `#![feature(register_tool)]` to the crate attributes to enable
  = note: this compiler was built on 2025-06-13; consider upgrading it if it is out of date

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-CLIArea: Command-line interface (CLI) to the compilerA-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsT-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