rust-lang / rust-lang/rust

Tracking Issue for -Z crate-attr

Open
#138,287 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

-Zcrate-attr A-CLI B-RFC-approved C-tracking-issue S-tracking-impl-incomplete T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

This is a tracking issue for the -Z crate-attr unstable option (RFC 3791).

About tracking issues

Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Discussion comments will get marked as off-topic or deleted.
Repeated discussions on the tracking issue may lead to the tracking issue getting locked.

Steps
Unresolved Questions
  • this likely needs an RFC, since it landed without much discussion? i am tentatively planning to do this at the same time as an RFC for #![register_tool].
  • probably we will want to limit the syntax? for example, -Z crate-attr='crate_name= /* foo */ "test"' is currently accepted without warning, and -Z crate-attr='crate_name=/*' gives an error about an unterminated block comment. explicitly rejected by the RFC
  • fix interactions with doctests: https://github.com/rust-lang/rust/issues/138491
  • we should improve diagnostics; currently we treat the attribute as surrounded by #![ /*...*/ ], but don't show the surrounding code in the error:
; rustc src/main.rs -Z crate-attr='#![crate_name="test"]'
error: expected identifier, found `#`
 --> <crate attribute>:1:1
  |
1 | #![crate_name="test"]
  | ^ expected identifier
  • fix lint controls to desugar to crate-attr, as described in the RFC
  • test that editions and file!/line!/column! behave as specified in the RFC
Implementation history

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

Read RFC 3791 and the rustc-dev-guide instructions linked in the checklist, then review the remaining lint-control and edition/file!/line!/column! requirements. Done means those behaviors are tested, the documentation is updated, and a stabilization PR is prepared.

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
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.