Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework untranslatable_diagnostic lint #121382

Merged

Commits on Mar 5, 2024

  1. Change message type in bug functions.

    From `impl Into<DiagnosticMessage>` to `impl Into<Cow<'static, str>>`.
    
    Because these functions don't produce user-facing output and we don't
    want their strings to be translated.
    nnethercote committed Mar 5, 2024
    Configuration menu
    Copy the full SHA
    d602394 View commit details
    Browse the repository at this point in the history

Commits on Mar 6, 2024

  1. 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`.
    nnethercote committed Mar 6, 2024
    Configuration menu
    Copy the full SHA
    b7d58ee View commit details
    Browse the repository at this point in the history
  2. Add missing #[rustc_lint_diagnostics] attributes.

    Prior to the previous commit, `#[rust_lint_diagnostics]` attributes
    could only be used on methods with an `impl Into<{D,Subd}iagMessage>`
    parameter. But there are many other nearby diagnostic methods (e.g.
    `Diag::span`) that don't take such a parameter and should have the
    attribute.
    
    This commit adds the missing attribute to these `Diag` methods. This
    requires adding some missing
    `#[allow(rustc::diagnostic_outside_of_impl)]` markers at call sites to
    these methods.
    nnethercote committed Mar 6, 2024
    Configuration menu
    Copy the full SHA
    3591e77 View commit details
    Browse the repository at this point in the history