rust-lang / rust-lang/rust

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

Open
#143,312 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

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

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 the rustc command in the issue and compare repeated -L, -Zcrate-attr, and -Zallow-features flags. The issue names no files or tests; done requires choosing and implementing or documenting a consistent occurrence policy for compiler flags, with coverage for the cited examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.