-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New internal lint: unusual_names
#15794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
New internal lint: unusual_names
#15794
Conversation
bc0b47c
to
188849d
Compare
188849d
to
469557a
Compare
Seems reasonable. Will wait a bit if anyone on the team has anything to add. cc @rust-lang/clippy |
Sounds fine to me, feels like something we could make into a [allowed-names]
"rustc_errors::Applicability" = ["app", "applicability"]
"rustc_middle::ty::TyCtxt" = "tcx"
# etc |
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. |
469557a
to
4c32a55
Compare
This comment has been minimized.
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! { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
This comment has been minimized.
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.
4c32a55
to
5de7da8
Compare
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. |
This lint aims at detecting unusual names used in Clippy source code, such as
appl
orapplication
for arustc_errors::Applicability
variable, instead ofapp
andapplicability
which are commonly used throughout Clippy.This helps maintaining the consistency of the Clippy source code.
It is currently implemented for:
Applicability
:app
orapplicability
EarlyContext
/LateContext
:cx
TyCtxt
:tcx
changelog: none