@@ -13,7 +13,7 @@ use rustc_hir::{
13
13
QPath , TraitItemRef , TyKind ,
14
14
} ;
15
15
use rustc_lint:: { LateContext , LateLintPass } ;
16
- use rustc_middle:: ty:: { self , AssocKind , FnSig , Ty } ;
16
+ use rustc_middle:: ty:: { self , FnSig , Ty } ;
17
17
use rustc_session:: declare_lint_pass;
18
18
use rustc_span:: source_map:: Spanned ;
19
19
use rustc_span:: symbol:: sym;
@@ -300,11 +300,7 @@ fn check_trait_items(cx: &LateContext<'_>, visited_trait: &Item<'_>, ident: Iden
300
300
let is_empty_method_found = current_and_super_traits
301
301
. items ( )
302
302
. flat_map ( |& i| cx. tcx . associated_items ( i) . filter_by_name_unhygienic ( is_empty) )
303
- . any ( |i| {
304
- i. kind == AssocKind :: Fn
305
- && i. fn_has_self_parameter
306
- && cx. tcx . fn_sig ( i. def_id ) . skip_binder ( ) . inputs ( ) . skip_binder ( ) . len ( ) == 1
307
- } ) ;
303
+ . any ( |i| i. is_method ( ) && cx. tcx . fn_sig ( i. def_id ) . skip_binder ( ) . inputs ( ) . skip_binder ( ) . len ( ) == 1 ) ;
308
304
309
305
if !is_empty_method_found {
310
306
span_lint (
@@ -482,7 +478,7 @@ fn check_for_is_empty(
482
478
. inherent_impls ( impl_ty)
483
479
. iter ( )
484
480
. flat_map ( |& id| cx. tcx . associated_items ( id) . filter_by_name_unhygienic ( is_empty) )
485
- . find ( |item| item. kind == AssocKind :: Fn ) ;
481
+ . find ( |item| item. is_fn ( ) ) ;
486
482
487
483
let ( msg, is_empty_span, self_kind) = match is_empty {
488
484
None => (
@@ -502,7 +498,7 @@ fn check_for_is_empty(
502
498
None ,
503
499
) ,
504
500
Some ( is_empty)
505
- if !( is_empty. fn_has_self_parameter
501
+ if !( is_empty. is_method ( )
506
502
&& check_is_empty_sig (
507
503
cx,
508
504
cx. tcx . fn_sig ( is_empty. def_id ) . instantiate_identity ( ) . skip_binder ( ) ,
@@ -626,7 +622,7 @@ fn is_empty_array(expr: &Expr<'_>) -> bool {
626
622
fn has_is_empty ( cx : & LateContext < ' _ > , expr : & Expr < ' _ > ) -> bool {
627
623
/// Gets an `AssocItem` and return true if it matches `is_empty(self)`.
628
624
fn is_is_empty ( cx : & LateContext < ' _ > , item : & ty:: AssocItem ) -> bool {
629
- if item. kind == AssocKind :: Fn {
625
+ if item. is_fn ( ) {
630
626
let sig = cx. tcx . fn_sig ( item. def_id ) . skip_binder ( ) ;
631
627
let ty = sig. skip_binder ( ) ;
632
628
ty. inputs ( ) . len ( ) == 1
@@ -662,7 +658,7 @@ fn has_is_empty(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
662
658
&& cx. tcx . get_diagnostic_item ( sym:: Deref ) . is_some_and ( |deref_id| {
663
659
implements_trait ( cx, ty, deref_id, & [ ] )
664
660
&& cx
665
- . get_associated_type ( ty, deref_id, " Target" )
661
+ . get_associated_type ( ty, deref_id, sym :: Target )
666
662
. is_some_and ( |deref_ty| ty_has_is_empty ( cx, deref_ty, depth + 1 ) )
667
663
} ) )
668
664
} ,
0 commit comments