@@ -14,8 +14,9 @@ mod useless_attribute;
14
14
mod utils;
15
15
16
16
use clippy_config:: Conf ;
17
+ use clippy_utils:: diagnostics:: span_lint_and_help;
17
18
use clippy_utils:: msrvs:: { self , Msrv , MsrvStack } ;
18
- use rustc_ast:: { self as ast, Attribute , MetaItemInner , MetaItemKind } ;
19
+ use rustc_ast:: { self as ast, AttrArgs , AttrKind , Attribute , MetaItemInner , MetaItemKind } ;
19
20
use rustc_hir:: { ImplItem , Item , ItemKind , TraitItem } ;
20
21
use rustc_lint:: { EarlyContext , EarlyLintPass , LateContext , LateLintPass } ;
21
22
use rustc_session:: impl_lint_pass;
@@ -448,6 +449,31 @@ declare_clippy_lint! {
448
449
"duplicated attribute"
449
450
}
450
451
452
+ declare_clippy_lint ! {
453
+ /// ### What it does
454
+ /// Checks for ignored tests without messages.
455
+ ///
456
+ /// ### Why is this bad?
457
+ /// The reason for ignoring the test may not be obvious.
458
+ ///
459
+ /// ### Example
460
+ /// ```no_run
461
+ /// #[test]
462
+ /// #[ignore]
463
+ /// fn test() {}
464
+ /// ```
465
+ /// Use instead:
466
+ /// ```no_run
467
+ /// #[test]
468
+ /// #[ignore = "Some good reason"]
469
+ /// fn test() {}
470
+ /// ```
471
+ #[ clippy:: version = "1.85.0" ]
472
+ pub IGNORE_WITHOUT_REASON ,
473
+ pedantic,
474
+ "ignored tests without messages"
475
+ }
476
+
451
477
pub struct Attributes {
452
478
msrv : Msrv ,
453
479
}
@@ -532,6 +558,7 @@ impl_lint_pass!(PostExpansionEarlyAttributes => [
532
558
ALLOW_ATTRIBUTES ,
533
559
ALLOW_ATTRIBUTES_WITHOUT_REASON ,
534
560
DEPRECATED_SEMVER ,
561
+ IGNORE_WITHOUT_REASON ,
535
562
USELESS_ATTRIBUTE ,
536
563
BLANKET_CLIPPY_RESTRICTION_LINTS ,
537
564
SHOULD_PANIC_WITHOUT_EXPECT ,
@@ -575,6 +602,22 @@ impl EarlyLintPass for PostExpansionEarlyAttributes {
575
602
if attr. has_name ( sym:: should_panic) {
576
603
should_panic_without_expect:: check ( cx, attr) ;
577
604
}
605
+
606
+ if attr. has_name ( sym:: ignore)
607
+ && match & attr. kind {
608
+ AttrKind :: Normal ( normal_attr) => !matches ! ( normal_attr. item. args, AttrArgs :: Eq { .. } ) ,
609
+ AttrKind :: DocComment ( ..) => true ,
610
+ }
611
+ {
612
+ span_lint_and_help (
613
+ cx,
614
+ IGNORE_WITHOUT_REASON ,
615
+ attr. span ,
616
+ "`#[ignore]` without reason" ,
617
+ None ,
618
+ "add a reason with `= \" ..\" `" ,
619
+ ) ;
620
+ }
578
621
}
579
622
580
623
fn check_item ( & mut self , cx : & EarlyContext < ' _ > , item : & ' _ ast:: Item ) {
0 commit comments