@@ -2513,11 +2513,11 @@ fn lint_chars_cmp_with_unwrap<'a, 'tcx>(
2513
2513
applicability,
2514
2514
) ;
2515
2515
2516
- return true ;
2516
+ true
2517
+ } else {
2518
+ false
2517
2519
}
2518
2520
}
2519
-
2520
- false
2521
2521
}
2522
2522
2523
2523
/// Checks for the `CHARS_NEXT_CMP` lint with `unwrap()`.
@@ -2605,7 +2605,7 @@ fn ty_has_iter_method(
2605
2605
cx : & LateContext < ' _ , ' _ > ,
2606
2606
self_ref_ty : Ty < ' _ > ,
2607
2607
) -> Option < ( & ' static Lint , & ' static str , & ' static str ) > {
2608
- if let Some ( ty_name ) = has_iter_method ( cx, self_ref_ty) {
2608
+ has_iter_method ( cx, self_ref_ty) . map ( |ty_name| {
2609
2609
let lint = if ty_name == "array" || ty_name == "PathBuf" {
2610
2610
INTO_ITER_ON_ARRAY
2611
2611
} else {
@@ -2619,10 +2619,8 @@ fn ty_has_iter_method(
2619
2619
hir:: MutImmutable => "iter" ,
2620
2620
hir:: MutMutable => "iter_mut" ,
2621
2621
} ;
2622
- Some ( ( lint, ty_name, method_name) )
2623
- } else {
2624
- None
2625
- }
2622
+ ( lint, ty_name, method_name)
2623
+ } )
2626
2624
}
2627
2625
2628
2626
fn lint_into_iter ( cx : & LateContext < ' _ , ' _ > , expr : & hir:: Expr , self_ref_ty : Ty < ' _ > , method_span : Span ) {
@@ -2657,14 +2655,9 @@ fn lint_suspicious_map(cx: &LateContext<'_, '_>, expr: &hir::Expr) {
2657
2655
2658
2656
/// Given a `Result<T, E>` type, return its error type (`E`).
2659
2657
fn get_error_type < ' a > ( cx : & LateContext < ' _ , ' _ > , ty : Ty < ' a > ) -> Option < Ty < ' a > > {
2660
- if let ty:: Adt ( _, substs) = ty. sty {
2661
- if match_type ( cx, ty, & paths:: RESULT ) {
2662
- substs. types ( ) . nth ( 1 )
2663
- } else {
2664
- None
2665
- }
2666
- } else {
2667
- None
2658
+ match ty. sty {
2659
+ ty:: Adt ( _, substs) if match_type ( cx, ty, & paths:: RESULT ) => substs. types ( ) . nth ( 1 ) ,
2660
+ _ => None ,
2668
2661
}
2669
2662
}
2670
2663
0 commit comments