@@ -305,23 +305,14 @@ fn is_call_max_min_pattern<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>)
305
305
OrdOrFloat ( & ' tcx PathSegment < ' tcx > ) ,
306
306
}
307
307
308
- fn extract_call_data ( e : ExprRef < ' _ > , is_first : bool ) -> Option < ( ExprRef < ' _ > , ExprRef < ' _ > , ExprRef < ' _ > , bool ) > {
309
- if let ExprKind :: Call ( inner_fn, & [ ref third, ref fourth] ) = & e. kind {
310
- Some ( ( inner_fn, third, fourth, is_first) )
311
- } else {
312
- None
313
- }
314
- }
315
-
316
308
fn check < ' tcx > (
317
309
cx : & LateContext < ' tcx > ,
318
310
outer_fn : ExprRef < ' tcx > ,
319
311
first : ExprRef < ' tcx > ,
320
312
second : ExprRef < ' tcx > ,
321
313
span : Span ,
322
314
) -> Option < ClampSuggestion < ' tcx > > {
323
- if let Ok ( ( inner_fn, third, fourth, is_first) ) =
324
- extract_call_data ( first, true ) . into_iter ( ) . chain ( extract_call_data ( second, false ) ) . exactly_one ( )
315
+ if let ExprKind :: Call ( inner_fn, & [ ref third, ref fourth] ) = & first. kind
325
316
&& let Some ( inner_seg) = segment ( cx, inner_fn)
326
317
&& let Some ( outer_seg) = segment ( cx, outer_fn) {
327
318
let third_is_const = constant ( cx, cx. typeck_results ( ) , simplify_kind ( third) ) . is_some ( ) ;
@@ -333,11 +324,7 @@ fn is_call_max_min_pattern<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>)
333
324
( false , true ) => ( input, new_arg) = ( third, fourth) ,
334
325
_ => return None ,
335
326
}
336
- let other_new_arg = if is_first {
337
- second
338
- } else {
339
- first
340
- } ;
327
+ let other_new_arg = second;
341
328
let is_float = cx. typeck_results ( ) . expr_ty_adjusted ( input) . is_floating_point ( ) ;
342
329
let min_max_suggestion = Some ( ClampSuggestion {
343
330
params : InputMinMax { input, min : other_new_arg, max : new_arg, is_float } ,
0 commit comments