about summary refs log tree commit diff
path: root/compiler/rustc_lint/src/internal.rs
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2024-02-05 16:27:53 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2024-02-28 10:53:04 +1100
commit5e29e26b96a397be6cf982cfa7fd334e24ed61c1 (patch)
tree4d6fb9c457fd65e2cab0ad7849127d1c969fb132 /compiler/rustc_lint/src/internal.rs
parentef324565d071c6d7e2477a195648549e33d6a465 (diff)
downloadrust-5e29e26b96a397be6cf982cfa7fd334e24ed61c1.tar.gz
rust-5e29e26b96a397be6cf982cfa7fd334e24ed61c1.zip
Remove the `UntranslatableDiagnosticTrivial` lint.
It's a specialized form of the `UntranslatableDiagnostic` lint that is
deny-by-default.

Now that `UntranslatableDiagnostic` has been changed from
allow-by-default to deny-by-default, the trivial variant is no longer
needed.
Diffstat (limited to 'compiler/rustc_lint/src/internal.rs')
-rw-r--r--compiler/rustc_lint/src/internal.rs83
1 files changed, 1 insertions, 82 deletions
diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs
index 596221a8455..a071fa488bc 100644
--- a/compiler/rustc_lint/src/internal.rs
+++ b/compiler/rustc_lint/src/internal.rs
@@ -4,7 +4,6 @@
 use crate::lints::{
     BadOptAccessDiag, DefaultHashTypesDiag, DiagOutOfImpl, LintPassByHand, NonExistentDocKeyword,
     QueryInstability, SpanUseEqCtxtDiag, TyQualified, TykindDiag, TykindKind, UntranslatableDiag,
-    UntranslatableDiagnosticTrivial,
 };
 use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext};
 use rustc_ast as ast;
@@ -361,15 +360,7 @@ declare_tool_lint! {
     report_in_external_macro: true
 }
 
-declare_tool_lint! {
-    /// The `untranslatable_diagnostic_trivial` lint detects diagnostics created using only static strings.
-    pub rustc::UNTRANSLATABLE_DIAGNOSTIC_TRIVIAL,
-    Deny,
-    "prevent creation of diagnostics which cannot be translated, which use only static strings",
-    report_in_external_macro: true
-}
-
-declare_lint_pass!(Diagnostics => [ UNTRANSLATABLE_DIAGNOSTIC, DIAGNOSTIC_OUTSIDE_OF_IMPL, UNTRANSLATABLE_DIAGNOSTIC_TRIVIAL ]);
+declare_lint_pass!(Diagnostics => [UNTRANSLATABLE_DIAGNOSTIC, DIAGNOSTIC_OUTSIDE_OF_IMPL]);
 
 impl LateLintPass<'_> for Diagnostics {
     fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
@@ -425,78 +416,6 @@ impl LateLintPass<'_> for Diagnostics {
     }
 }
 
-impl EarlyLintPass for Diagnostics {
-    #[allow(unused_must_use)]
-    fn check_stmt(&mut self, cx: &EarlyContext<'_>, stmt: &ast::Stmt) {
-        // Looking for a straight chain of method calls from 'struct_span_err' to 'emit'.
-        let ast::StmtKind::Semi(expr) = &stmt.kind else {
-            return;
-        };
-        let ast::ExprKind::MethodCall(meth) = &expr.kind else {
-            return;
-        };
-        if meth.seg.ident.name != sym::emit || !meth.args.is_empty() {
-            return;
-        }
-        let mut segments = vec![];
-        let mut cur = &meth.receiver;
-        let fake = &[].into();
-        loop {
-            match &cur.kind {
-                ast::ExprKind::Call(func, args) => {
-                    if let ast::ExprKind::Path(_, path) = &func.kind {
-                        segments.push((path.segments.last().unwrap().ident.name, args))
-                    }
-                    break;
-                }
-                ast::ExprKind::MethodCall(method) => {
-                    segments.push((method.seg.ident.name, &method.args));
-                    cur = &method.receiver;
-                }
-                ast::ExprKind::MacCall(mac) => {
-                    segments.push((mac.path.segments.last().unwrap().ident.name, fake));
-                    break;
-                }
-                _ => {
-                    break;
-                }
-            }
-        }
-        segments.reverse();
-        if segments.is_empty() {
-            return;
-        }
-        if segments[0].0.as_str() != "struct_span_err" {
-            return;
-        }
-        if !segments.iter().all(|(name, args)| {
-            let arg = match name.as_str() {
-                "struct_span_err" | "span_note" | "span_label" | "span_help" if args.len() == 2 => {
-                    &args[1]
-                }
-                "note" | "help" if args.len() == 1 => &args[0],
-                _ => {
-                    return false;
-                }
-            };
-            if let ast::ExprKind::Lit(lit) = arg.kind
-                && let ast::token::LitKind::Str = lit.kind
-            {
-                true
-            } else {
-                false
-            }
-        }) {
-            return;
-        }
-        cx.emit_span_lint(
-            UNTRANSLATABLE_DIAGNOSTIC_TRIVIAL,
-            stmt.span,
-            UntranslatableDiagnosticTrivial,
-        );
-    }
-}
-
 declare_tool_lint! {
     /// The `bad_opt_access` lint detects accessing options by field instead of
     /// the wrapper function.