@@ -14,8 +14,9 @@ mod useless_attribute;
1414mod utils;
1515
1616use clippy_config:: Conf ;
17+ use clippy_utils:: diagnostics:: span_lint_and_help;
1718use clippy_utils:: msrvs:: { self , Msrv } ;
18- use rustc_ast:: { self as ast, Attribute , MetaItemInner , MetaItemKind } ;
19+ use rustc_ast:: { self as ast, AttrArgs , AttrKind , Attribute , MetaItemInner , MetaItemKind } ;
1920use rustc_hir:: { ImplItem , Item , TraitItem } ;
2021use rustc_lint:: { EarlyContext , EarlyLintPass , LateContext , LateLintPass } ;
2122use rustc_session:: impl_lint_pass;
@@ -448,6 +449,31 @@ declare_clippy_lint! {
448449 "duplicated attribute"
449450}
450451
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+ restriction,
474+ "ignored tests without messages"
475+ }
476+
451477pub struct Attributes {
452478 msrv : Msrv ,
453479}
@@ -534,6 +560,7 @@ impl_lint_pass!(PostExpansionEarlyAttributes => [
534560 ALLOW_ATTRIBUTES ,
535561 ALLOW_ATTRIBUTES_WITHOUT_REASON ,
536562 DEPRECATED_SEMVER ,
563+ IGNORE_WITHOUT_REASON ,
537564 USELESS_ATTRIBUTE ,
538565 BLANKET_CLIPPY_RESTRICTION_LINTS ,
539566 SHOULD_PANIC_WITHOUT_EXPECT ,
@@ -577,6 +604,22 @@ impl EarlyLintPass for PostExpansionEarlyAttributes {
577604 if attr. has_name ( sym:: should_panic) {
578605 should_panic_without_expect:: check ( cx, attr) ;
579606 }
607+
608+ if attr. has_name ( sym:: ignore)
609+ && match & attr. kind {
610+ AttrKind :: Normal ( normal_attr) => !matches ! ( normal_attr. item. args, AttrArgs :: Eq { .. } ) ,
611+ AttrKind :: DocComment ( ..) => true ,
612+ }
613+ {
614+ span_lint_and_help (
615+ cx,
616+ IGNORE_WITHOUT_REASON ,
617+ attr. span ,
618+ "`#[ignore]` without reason" ,
619+ None ,
620+ "add a reason with `= \" ..\" `" ,
621+ ) ;
622+ }
580623 }
581624
582625 fn check_item ( & mut self , cx : & EarlyContext < ' _ > , item : & ' _ ast:: Item ) {
0 commit comments