@@ -2513,11 +2513,11 @@ fn lint_chars_cmp_with_unwrap<'a, 'tcx>(
25132513 applicability,
25142514 ) ;
25152515
2516- return true ;
2516+ true
2517+ } else {
2518+ false
25172519 }
25182520 }
2519-
2520- false
25212521}
25222522
25232523/// Checks for the `CHARS_NEXT_CMP` lint with `unwrap()`.
@@ -2605,7 +2605,7 @@ fn ty_has_iter_method(
26052605 cx : & LateContext < ' _ , ' _ > ,
26062606 self_ref_ty : Ty < ' _ > ,
26072607) -> 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| {
26092609 let lint = if ty_name == "array" || ty_name == "PathBuf" {
26102610 INTO_ITER_ON_ARRAY
26112611 } else {
@@ -2619,10 +2619,8 @@ fn ty_has_iter_method(
26192619 hir:: MutImmutable => "iter" ,
26202620 hir:: MutMutable => "iter_mut" ,
26212621 } ;
2622- Some ( ( lint, ty_name, method_name) )
2623- } else {
2624- None
2625- }
2622+ ( lint, ty_name, method_name)
2623+ } )
26262624}
26272625
26282626fn 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) {
26572655
26582656/// Given a `Result<T, E>` type, return its error type (`E`).
26592657fn 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 ,
26682661 }
26692662}
26702663
0 commit comments