1
Fork 0

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`.
This commit is contained in:
Nicholas Nethercote 2024-02-20 14:12:50 +11:00
parent d602394827
commit b7d58eef4b
35 changed files with 224 additions and 63 deletions

View file

@ -77,6 +77,7 @@ impl<'tcx> CheckConstVisitor<'tcx> {
}
/// Emits an error when an unsupported expression is found in a const context.
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
fn const_check_violated(&self, expr: NonConstExpr, span: Span) {
let Self { tcx, def_id, const_kind } = *self;