@@ -4,15 +4,16 @@ use clippy_utils::is_doc_hidden;
44use clippy_utils:: msrvs:: { self , Msrv } ;
55use clippy_utils:: source:: snippet_indent;
66use itertools:: Itertools ;
7- use rustc_ast:: attr;
87use rustc_data_structures:: fx:: FxHashSet ;
98use rustc_errors:: Applicability ;
109use rustc_hir:: def:: { CtorKind , CtorOf , DefKind , Res } ;
1110use rustc_hir:: { Expr , ExprKind , Item , ItemKind , QPath , TyKind , VariantData } ;
1211use rustc_lint:: { LateContext , LateLintPass } ;
1312use rustc_session:: impl_lint_pass;
1413use 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 ;
1617
1718declare_clippy_lint ! {
1819 /// ### What it does
@@ -93,7 +94,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualNonExhaustive {
9394 . then_some ( ( v. def_id , v. span ) )
9495 } ) ;
9596 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 ( .. ) )
9798 {
9899 self . potential_enums . push ( ( item. owner_id . def_id , id, item. span , span) ) ;
99100 }
@@ -113,10 +114,10 @@ impl<'tcx> LateLintPass<'tcx> for ManualNonExhaustive {
113114 item. span ,
114115 "this seems like a manual implementation of the non-exhaustive pattern" ,
115116 |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 )
118119 {
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" ) ;
120121 } else {
121122 let indent = snippet_indent ( cx, item. span ) . unwrap_or_default ( ) ;
122123 diag. span_suggestion_verbose (
0 commit comments