From 677c1d805906bcd21f0dd48d044fee9323db7e74 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 20 Feb 2024 14:12:50 +1100 Subject: [PATCH] Rewrite the `untranslatable_diagnostic` lint. Currently it only checks calls to functions marked with `#[rustc_lint_diagnostics]`. This commit changes it to check calls to any function with an `impl Into<{D,Subd}iagMessage>` parameter. This greatly improves its coverage and doesn't rely on people remembering to add `#[rustc_lint_diagnostics]`. The commit also adds `#[allow(rustc::untranslatable_diagnostic)`] attributes to places that need it that are caught by the improved lint. These places that might be easy to convert to translatable diagnostics. Finally, it also: - Expands and corrects some comments. - Does some minor formatting improvements. - Adds missing `DecorateLint` cases to `tests/ui-fulldeps/internal-lints/diagnostics.rs`. --- src/parse/session.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/parse/session.rs b/src/parse/session.rs index 11af9860513..cf8120e9b09 100644 --- a/src/parse/session.rs +++ b/src/parse/session.rs @@ -383,6 +383,7 @@ fn emit_diagnostic(&mut self, _diag: DiagInner) { } fn build_diagnostic(level: DiagnosticLevel, span: Option) -> DiagInner { + #[allow(rustc::untranslatable_diagnostic)] // no translation needed for empty string let mut diag = DiagInner::new(level, ""); diag.messages.clear(); if let Some(span) = span {