@@ -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 , ItemKind , 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+ pedantic,
474+ "ignored tests without messages"
475+ }
476+
451477pub struct Attributes {
452478 msrv : Msrv ,
453479}
@@ -532,6 +558,7 @@ impl_lint_pass!(PostExpansionEarlyAttributes => [
532558 ALLOW_ATTRIBUTES ,
533559 ALLOW_ATTRIBUTES_WITHOUT_REASON ,
534560 DEPRECATED_SEMVER ,
561+ IGNORE_WITHOUT_REASON ,
535562 USELESS_ATTRIBUTE ,
536563 BLANKET_CLIPPY_RESTRICTION_LINTS ,
537564 SHOULD_PANIC_WITHOUT_EXPECT ,
@@ -575,6 +602,22 @@ impl EarlyLintPass for PostExpansionEarlyAttributes {
575602 if attr. has_name ( sym:: should_panic) {
576603 should_panic_without_expect:: check ( cx, attr) ;
577604 }
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+ }
578621 }
579622
580623 fn check_item ( & mut self , cx : & EarlyContext < ' _ > , item : & ' _ ast:: Item ) {
0 commit comments