|
4 | 4 | use crate::lints::{
|
5 | 5 | BadOptAccessDiag, DefaultHashTypesDiag, DiagOutOfImpl, LintPassByHand, NonExistentDocKeyword,
|
6 | 6 | QueryInstability, SpanUseEqCtxtDiag, TyQualified, TykindDiag, TykindKind, UntranslatableDiag,
|
7 |
| - UntranslatableDiagnosticTrivial, |
8 | 7 | };
|
9 | 8 | use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext};
|
10 | 9 | use rustc_ast as ast;
|
@@ -361,15 +360,7 @@ declare_tool_lint! {
|
361 | 360 | report_in_external_macro: true
|
362 | 361 | }
|
363 | 362 |
|
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]); |
373 | 364 |
|
374 | 365 | impl LateLintPass<'_> for Diagnostics {
|
375 | 366 | fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
|
@@ -425,78 +416,6 @@ impl LateLintPass<'_> for Diagnostics {
|
425 | 416 | }
|
426 | 417 | }
|
427 | 418 |
|
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 |
| - |
500 | 419 | declare_tool_lint! {
|
501 | 420 | /// The `bad_opt_access` lint detects accessing options by field instead of
|
502 | 421 | /// the wrapper function.
|
|
0 commit comments