Skip to content

Expand checks for register_tool - #160145

Merged
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
nbdd0121:register_tool
Aug 1, 2026
Merged

Expand checks for register_tool#160145
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
nbdd0121:register_tool

Conversation

@nbdd0121

@nbdd0121 nbdd0121 commented Jul 29, 2026

Copy link
Copy Markdown
Member

Follow up to #158038 (review) and #158038 (comment)

  • Add tool-attribute test to ensure tools are not preserved across crate
  • Reject invalid identifiers (super/self/Self/crate) in register_tool
  • Add lint for duplicate tools

r? @mejrs

@rustbot

rustbot commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann, @JonathanBrouwer

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 29, 2026
@mejrs mejrs added the F-register_tool `#![feature(register_tool)]` label Jul 30, 2026

@mejrs mejrs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update the PR description to specify precisely what functionality is implemented?

Both for myself, so I can verify the implementation matches intent, and to leave a summary for others, so they can read it while reviewing the state of the feature or writing reference material for example. This applies especially if/when we diverge from the RFC.

The RFC specifies "tools must be a single ident", this PR implements "must be a valid identifier". That best matches the intent of the RFC, so lets go ahead with that. (Another option would be to limit to ascii but iirc there is no good reason to be that restrictive)

View changes since this review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add such a test using -Zcrate-attr=register_tool(..) -Zallow(duplicate_tools) (whatever the precise syntax is) with a crate level attribute introducing the same tool?

@mejrs mejrs added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 30, 2026
nbdd0121 added 2 commits July 31, 2026 00:57
Forbid super/crate/self/Self to be used in register_tool.
Also, add test for raw identifier and unicode identifiers.
This adds back the previously existing duplicate tool error, but as a
suppressable lint.
@nbdd0121

nbdd0121 commented Jul 31, 2026

Copy link
Copy Markdown
Member Author

Can you update the PR description to specify precisely what functionality is implemented?

I have nothing to add except those already in the commit message. I just added the commit message to the PR description and hopefully that's enough.

The RFC specifies "tools must be a single ident", this PR implements "must be a valid identifier". That best matches the intent of the RFC, so lets go ahead with that. (Another option would be to limit to ascii but iirc there is no good reason to be that restrictive)

Added a line to test unicode too.

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 31, 2026

@mejrs mejrs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rust-bors

rust-bors Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 83ed6e4 has been approved by mejrs

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 31, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 1, 2026
Expand checks for register_tool

Follow up to rust-lang#158038 (review) and rust-lang#158038 (comment)

* Add tool-attribute test to ensure tools are not preserved across crate
* Reject invalid identifiers (super/self/Self/crate) in register_tool
* Add lint for duplicate tools

r? @mejrs
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 1, 2026
Expand checks for register_tool

Follow up to rust-lang#158038 (review) and rust-lang#158038 (comment)

* Add tool-attribute test to ensure tools are not preserved across crate
* Reject invalid identifiers (super/self/Self/crate) in register_tool
* Add lint for duplicate tools

r? @mejrs
rust-bors Bot pushed a commit that referenced this pull request Aug 1, 2026
Rollup of 14 pull requests

Successful merges:

 - #159245 (Emit retags in codegen to support BorrowSanitizer (part 5))
 - #159864 (Report "capacity overflow" for oversized Rc<[T]>/Arc<[T]>)
 - #160079 (make atomic operations const)
 - #160124 (Structurally prevent zero-count `BackendRepr::SimdVector`s)
 - #160162 (Make `#[fundamental]` only apply to the first argument of `Box`)
 - #160210 (Remove an outdated FIXME)
 - #160282 (Improve diagnostic for patterns in function pointer types)
 - #157928 (Eagerly fetch typeck results when linting)
 - #159672 (Improve suggestions when multiples tuples implement the same trait)
 - #159861 (Add documentation for the `non_exhaustive` attribute)
 - #159907 (Fix `hidden_glob_reexports` in `rustc_ast`)
 - #159998 (Align expect messages with guidance)
 - #160145 (Expand checks for register_tool)
 - #160307 (Update `minifier` version to `0.4.0`)
@rust-bors
rust-bors Bot merged commit 9d06bc8 into rust-lang:main Aug 1, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Aug 1, 2026
rust-timer added a commit that referenced this pull request Aug 1, 2026
Rollup merge of #160145 - nbdd0121:register_tool, r=mejrs

Expand checks for register_tool

Follow up to #158038 (review) and #158038 (comment)

* Add tool-attribute test to ensure tools are not preserved across crate
* Reject invalid identifiers (super/self/Self/crate) in register_tool
* Add lint for duplicate tools

r? @mejrs
@nbdd0121
nbdd0121 deleted the register_tool branch August 1, 2026 11:10
@jyn514 jyn514 mentioned this pull request Aug 1, 2026
8 tasks
pull Bot pushed a commit to xtqqczze/rust-lang-miri that referenced this pull request Aug 2, 2026
Rollup of 14 pull requests

Successful merges:

 - rust-lang/rust#159245 (Emit retags in codegen to support BorrowSanitizer (part 5))
 - rust-lang/rust#159864 (Report "capacity overflow" for oversized Rc<[T]>/Arc<[T]>)
 - rust-lang/rust#160079 (make atomic operations const)
 - rust-lang/rust#160124 (Structurally prevent zero-count `BackendRepr::SimdVector`s)
 - rust-lang/rust#160162 (Make `#[fundamental]` only apply to the first argument of `Box`)
 - rust-lang/rust#160210 (Remove an outdated FIXME)
 - rust-lang/rust#160282 (Improve diagnostic for patterns in function pointer types)
 - rust-lang/rust#157928 (Eagerly fetch typeck results when linting)
 - rust-lang/rust#159672 (Improve suggestions when multiples tuples implement the same trait)
 - rust-lang/rust#159861 (Add documentation for the `non_exhaustive` attribute)
 - rust-lang/rust#159907 (Fix `hidden_glob_reexports` in `rustc_ast`)
 - rust-lang/rust#159998 (Align expect messages with guidance)
 - rust-lang/rust#160145 (Expand checks for register_tool)
 - rust-lang/rust#160307 (Update `minifier` version to `0.4.0`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) F-register_tool `#![feature(register_tool)]` S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants