Skip to content

Conversation

samueltardieu
Copy link
Member

@samueltardieu samueltardieu commented Sep 30, 2025

This lint aims at detecting unusual names used in Clippy source code, such as appl or application for a rustc_errors::Applicability variable, instead of app and applicability which are commonly used throughout Clippy.

This helps maintaining the consistency of the Clippy source code.

It is currently implemented for:

  • Applicability: app or applicability
  • EarlyContext/LateContext: cx
  • TyCtxt: tcx

changelog: none

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Sep 30, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 30, 2025

r? @Jarcho

rustbot has assigned @Jarcho.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@samueltardieu samueltardieu marked this pull request as draft September 30, 2025 15:36
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Sep 30, 2025
@samueltardieu samueltardieu marked this pull request as ready for review September 30, 2025 17:26
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Sep 30, 2025
@Jarcho
Copy link
Contributor

Jarcho commented Oct 1, 2025

Seems reasonable. Will wait a bit if anyone on the team has anything to add.

cc @rust-lang/clippy

@Alexendoo
Copy link
Member

Sounds fine to me, feels like something we could make into a disallowed- style lint

[allowed-names]
"rustc_errors::Applicability" = ["app", "applicability"]
"rustc_middle::ty::TyCtxt" = "tcx"
# etc

@samueltardieu
Copy link
Member Author

I thought about this and as long as it is an internal lint only we can edit the source as easily as we would edit the configuration file. But if we make it a general lint, it would be a good idea to make it configurable of course.

@samueltardieu samueltardieu force-pushed the features/unusual-names branch from 469557a to 4c32a55 Compare October 6, 2025 22:31
@rustbot

This comment has been minimized.

// An alternative content can be specified using a colon after the symbol name.
//
// `cargo dev fmt` ensures that the content of the `generate!()` macro call stays sorted.
generate! {
Copy link
Member

Choose a reason for hiding this comment

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

We don't want to register symbols into the general compiler if they're only used for an internal lint. Could we either cfg-gate them or move this logic to an internal module?

Copy link
Member Author

Choose a reason for hiding this comment

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

We already do that a lot: sym::expn_data, sym::outer_expn, sym::lint_vec, sym::check_attributes, etc. Why do it differently for this particular lint?

Maybe you should file a separate issue if you think it is worth the complexity to have a separate symbol list. I'm not sure this is needed, as those symbols are created at compile time as constants, and they are few so that they probably don't create many collisions when dynamically interning new strings when parsing code.

Copy link
Member

Choose a reason for hiding this comment

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

In that case, I'll do an experiment and open a Pr performing the optimization if it turns out to be significant. Although in a mini-benchmark with -Aclippy::all this PR showed to be about +0.2% on tokio 1.38.1, and that's what really brought me to post this comment.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do not cfg these out. Having to rebuild all of clippy to switch on the internal feature is not a good trade off.

You're almost certainly measuring noise. Symbol interning shouldn't even be 0.1% of the runtime and that's the only thing this affects.

@rustbot

This comment has been minimized.

This lint aims at detecting unusual names used in Clippy source code,
such as `appl` or `application` for a `rustc_errors::Applicability`
variable, instead of `app` and `applicability` which are commonly used
throughout Clippy.

This helps maintaining the consistency of the Clippy source code.
@samueltardieu samueltardieu force-pushed the features/unusual-names branch from 4c32a55 to 5de7da8 Compare October 11, 2025 07:37
@rustbot
Copy link
Collaborator

rustbot commented Oct 11, 2025

This PR was rebased onto a different master 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants