Conversation
Collaborator
|
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.
mejrs
force-pushed
the
lint_helper_namespace-
branch
from
October 2, 2026 16:32
6ca0789 to
1656f72
Compare
Collaborator
|
cc @rust-lang/clippy |
Collaborator
|
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. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(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