1
1
use clippy_utils:: diagnostics:: { span_lint_and_help, span_lint_and_sugg, span_lint_and_then} ;
2
2
use clippy_utils:: source:: { snippet, snippet_with_context} ;
3
3
use clippy_utils:: sugg:: { DiagExt as _, Sugg } ;
4
- use clippy_utils:: ty:: { is_copy, is_type_diagnostic_item, same_type_and_consts} ;
4
+ use clippy_utils:: ty:: { get_type_diagnostic_name , is_copy, is_type_diagnostic_item, same_type_and_consts} ;
5
5
use clippy_utils:: {
6
6
get_parent_expr, is_inherent_method_call, is_trait_item, is_trait_method, is_ty_alias, path_to_local,
7
7
} ;
@@ -13,7 +13,7 @@ use rustc_infer::traits::Obligation;
13
13
use rustc_lint:: { LateContext , LateLintPass } ;
14
14
use rustc_middle:: traits:: ObligationCause ;
15
15
use rustc_middle:: ty:: adjustment:: { Adjust , AutoBorrow , AutoBorrowMutability } ;
16
- use rustc_middle:: ty:: { self , AdtDef , EarlyBinder , GenericArg , GenericArgsRef , Ty , TypeVisitableExt } ;
16
+ use rustc_middle:: ty:: { self , EarlyBinder , GenericArg , GenericArgsRef , Ty , TypeVisitableExt } ;
17
17
use rustc_session:: impl_lint_pass;
18
18
use rustc_span:: { Span , sym} ;
19
19
use rustc_trait_selection:: traits:: query:: evaluate_obligation:: InferCtxtExt ;
@@ -412,24 +412,14 @@ pub fn check_function_application(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &
412
412
}
413
413
414
414
fn has_eligible_receiver ( cx : & LateContext < ' _ > , recv : & Expr < ' _ > , expr : & Expr < ' _ > ) -> bool {
415
- let recv_ty = cx. typeck_results ( ) . expr_ty ( recv) ;
416
- if is_inherent_method_call ( cx, expr)
417
- && let Some ( recv_ty_defid) = recv_ty. ty_adt_def ( ) . map ( AdtDef :: did)
418
- {
419
- if let Some ( diag_name) = cx. tcx . get_diagnostic_name ( recv_ty_defid)
420
- && matches ! ( diag_name, sym:: Option | sym:: Result )
421
- {
422
- return true ;
423
- }
424
-
425
- if cx. tcx . is_diagnostic_item ( sym:: ControlFlow , recv_ty_defid) {
426
- return true ;
427
- }
428
- }
429
- if is_trait_method ( cx, expr, sym:: Iterator ) {
430
- return true ;
415
+ if is_inherent_method_call ( cx, expr) {
416
+ matches ! (
417
+ get_type_diagnostic_name( cx, cx. typeck_results( ) . expr_ty( recv) ) ,
418
+ Some ( sym:: Option | sym:: Result | sym:: ControlFlow )
419
+ )
420
+ } else {
421
+ is_trait_method ( cx, expr, sym:: Iterator )
431
422
}
432
- false
433
423
}
434
424
435
425
fn adjustments ( cx : & LateContext < ' _ > , expr : & Expr < ' _ > ) -> String {
0 commit comments