Repository navigation
Add a lint helper attribute namespace - #163625
Merged
Merged
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 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Contributor
|
I originally self-assigned because I'd seen the word "namespace", which means something big, like type/value/macro namespaces. |
WaffleLapkin
self-requested a review
October 16, 2026 12:43
mejrs
force-pushed
the
lint_helper_namespace-
branch
from
October 19, 2026 13:57
1656f72 to
4339030
Compare
This comment has been minimized.
This comment has been minimized.
57 tasks
This comment has been minimized.
This comment has been minimized.
mejrs
force-pushed
the
lint_helper_namespace-
branch
from
October 28, 2026 22:21
4339030 to
c839f3f
Compare
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 29, 2026 00:06
c839f3f to
d99929a
Compare
This comment has been minimized.
This comment has been minimized.
mejrs
force-pushed
the
lint_helper_namespace-
branch
from
October 31, 2026 17:10
d99929a to
9748663
Compare
This comment has been minimized.
This comment has been minimized.
Member
Author
|
@WaffleLapkin, @estebank, is either of you be able to review this? |
Contributor
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Nov 3, 2026
…tebank Add a lint helper attribute namespace (and also port over three rustc lint attributes, as proof of concept) This PR implements parsing for the `lint` tool 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: - creating a place for attributes like `trivial_field_reads` (rust-lang#160666) and `c_buffer_length` (rust-lang#162565) to live, as these IMO do not belong in the diagnostic namespace. - make it easier to unstably land lints and lint helper attributes, as these currently suffer from the "any new built-in attribute is a breaking change" problem. - implementing (part of) rust-lang#160808 ### What 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]`. Even `clippy` has such a thing: `#[clippy::format_args]`. ### On breaking changes This doesn't add `lint` as a built-in tool (like `diagnostic`, `rustfmt`, `clippy` etc 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 adding `lint` as a builtin tool, but this (assuming rust-lang#162597) breaks ```rust #[lint::as_ptr] struct Foo; mod lint { pub use derive as as_ptr; } ``` However as [nobody on github does this](https://github.com/search?type=code&q=%22%23%5Blint%3A%3A%22+language%3ARust) it's probably only theoretically breaking. It's non-breaking to add it across an edition. r? @estebank cc @WaffleLapkin @petrochenkov
rust-bors Bot
pushed a commit
that referenced
this pull request
Nov 3, 2026
…uwer Rollup of 20 pull requests Successful merges: - #149245 (Make inline attributes apply to the generated `poll` in async fn) - #163495 (Parallelize AST -> HIR lowering) - #164304 ([perf] Reuse CanonicalVarKinds if no new variables were added) - #165109 (Avoid building a region map when erasing bound regions) - #163393 (std: Use getexecpath() for current_exe() on OpenBSD) - #163625 (Add a lint helper attribute namespace ) - #164414 (Add `let_underscore_drop_guard` lint.) - #165342 (Avoid unnecessary MIR traversals in CheckPackedRef lint) - #165351 (delegation: insert probing adjustments before args check adjustments) - #165358 (Reenable some cg_gcc tests that were disabled) - #165377 (Make `no_implicit_prelude` not suppress tool attributes) - #165397 (Add codegen test for unused match arms removed after inlining) - #165398 (Rework parallel reproducibility tests) - #162608 (Avoid oscillating line wrapping due to symbol indices) - #164241 (make the safety documentation consistent in Ptr module) - #165029 (Use `MalformedLintAttributeInput` in more places) - #165203 (AIX: Implement TLS destructor guard in std and update dynamic-loading-cdylib test) - #165230 (Fix rigidity assertion ICE) - #165293 (unstable-book: update default-visibility.md to link to tracking issue) - #165374 (Refactorings in preparation for the move trait)
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Nov 3, 2026
…tebank Add a lint helper attribute namespace (and also port over three rustc lint attributes, as proof of concept) This PR implements parsing for the `lint` tool 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: - creating a place for attributes like `trivial_field_reads` (rust-lang#160666) and `c_buffer_length` (rust-lang#162565) to live, as these IMO do not belong in the diagnostic namespace. - make it easier to unstably land lints and lint helper attributes, as these currently suffer from the "any new built-in attribute is a breaking change" problem. - implementing (part of) rust-lang#160808 ### What 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]`. Even `clippy` has such a thing: `#[clippy::format_args]`. ### On breaking changes This doesn't add `lint` as a built-in tool (like `diagnostic`, `rustfmt`, `clippy` etc 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 adding `lint` as a builtin tool, but this (assuming rust-lang#162597) breaks ```rust #[lint::as_ptr] struct Foo; mod lint { pub use derive as as_ptr; } ``` However as [nobody on github does this](https://github.com/search?type=code&q=%22%23%5Blint%3A%3A%22+language%3ARust) it's probably only theoretically breaking. It's non-breaking to add it across an edition. r? @estebank cc @WaffleLapkin @petrochenkov
rust-bors Bot
pushed a commit
that referenced
this pull request
Nov 3, 2026
…uwer Rollup of 21 pull requests Successful merges: - #165416 (fix unsoundness when compiling `[diverging_const; 0]`) - #149245 (Make inline attributes apply to the generated `poll` in async fn) - #163495 (Parallelize AST -> HIR lowering) - #164304 ([perf] Reuse CanonicalVarKinds if no new variables were added) - #165109 (Avoid building a region map when erasing bound regions) - #163393 (std: Use getexecpath() for current_exe() on OpenBSD) - #163625 (Add a lint helper attribute namespace ) - #164414 (Add `let_underscore_drop_guard` lint.) - #165342 (Avoid unnecessary MIR traversals in CheckPackedRef lint) - #165351 (delegation: insert probing adjustments before args check adjustments) - #165358 (Reenable some cg_gcc tests that were disabled) - #165377 (Make `no_implicit_prelude` not suppress tool attributes) - #165397 (Add codegen test for unused match arms removed after inlining) - #165398 (Rework parallel reproducibility tests) - #162608 (Avoid oscillating line wrapping due to symbol indices) - #164241 (make the safety documentation consistent in Ptr module) - #165029 (Use `MalformedLintAttributeInput` in more places) - #165203 (AIX: Implement TLS destructor guard in std and update dynamic-loading-cdylib test) - #165230 (Fix rigidity assertion ICE) - #165293 (unstable-book: update default-visibility.md to link to tracking issue) - #165374 (Refactorings in preparation for the move trait)
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Nov 3, 2026
…tebank Add a lint helper attribute namespace (and also port over three rustc lint attributes, as proof of concept) This PR implements parsing for the `lint` tool 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: - creating a place for attributes like `trivial_field_reads` (rust-lang#160666) and `c_buffer_length` (rust-lang#162565) to live, as these IMO do not belong in the diagnostic namespace. - make it easier to unstably land lints and lint helper attributes, as these currently suffer from the "any new built-in attribute is a breaking change" problem. - implementing (part of) rust-lang#160808 ### What 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]`. Even `clippy` has such a thing: `#[clippy::format_args]`. ### On breaking changes This doesn't add `lint` as a built-in tool (like `diagnostic`, `rustfmt`, `clippy` etc 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 adding `lint` as a builtin tool, but this (assuming rust-lang#162597) breaks ```rust #[lint::as_ptr] struct Foo; mod lint { pub use derive as as_ptr; } ``` However as [nobody on github does this](https://github.com/search?type=code&q=%22%23%5Blint%3A%3A%22+language%3ARust) it's probably only theoretically breaking. It's non-breaking to add it across an edition. r? @estebank cc @WaffleLapkin @petrochenkov
rust-bors Bot
pushed a commit
that referenced
this pull request
Nov 3, 2026
…uwer Rollup of 20 pull requests Successful merges: - #149245 (Make inline attributes apply to the generated `poll` in async fn) - #163495 (Parallelize AST -> HIR lowering) - #164304 ([perf] Reuse CanonicalVarKinds if no new variables were added) - #165109 (Avoid building a region map when erasing bound regions) - #163393 (std: Use getexecpath() for current_exe() on OpenBSD) - #163625 (Add a lint helper attribute namespace ) - #164414 (Add `let_underscore_drop_guard` lint.) - #165342 (Avoid unnecessary MIR traversals in CheckPackedRef lint) - #165351 (delegation: insert probing adjustments before args check adjustments) - #165358 (Reenable some cg_gcc tests that were disabled) - #165377 (Make `no_implicit_prelude` not suppress tool attributes) - #165397 (Add codegen test for unused match arms removed after inlining) - #165398 (Rework parallel reproducibility tests) - #162608 (Avoid oscillating line wrapping due to symbol indices) - #164241 (make the safety documentation consistent in Ptr module) - #165029 (Use `MalformedLintAttributeInput` in more places) - #165203 (AIX: Implement TLS destructor guard in std and update dynamic-loading-cdylib test) - #165230 (Fix rigidity assertion ICE) - #165293 (unstable-book: update default-visibility.md to link to tracking issue) - #165374 (Refactorings in preparation for the move trait)
rust-bors Bot
pushed a commit
that referenced
this pull request
Nov 3, 2026
…uwer Rollup of 22 pull requests Successful merges: - #149245 (Make inline attributes apply to the generated `poll` in async fn) - #164304 ([perf] Reuse CanonicalVarKinds if no new variables were added) - #165109 (Avoid building a region map when erasing bound regions) - #163393 (std: Use getexecpath() for current_exe() on OpenBSD) - #163625 (Add a lint helper attribute namespace ) - #164414 (Add `let_underscore_drop_guard` lint.) - #165342 (Avoid unnecessary MIR traversals in CheckPackedRef lint) - #165351 (delegation: insert probing adjustments before args check adjustments) - #165358 (Reenable some cg_gcc tests that were disabled) - #165377 (Make `no_implicit_prelude` not suppress tool attributes) - #165397 (Add codegen test for unused match arms removed after inlining) - #165398 (Rework parallel reproducibility tests) - #162232 (Replace `builtin #` with `k#`) - #162608 (Avoid oscillating line wrapping due to symbol indices) - #164241 (make the safety documentation consistent in Ptr module) - #164258 (clarify when `Vec::into_boxed_slice()` is in-place) - #165029 (Use `MalformedLintAttributeInput` in more places) - #165203 (AIX: Implement TLS destructor guard in std and update dynamic-loading-cdylib test) - #165230 (Fix rigidity assertion ICE) - #165293 (unstable-book: update default-visibility.md to link to tracking issue) - #165374 (Refactorings in preparation for the move trait) - #165421 (another Enzyme submodule update for nested autodiff)
rust-bors Bot
pushed a commit
that referenced
this pull request
Nov 4, 2026
Rollup merge of #163625 - mejrs:lint_helper_namespace-, r=estebank Add a lint helper attribute namespace (and also port over three rustc lint attributes, as proof of concept) This PR implements parsing for the `lint` tool 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: - creating a place for attributes like `trivial_field_reads` (#160666) and `c_buffer_length` (#162565) to live, as these IMO do not belong in the diagnostic namespace. - make it easier to unstably land lints and lint helper attributes, as these currently suffer from the "any new built-in attribute is a breaking change" problem. - implementing (part of) #160808 ### What 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]`. Even `clippy` has such a thing: `#[clippy::format_args]`. ### On breaking changes This doesn't add `lint` as a built-in tool (like `diagnostic`, `rustfmt`, `clippy` etc 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 adding `lint` as a builtin tool, but this (assuming #162597) breaks ```rust #[lint::as_ptr] struct Foo; mod lint { pub use derive as as_ptr; } ``` However as [nobody on github does this](https://github.com/search?type=code&q=%22%23%5Blint%3A%3A%22+language%3ARust) it's probably only theoretically breaking. It's non-breaking to add it across an edition. r? @estebank cc @WaffleLapkin @petrochenkov
RalfJung
pushed a commit
to RalfJung/miri
that referenced
this pull request
Nov 4, 2026
…uwer Rollup of 22 pull requests Successful merges: - rust-lang/rust#149245 (Make inline attributes apply to the generated `poll` in async fn) - rust-lang/rust#164304 ([perf] Reuse CanonicalVarKinds if no new variables were added) - rust-lang/rust#165109 (Avoid building a region map when erasing bound regions) - rust-lang/rust#163393 (std: Use getexecpath() for current_exe() on OpenBSD) - rust-lang/rust#163625 (Add a lint helper attribute namespace ) - rust-lang/rust#164414 (Add `let_underscore_drop_guard` lint.) - rust-lang/rust#165342 (Avoid unnecessary MIR traversals in CheckPackedRef lint) - rust-lang/rust#165351 (delegation: insert probing adjustments before args check adjustments) - rust-lang/rust#165358 (Reenable some cg_gcc tests that were disabled) - rust-lang/rust#165377 (Make `no_implicit_prelude` not suppress tool attributes) - rust-lang/rust#165397 (Add codegen test for unused match arms removed after inlining) - rust-lang/rust#165398 (Rework parallel reproducibility tests) - rust-lang/rust#162232 (Replace `builtin #` with `k#`) - rust-lang/rust#162608 (Avoid oscillating line wrapping due to symbol indices) - rust-lang/rust#164241 (make the safety documentation consistent in Ptr module) - rust-lang/rust#164258 (clarify when `Vec::into_boxed_slice()` is in-place) - rust-lang/rust#165029 (Use `MalformedLintAttributeInput` in more places) - rust-lang/rust#165203 (AIX: Implement TLS destructor guard in std and update dynamic-loading-cdylib test) - rust-lang/rust#165230 (Fix rigidity assertion ICE) - rust-lang/rust#165293 (unstable-book: update default-visibility.md to link to tracking issue) - rust-lang/rust#165374 (Refactorings in preparation for the move trait) - rust-lang/rust#165421 (another Enzyme submodule update for nested autodiff)
This was referenced Nov 11, 2026
flip1995
pushed a commit
to flip1995/rust-clippy
that referenced
this pull request
Nov 12, 2026
…uwer Rollup of 22 pull requests Successful merges: - rust-lang/rust#149245 (Make inline attributes apply to the generated `poll` in async fn) - rust-lang/rust#164304 ([perf] Reuse CanonicalVarKinds if no new variables were added) - rust-lang/rust#165109 (Avoid building a region map when erasing bound regions) - rust-lang/rust#163393 (std: Use getexecpath() for current_exe() on OpenBSD) - rust-lang/rust#163625 (Add a lint helper attribute namespace ) - rust-lang/rust#164414 (Add `let_underscore_drop_guard` lint.) - rust-lang/rust#165342 (Avoid unnecessary MIR traversals in CheckPackedRef lint) - rust-lang/rust#165351 (delegation: insert probing adjustments before args check adjustments) - rust-lang/rust#165358 (Reenable some cg_gcc tests that were disabled) - rust-lang/rust#165377 (Make `no_implicit_prelude` not suppress tool attributes) - rust-lang/rust#165397 (Add codegen test for unused match arms removed after inlining) - rust-lang/rust#165398 (Rework parallel reproducibility tests) - rust-lang/rust#162232 (Replace `builtin #` with `k#`) - rust-lang/rust#162608 (Avoid oscillating line wrapping due to symbol indices) - rust-lang/rust#164241 (make the safety documentation consistent in Ptr module) - rust-lang/rust#164258 (clarify when `Vec::into_boxed_slice()` is in-place) - rust-lang/rust#165029 (Use `MalformedLintAttributeInput` in more places) - rust-lang/rust#165203 (AIX: Implement TLS destructor guard in std and update dynamic-loading-cdylib test) - rust-lang/rust#165230 (Fix rigidity assertion ICE) - rust-lang/rust#165293 (unstable-book: update default-visibility.md to link to tracking issue) - rust-lang/rust#165374 (Refactorings in preparation for the move trait) - rust-lang/rust#165421 (another Enzyme submodule update for nested autodiff)
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Nov 12, 2026
Move more rustc lint attributes to lint helpers. Part 2 of implementing rust-lang#160808 (For part 1, see rust-lang#163625)
rust-bors Bot
pushed a commit
that referenced
this pull request
Nov 13, 2026
Add a lint helper attribute namespace (and also port over three rustc lint attributes, as proof of concept) This PR implements parsing for the `lint` tool 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: - creating a place for attributes like `trivial_field_reads` (#160666) and `c_buffer_length` (#162565) to live, as these IMO do not belong in the diagnostic namespace. - make it easier to unstably land lints and lint helper attributes, as these currently suffer from the "any new built-in attribute is a breaking change" problem. - implementing (part of) #160808 ### What 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]`. Even `clippy` has such a thing: `#[clippy::format_args]`. ### On breaking changes This doesn't add `lint` as a built-in tool (like `diagnostic`, `rustfmt`, `clippy` etc 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 adding `lint` as a builtin tool, but this (assuming #162597) breaks ```rust #[lint::as_ptr] struct Foo; mod lint { pub use derive as as_ptr; } ``` However as [nobody on github does this](https://github.com/search?type=code&q=%22%23%5Blint%3A%3A%22+language%3ARust) it's probably only theoretically breaking. It's non-breaking to add it across an edition. r? @estebank cc @WaffleLapkin @petrochenkov
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Nov 23, 2026
Move more rustc lint attributes to lint helpers. Part 2 of implementing rust-lang#160808 (For part 1, see rust-lang#163625)
jhpratt
added a commit
to jhpratt/rust
that referenced
this pull request
Nov 23, 2026
Move more rustc lint attributes to lint helpers. Part 2 of implementing rust-lang#160808 (For part 1, see rust-lang#163625)
mehmettoplu-rs
pushed a commit
to mehmettoplu-rs/miri
that referenced
this pull request
Nov 24, 2026
Move more rustc lint attributes to lint helpers. Part 2 of implementing rust-lang/rust#160808 (For part 1, see rust-lang/rust#163625)
DaniPopes
added a commit
to paradigmxyz/solar
that referenced
this pull request
Nov 25, 2026
The docs job on main fails since nightly 2026-11-23 (rust-lang/rust#163625 moved rustc's lint helper attributes into the `lint::` tool namespace), with "cannot find attribute `rustc_pass_by_value`": https://github.com/paradigmxyz/solar/actions/runs/45395004177/job/138448296782 The attribute only feeds rustc's internal `rustc::` pass-by-value lint, which we never enable, so this drops it from `Interned` and `Gcx` instead of opting into the unstable `register_tool(lint)` namespace.
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.
View all comments
(and also port over three rustc lint attributes, as proof of concept)
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_lengthlint helper #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