@@ -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 , MsrvStack } ;
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}
@@ -530,6 +556,7 @@ impl_lint_pass!(PostExpansionEarlyAttributes => [
530556 ALLOW_ATTRIBUTES ,
531557 ALLOW_ATTRIBUTES_WITHOUT_REASON ,
532558 DEPRECATED_SEMVER ,
559+ IGNORE_WITHOUT_REASON ,
533560 USELESS_ATTRIBUTE ,
534561 BLANKET_CLIPPY_RESTRICTION_LINTS ,
535562 SHOULD_PANIC_WITHOUT_EXPECT ,
@@ -573,6 +600,22 @@ impl EarlyLintPass for PostExpansionEarlyAttributes {
573600 if attr. has_name ( sym:: should_panic) {
574601 should_panic_without_expect:: check ( cx, attr) ;
575602 }
603+
604+ if attr. has_name ( sym:: ignore)
605+ && match & attr. kind {
606+ AttrKind :: Normal ( normal_attr) => !matches ! ( normal_attr. item. args, AttrArgs :: Eq { .. } ) ,
607+ AttrKind :: DocComment ( ..) => true ,
608+ }
609+ {
610+ span_lint_and_help (
611+ cx,
612+ IGNORE_WITHOUT_REASON ,
613+ attr. span ,
614+ "`#[ignore]` without reason" ,
615+ None ,
616+ "add a reason with `= \" ..\" `" ,
617+ ) ;
618+ }
576619 }
577620
578621 fn check_item ( & mut self , cx : & EarlyContext < ' _ > , item : & ' _ ast:: Item ) {
0 commit comments