-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Also emit suggestions for usages in the non_upper_case_globals
lint
#142645
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?
Conversation
r? @fee1-dead rustbot has assigned @fee1-dead. Use |
help: convert the identifier to upper case | ||
| | ||
LL - const my_static: u32 = 0; | ||
LL + const MY_STATIC: u32 = 0; | ||
| | ||
help: convert the identifier to upper case | ||
| | ||
LL - const LOL: u32 = my_static + 0; | ||
LL + const LOL: u32 = MY_STATIC + 0; | ||
| | ||
help: convert the identifier to upper case | ||
| | ||
LL - let _a = crate::my_static; | ||
LL + let _a = crate::MY_STATIC; |
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.
This seems pretty noisy. Could you convert this to a multipart suggestion?
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.
you could perhaps tweak the help:
to say something like "convert the identifier and its usages to upper case"
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.
Sure, converted a multipart suggestion.
EDIT: Didn't see your second message, will fix that tomorrow.
2589fe0
to
17f95ca
Compare
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.
I wonder if the original issue author meant "I ran cargo fix
/ cargo clippy --fix
" when they wrote "I applied the fixes suggested by clippy and rustc.".
I would probably mark the suggestions for usage sites as tool_only
, so they don't spam the terminal but still get applied automatically by rustfix.
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.
It's true that it doesn't bring much to show all of them and it can quickly become overwhelming. What do you think @compiler-errors ?
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.
Pushed a version with the suggestions as tool only, so they won't clutter the users terminal.
17f95ca
to
4df9f2f
Compare
compiler/rustc_lint/src/lints.rs
Outdated
#[suggestion( | ||
lint_suggestion, | ||
code = "{replace}", | ||
applicability = "maybe-incorrect", |
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.
Does cargo fix
actually apply maybe-incorrect suggestions? Or does it only apply machine-applicable ones? If cargo fix
doesn't actually end up auto-fixing these, I'm not sure if it's worth having them at all 🤔
Follow-up question: Why is it actually maybe-incorrect? Because of the existence of macros?
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.
I shameslly copied from the main suggestion NonUpperCaseGlobalSub
which also has maybe-incorrect
.
That's a very good point, cargo fix doesn't seems apply "maybe-incorrect" suggestions. (we are being tricked by compiletest/rustfix here)
Doing some archeology until #57387 doesn't reveal much why it's "maybe-incorrect" but if I had to guess I would say it's because it would lead to cargo fix
throwing a error that there now would be errors due to the other ones not being renamed ... but since we are now renaming the other ones I think it's fine to put it at "machine-applicable".
This PR currently collects use sites eagerly, i.e., before the indirect call to If this ends up perf heavy, it should be possible to turn this into a @bors2 try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Also emit suggestions for usages in the `non_upper_case_globals` lint This PR adds suggestions for all the usages of the renamed item in the warning of the `non_upper_case_globals` lint. Fixes #124061
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (4bb20cc): comparison URL. Overall result: ❌ regressions - please read the text belowBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 1.2%, secondary -4.2%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 30.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 692.606s -> 715.256s (3.27%) |
This PR adds suggestions for all the usages of the renamed item in the warning of the
non_upper_case_globals
lint.Fixes #124061