Open
Description
This is a tracking issue for the -Z crate-attr
unstable option.
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
- Adjust documentation (see instructions on rustc-dev-guide)
- Stabilization PR (see instructions on rustc-dev-guide)
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. - fix interactions with doctests:
rustdoc --test
does not respect-Zcrate-attr
#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
Implementation history
- Initial implementation: Add the -Zcrate-attr=foo unstable rustc option #52355
- Recommended in other diagnostics: fix #113702 emit a proper diagnostic message for unstable lints passed from CLI #114959
- Documentation and tests: Document -Z crate-attr #138288
- Improve diagnostics for crate-attr itself: Improve
-Z crate-attr
diagnostics #138336