@@ -3,11 +3,11 @@ use clippy_utils::consts::{ConstEvalCtxt, Constant};
33use clippy_utils:: diagnostics:: { span_lint_and_then, span_lint_hir_and_then} ;
44use clippy_utils:: higher:: If ;
55use clippy_utils:: msrvs:: { self , Msrv } ;
6- use clippy_utils:: res:: { MaybeDef , MaybeResPath } ;
6+ use clippy_utils:: res:: { MaybeDef , MaybeResPath , MaybeTypeckRes } ;
77use clippy_utils:: sugg:: Sugg ;
88use clippy_utils:: ty:: implements_trait;
99use clippy_utils:: visitors:: is_const_evaluatable;
10- use clippy_utils:: { eq_expr_value, is_in_const_context, is_trait_method , peel_blocks, peel_blocks_with_stmt, sym} ;
10+ use clippy_utils:: { eq_expr_value, is_in_const_context, peel_blocks, peel_blocks_with_stmt, sym} ;
1111use itertools:: Itertools ;
1212use rustc_errors:: { Applicability , Diag } ;
1313use rustc_hir:: def:: Res ;
@@ -290,10 +290,12 @@ fn is_if_elseif_else_pattern<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx
290290/// # ;
291291/// ```
292292fn is_max_min_pattern < ' tcx > ( cx : & LateContext < ' tcx > , expr : & ' tcx Expr < ' tcx > ) -> Option < ClampSuggestion < ' tcx > > {
293- if let ExprKind :: MethodCall ( seg_second, receiver, [ arg_second] , _) = & expr. kind
294- && ( cx. typeck_results ( ) . expr_ty_adjusted ( receiver) . is_floating_point ( ) || is_trait_method ( cx, expr, sym:: Ord ) )
293+ if let ExprKind :: MethodCall ( seg_second, receiver, [ arg_second] , _) = expr. kind
294+ && ( cx. typeck_results ( ) . expr_ty_adjusted ( receiver) . is_floating_point ( )
295+ || cx. ty_based_def ( expr) . assoc_fn_parent ( cx) . is_diag_item ( cx, sym:: Ord ) )
295296 && let ExprKind :: MethodCall ( seg_first, input, [ arg_first] , _) = & receiver. kind
296- && ( cx. typeck_results ( ) . expr_ty_adjusted ( input) . is_floating_point ( ) || is_trait_method ( cx, receiver, sym:: Ord ) )
297+ && ( cx. typeck_results ( ) . expr_ty_adjusted ( input) . is_floating_point ( )
298+ || cx. ty_based_def ( receiver) . assoc_fn_parent ( cx) . is_diag_item ( cx, sym:: Ord ) )
297299 {
298300 let is_float = cx. typeck_results ( ) . expr_ty_adjusted ( input) . is_floating_point ( ) ;
299301 let ( min, max) = match ( seg_first. ident . name , seg_second. ident . name ) {
0 commit comments