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

@@ -524,6 +524,20 @@ pub trait LintContext {
});
}
/// Emit a lint at `span` from a lazily-constructed lint struct (some type that implements
/// `LintDiagnostic`, typically generated by `#[derive(LintDiagnostic)]`).
fn emit_span_lint_lazy<S: Into<MultiSpan>, L: for<'a> LintDiagnostic<'a, ()>>(
&self,
lint: &'static Lint,
span: S,
decorator: impl FnOnce() -> L,
) {
self.opt_span_lint(lint, Some(span), |lint| {
let decorator = decorator();
decorator.decorate_lint(lint);
});
}
/// Emit a lint at the appropriate level, with an associated span.
///
/// [`lint_level`]: rustc_middle::lint::lint_level#decorate-signature