Rollup merge of #142645 - Urgau:usage-non_upper_case_globals, r=fmease

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 https://github.com/rust-lang/rust/issues/124061
This commit is contained in:
Matthias Krüger
2025-06-24 20:46:03 +02:00
committed by GitHub
6 changed files with 252 additions and 15 deletions

View File

@@ -1353,6 +1353,8 @@ pub(crate) struct NonUpperCaseGlobal<'a> {
pub name: &'a str,
#[subdiagnostic]
pub sub: NonUpperCaseGlobalSub,
#[subdiagnostic]
pub usages: Vec<NonUpperCaseGlobalSubTool>,
}
#[derive(Subdiagnostic)]
@@ -1362,14 +1364,29 @@ pub(crate) enum NonUpperCaseGlobalSub {
#[primary_span]
span: Span,
},
#[suggestion(lint_suggestion, code = "{replace}", applicability = "maybe-incorrect")]
#[suggestion(lint_suggestion, code = "{replace}")]
Suggestion {
#[primary_span]
span: Span,
#[applicability]
applicability: Applicability,
replace: String,
},
}
#[derive(Subdiagnostic)]
#[suggestion(
lint_suggestion,
code = "{replace}",
applicability = "machine-applicable",
style = "tool-only"
)]
pub(crate) struct NonUpperCaseGlobalSubTool {
#[primary_span]
pub(crate) span: Span,
pub(crate) replace: String,
}
// noop_method_call.rs
#[derive(LintDiagnostic)]
#[diag(lint_noop_method_call)]