@@ -4,15 +4,16 @@ use clippy_utils::is_doc_hidden;
4
4
use clippy_utils:: msrvs:: { self , Msrv } ;
5
5
use clippy_utils:: source:: snippet_indent;
6
6
use itertools:: Itertools ;
7
- use rustc_ast:: attr;
8
7
use rustc_data_structures:: fx:: FxHashSet ;
9
8
use rustc_errors:: Applicability ;
10
9
use rustc_hir:: def:: { CtorKind , CtorOf , DefKind , Res } ;
11
10
use rustc_hir:: { Expr , ExprKind , Item , ItemKind , QPath , TyKind , VariantData } ;
12
11
use rustc_lint:: { LateContext , LateLintPass } ;
13
12
use rustc_session:: impl_lint_pass;
14
13
use rustc_span:: def_id:: LocalDefId ;
15
- use rustc_span:: { Span , sym} ;
14
+ use rustc_span:: Span ;
15
+ use rustc_attr_data_structures:: find_attr;
16
+ use rustc_attr_data_structures:: AttributeKind ;
16
17
17
18
declare_clippy_lint ! {
18
19
/// ### What it does
@@ -93,7 +94,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualNonExhaustive {
93
94
. then_some ( ( v. def_id , v. span ) )
94
95
} ) ;
95
96
if let Ok ( ( id, span) ) = iter. exactly_one ( )
96
- && !attr :: contains_name ( cx. tcx . hir_attrs ( item. hir_id ( ) ) , sym :: non_exhaustive )
97
+ && !find_attr ! ( cx. tcx. hir_attrs( item. hir_id( ) ) , AttributeKind :: NonExhaustive ( .. ) )
97
98
{
98
99
self . potential_enums . push ( ( item. owner_id . def_id , id, item. span , span) ) ;
99
100
}
@@ -113,10 +114,10 @@ impl<'tcx> LateLintPass<'tcx> for ManualNonExhaustive {
113
114
item. span ,
114
115
"this seems like a manual implementation of the non-exhaustive pattern" ,
115
116
|diag| {
116
- if let Some ( non_exhaustive ) =
117
- attr :: find_by_name ( cx. tcx . hir_attrs ( item. hir_id ( ) ) , sym :: non_exhaustive )
117
+ if let Some ( non_exhaustive_span ) =
118
+ find_attr ! ( cx. tcx. hir_attrs( item. hir_id( ) ) , AttributeKind :: NonExhaustive ( span ) => * span )
118
119
{
119
- diag. span_note ( non_exhaustive . span ( ) , "the struct is already non-exhaustive" ) ;
120
+ diag. span_note ( non_exhaustive_span , "the struct is already non-exhaustive" ) ;
120
121
} else {
121
122
let indent = snippet_indent ( cx, item. span ) . unwrap_or_default ( ) ;
122
123
diag. span_suggestion_verbose (
0 commit comments