diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-03-06 22:02:46 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-06 22:02:46 +0100 |
| commit | efe9deace861039956aa182d8c17c38ef9ef2408 (patch) | |
| tree | b9854ba5f0310cbbc3dc518fadb2bb3d27785643 /src | |
| parent | c7fca03240dfba93363505bc9c6839a224cc8ca6 (diff) | |
| parent | 3591e77b3566772023b7e35e96224106243ef214 (diff) | |
| download | rust-efe9deace861039956aa182d8c17c38ef9ef2408.tar.gz rust-efe9deace861039956aa182d8c17c38ef9ef2408.zip | |
Rollup merge of #121382 - nnethercote:rework-untranslatable_diagnostic-lint, r=davidtwco
Rework `untranslatable_diagnostic` lint
Currently it only checks calls to functions marked with `#[rustc_lint_diagnostics]`. This PR changes it to check calls to any function with an `impl Into<{D,Subd}iagnosticMessage>` parameter. This greatly improves its coverage and doesn't rely on people remembering to add `#[rustc_lint_diagnostics]`. It also lets us add `#[rustc_lint_diagnostics]` to a number of functions that don't have an `impl Into<{D,Subd}iagnosticMessage>`, such as `Diag::span`.
r? ``@davidtwco``
Diffstat (limited to 'src')
| -rw-r--r-- | src/tools/rust-analyzer/crates/hir-ty/src/layout.rs | 5 | ||||
| -rw-r--r-- | src/tools/rustfmt/src/parse/session.rs | 1 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs b/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs index be1c8d9094b..a1be6018083 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs @@ -1,5 +1,6 @@ //! Compute the binary representation of a type +use std::borrow::Cow; use std::fmt; use base_db::salsa::Cycle; @@ -114,8 +115,8 @@ struct LayoutCx<'a> { impl<'a> LayoutCalculator for LayoutCx<'a> { type TargetDataLayoutRef = &'a TargetDataLayout; - fn delayed_bug(&self, txt: String) { - never!("{}", txt); + fn delayed_bug(&self, txt: impl Into<Cow<'static, str>>) { + never!("{}", txt.into()); } fn current_data_layout(&self) -> &'a TargetDataLayout { diff --git a/src/tools/rustfmt/src/parse/session.rs b/src/tools/rustfmt/src/parse/session.rs index 60a89a57536..cb46e65999d 100644 --- a/src/tools/rustfmt/src/parse/session.rs +++ b/src/tools/rustfmt/src/parse/session.rs @@ -360,6 +360,7 @@ mod tests { } fn build_diagnostic(level: DiagnosticLevel, span: Option<MultiSpan>) -> 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 { |
