Skip to content

Commit 87c1afb

Browse files
authored
Rollup merge of rust-lang#121423 - nnethercote:rm-UntranslatableDiagnosticTrivial, r=davidtwco
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. r? ``@davidtwco``
2 parents 6f87759 + 69b68e2 commit 87c1afb

File tree

4 files changed

+1
-88
lines changed

4 files changed

+1
-88
lines changed

compiler/rustc_lint/src/internal.rs

+1-82
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
use crate::lints::{
55
BadOptAccessDiag, DefaultHashTypesDiag, DiagOutOfImpl, LintPassByHand, NonExistentDocKeyword,
66
QueryInstability, SpanUseEqCtxtDiag, TyQualified, TykindDiag, TykindKind, UntranslatableDiag,
7-
UntranslatableDiagnosticTrivial,
87
};
98
use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext};
109
use rustc_ast as ast;
@@ -361,15 +360,7 @@ declare_tool_lint! {
361360
report_in_external_macro: true
362361
}
363362

364-
declare_tool_lint! {
365-
/// The `untranslatable_diagnostic_trivial` lint detects diagnostics created using only static strings.
366-
pub rustc::UNTRANSLATABLE_DIAGNOSTIC_TRIVIAL,
367-
Deny,
368-
"prevent creation of diagnostics which cannot be translated, which use only static strings",
369-
report_in_external_macro: true
370-
}
371-
372-
declare_lint_pass!(Diagnostics => [ UNTRANSLATABLE_DIAGNOSTIC, DIAGNOSTIC_OUTSIDE_OF_IMPL, UNTRANSLATABLE_DIAGNOSTIC_TRIVIAL ]);
363+
declare_lint_pass!(Diagnostics => [UNTRANSLATABLE_DIAGNOSTIC, DIAGNOSTIC_OUTSIDE_OF_IMPL]);
373364

374365
impl LateLintPass<'_> for Diagnostics {
375366
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
@@ -425,78 +416,6 @@ impl LateLintPass<'_> for Diagnostics {
425416
}
426417
}
427418

428-
impl EarlyLintPass for Diagnostics {
429-
#[allow(unused_must_use)]
430-
fn check_stmt(&mut self, cx: &EarlyContext<'_>, stmt: &ast::Stmt) {
431-
// Looking for a straight chain of method calls from 'struct_span_err' to 'emit'.
432-
let ast::StmtKind::Semi(expr) = &stmt.kind else {
433-
return;
434-
};
435-
let ast::ExprKind::MethodCall(meth) = &expr.kind else {
436-
return;
437-
};
438-
if meth.seg.ident.name != sym::emit || !meth.args.is_empty() {
439-
return;
440-
}
441-
let mut segments = vec![];
442-
let mut cur = &meth.receiver;
443-
let fake = &[].into();
444-
loop {
445-
match &cur.kind {
446-
ast::ExprKind::Call(func, args) => {
447-
if let ast::ExprKind::Path(_, path) = &func.kind {
448-
segments.push((path.segments.last().unwrap().ident.name, args))
449-
}
450-
break;
451-
}
452-
ast::ExprKind::MethodCall(method) => {
453-
segments.push((method.seg.ident.name, &method.args));
454-
cur = &method.receiver;
455-
}
456-
ast::ExprKind::MacCall(mac) => {
457-
segments.push((mac.path.segments.last().unwrap().ident.name, fake));
458-
break;
459-
}
460-
_ => {
461-
break;
462-
}
463-
}
464-
}
465-
segments.reverse();
466-
if segments.is_empty() {
467-
return;
468-
}
469-
if segments[0].0.as_str() != "struct_span_err" {
470-
return;
471-
}
472-
if !segments.iter().all(|(name, args)| {
473-
let arg = match name.as_str() {
474-
"struct_span_err" | "span_note" | "span_label" | "span_help" if args.len() == 2 => {
475-
&args[1]
476-
}
477-
"note" | "help" if args.len() == 1 => &args[0],
478-
_ => {
479-
return false;
480-
}
481-
};
482-
if let ast::ExprKind::Lit(lit) = arg.kind
483-
&& let ast::token::LitKind::Str = lit.kind
484-
{
485-
true
486-
} else {
487-
false
488-
}
489-
}) {
490-
return;
491-
}
492-
cx.emit_span_lint(
493-
UNTRANSLATABLE_DIAGNOSTIC_TRIVIAL,
494-
stmt.span,
495-
UntranslatableDiagnosticTrivial,
496-
);
497-
}
498-
}
499-
500419
declare_tool_lint! {
501420
/// The `bad_opt_access` lint detects accessing options by field instead of
502421
/// the wrapper function.

compiler/rustc_lint/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,6 @@ fn register_internals(store: &mut LintStore) {
550550
store.register_lints(&TyTyKind::get_lints());
551551
store.register_late_mod_pass(|_| Box::new(TyTyKind));
552552
store.register_lints(&Diagnostics::get_lints());
553-
store.register_early_pass(|| Box::new(Diagnostics));
554553
store.register_late_mod_pass(|_| Box::new(Diagnostics));
555554
store.register_lints(&BadOptAccess::get_lints());
556555
store.register_late_mod_pass(|_| Box::new(BadOptAccess));

compiler/rustc_lint/src/lints.rs

-4
Original file line numberDiff line numberDiff line change
@@ -923,10 +923,6 @@ pub struct DiagOutOfImpl;
923923
#[diag(lint_untranslatable_diag)]
924924
pub struct UntranslatableDiag;
925925

926-
#[derive(LintDiagnostic)]
927-
#[diag(lint_trivial_untranslatable_diag)]
928-
pub struct UntranslatableDiagnosticTrivial;
929-
930926
#[derive(LintDiagnostic)]
931927
#[diag(lint_bad_opt_access)]
932928
pub struct BadOptAccessDiag<'a> {

src/tools/clippy/clippy_config/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
clippy::missing_panics_doc,
77
rustc::diagnostic_outside_of_impl,
88
rustc::untranslatable_diagnostic,
9-
rustc::untranslatable_diagnostic_trivial,
109
)]
1110

1211
extern crate rustc_ast;

0 commit comments

Comments
 (0)