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:
parent
d602394827
commit
b7d58eef4b
35 changed files with 224 additions and 63 deletions
|
@ -1074,6 +1074,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
|||
/// of one item. Read the documentation of [`check_doc_inline`] for more information.
|
||||
///
|
||||
/// [`check_doc_inline`]: Self::check_doc_inline
|
||||
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
|
||||
fn check_doc_attrs(
|
||||
&self,
|
||||
attr: &Attribute,
|
||||
|
@ -1756,6 +1757,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
|||
}
|
||||
|
||||
/// Checks if the `#[repr]` attributes on `item` are valid.
|
||||
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
|
||||
fn check_repr(
|
||||
&self,
|
||||
attrs: &[Attribute],
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -114,6 +114,7 @@ fn find_item(id: ItemId, ctxt: &mut EntryContext<'_>) {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
|
||||
fn configure_main(tcx: TyCtxt<'_>, visitor: &EntryContext<'_>) -> Option<(DefId, EntryFnType)> {
|
||||
if let Some((def_id, _)) = visitor.start_fn {
|
||||
Some((def_id.to_def_id(), EntryFnType::Start))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue