Skip to content

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Urgau
Copy link
Member

@Urgau Urgau commented Jun 17, 2025

This PR adds suggestions for all the usages of the renamed item in the warning of the non_upper_case_globals lint.

Fixes #124061

@rustbot
Copy link
Collaborator

rustbot commented Jun 17, 2025

r? @fee1-dead

rustbot has assigned @fee1-dead.
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

@rustbot rustbot added 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 Jun 17, 2025
@Urgau Urgau force-pushed the usage-non_upper_case_globals branch from 2589fe0 to 17f95ca Compare June 17, 2025 22:07
@Urgau Urgau force-pushed the usage-non_upper_case_globals branch from 17f95ca to 4df9f2f Compare June 20, 2025 16:16
@fmease fmease self-assigned this Jun 20, 2025
@fmease
Copy link
Member

fmease commented Jun 20, 2025

This PR currently collects use sites eagerly, i.e., before the indirect call to lint_level which ultimately decides if the lint should be emitted or not. I wonder if this is noticeable perf-wise.

If this ends up perf heavy, it should be possible to turn this into a LintDiagnostic that computes these tool-only suggs lazily.

@bors2 try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Jun 20, 2025

⌛ Trying commit 09d0a73 with merge 4bb20cc

To cancel the try build, run the command @bors2 try cancel.

rust-bors bot added a commit that referenced this pull request Jun 20, 2025
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
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 20, 2025
@rust-bors
Copy link

rust-bors bot commented Jun 20, 2025

☀️ Try build successful (CI)
Build commit: 4bb20cc (4bb20cc8be9c984fb2d6235080e1f44f349e6b9f, parent: 9c4ff566babe632af5e30281a822d1ae9972873b)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (4bb20cc): comparison URL.

Overall result: ❌ regressions - please read the text below

Benchmarking 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 @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
41.4% [33.7%, 55.9%] 9
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 41.4% [33.7%, 55.9%] 9

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.

mean range count
Regressions ❌
(primary)
3.1% [3.1%, 3.1%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.7% [-0.7%, -0.7%] 1
Improvements ✅
(secondary)
-4.2% [-6.0%, -2.3%] 2
All ❌✅ (primary) 1.2% [-0.7%, 3.1%] 2

Cycles

Results (primary 30.3%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
34.0% [23.9%, 47.1%] 9
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.6% [-2.6%, -2.6%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 30.3% [-2.6%, 47.1%] 10

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 692.606s -> 715.256s (3.27%)
Artifact size: 372.01 MiB -> 372.00 MiB (-0.00%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jun 20, 2025
} else {
NonUpperCaseGlobalSub::Label { span: ident.span }
};

struct UsageCollector<'a, 'tcx> {
Copy link
Member

@fmease fmease Jun 21, 2025

Choose a reason for hiding this comment

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

Impl LintDiagnostic manually for NonUpperCaseGlobal (it can still remain translatable) and move the usage collection into decorate_lint. This way, we only collect usages when absolutely necessary which should fix perf.

Copy link
Member Author

Choose a reason for hiding this comment

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

I did something different I called opt_span_lint directly, and since we aren't supposed to (which I kind of disagree) I added a emit_span_lint_lazy to do that.

@fmease fmease 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 Jun 21, 2025
@Urgau
Copy link
Member Author

Urgau commented Jun 21, 2025

@bors2 try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Jun 21, 2025

⌛ Trying commit 3939316 with merge 5aafa84

To cancel the try build, run the command @bors2 try cancel.

rust-bors bot added a commit that referenced this pull request Jun 21, 2025
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
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 21, 2025
@rust-bors
Copy link

rust-bors bot commented Jun 21, 2025

☀️ Try build successful (CI)
Build commit: 5aafa84 (5aafa84b2abbb29683a7d7c5bc618fe756a406c5, parent: df4ad9e28b9fb973e244ebc65a8167a261b8f45e)

@rust-timer

This comment has been minimized.

@Urgau Urgau force-pushed the usage-non_upper_case_globals branch from 3939316 to 1b5ec3f Compare June 21, 2025 12:45
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (5aafa84): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking 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.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (primary -3.2%, secondary -2.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
5.4% [5.4%, 5.4%] 1
Improvements ✅
(primary)
-3.2% [-3.2%, -3.2%] 1
Improvements ✅
(secondary)
-3.3% [-6.8%, -2.1%] 11
All ❌✅ (primary) -3.2% [-3.2%, -3.2%] 1

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 689.042s -> 689.239s (0.03%)
Artifact size: 371.85 MiB -> 371.86 MiB (0.00%)

@rustbot rustbot removed S-waiting-on-perf Status: Waiting on a perf run to be completed. perf-regression Performance regression. labels Jun 21, 2025
@Urgau Urgau 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 Jun 21, 2025
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. 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.

Fix for non_upper_case_globals should replace all usages
6 participants