Repository navigation
Conversation
|
Some changes occurred in compiler/rustc_attr_parsing cc @jdonszelmann, @JonathanBrouwer Some changes occurred in compiler/rustc_passes/src/check_attr.rs cc @jdonszelmann, @JonathanBrouwer Some changes occurred in compiler/rustc_attr_ir |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
6ca0789 to
1656f72
Compare
|
cc @rust-lang/clippy |
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
☔ The latest upstream changes (presumably #163957) made this pull request unmergeable. Please resolve the merge conflicts by rebasing. |
|
I originally self-assigned because I'd seen the word "namespace", which means something big, like type/value/macro namespaces. |
(and also port over three rustc lint attributes, as proof of concept)
Note
The below discussion assumes #162597 has been merged.
That PR implements an ambiguity error if
#[tool::attr]can refer to either an attribute macro or a tool attribute. In particular this means adding a new built-in tool is a breaking change, if not done over an edition.This PR implements parsing for the
linttool namespace (#[lint::attribute]) but doesn't add it as a builtin tool, so#![register_tool(lint)]is also required to use it. It raises an error on an unknown attribute within that namespace.The primary motivations for creating this namespace are:
trivial_field_reads(expanding#[rustc_trivial_field_reads]to more targets, place on Derive and Clone #160666) andc_buffer_length(Addc_buffer_lengthdiagnostic attribute #162565) to live, as these IMO do not belong in the diagnostic namespace.rustc_attrs #160808What is a "lint helper"
Attributes that change how or if a lint is emitted. Think of many of the internal attributes like
#[rustc_as_ptr],#[rustc_pass_by_value]etc. Other examples are#[deprecated]and#[must_not_suspend]. Evenclippyhas such a thing:#[clippy::format_args].On breaking changes
This doesn't add
lintas a built-in tool (likediagnostic,rustfmt,clippyetc are) so this pr is not a breaking change. The breaking changes are opt-in by using#![register_tool(lint)]in the crate root which is unstable at this time.The way this PR is implemented means that, even if users could use
#![register_tool(lint)]stably, they cannot stably use the namespace because an unknown attribute is an error and all valid attributes in it, at this time, are also feature gated. So there is no commitment to stability until we choose to stabilize an attribute in it.Going forward
We can require using
#![register_tool(lint)]indefinitely. It's possible to not require this this by addinglintas a builtin tool, but this (assuming #162597) breaksHowever as nobody on github does this it's probably only theoretically breaking. It's non-breaking to add it across an edition.
r? @estebank
cc @WaffleLapkin @petrochenkov