@@ -687,11 +687,7 @@ fn never_loop_expr(expr: &Expr<'_>, main_loop_id: HirId) -> NeverLoopResult {
687687 }
688688 } ,
689689 ExprKind :: Break ( _, ref e) | ExprKind :: Ret ( ref e) => {
690- if let Some ( ref e) = * e {
691- combine_seq ( never_loop_expr ( e, main_loop_id) , NeverLoopResult :: AlwaysBreak )
692- } else {
693- NeverLoopResult :: AlwaysBreak
694- }
690+ e. as_ref ( ) . map_or ( NeverLoopResult :: AlwaysBreak , |e| combine_seq ( never_loop_expr ( e, main_loop_id) , NeverLoopResult :: AlwaysBreak ) )
695691 } ,
696692 ExprKind :: InlineAsm ( ref asm) => asm
697693 . operands
@@ -1882,11 +1878,7 @@ fn is_iterable_array<'tcx>(ty: Ty<'tcx>, cx: &LateContext<'tcx>) -> bool {
18821878 // IntoIterator is currently only implemented for array sizes <= 32 in rustc
18831879 match ty. kind {
18841880 ty:: Array ( _, n) => {
1885- if let Some ( val) = n. try_eval_usize ( cx. tcx , cx. param_env ) {
1886- ( 0 ..=32 ) . contains ( & val)
1887- } else {
1888- false
1889- }
1881+ n. try_eval_usize ( cx. tcx , cx. param_env ) . map_or ( false , |val| ( 0 ..=32 ) . contains ( & val) )
18901882 } ,
18911883 _ => false ,
18921884 }
@@ -1899,11 +1891,7 @@ fn extract_expr_from_first_stmt<'tcx>(block: &Block<'tcx>) -> Option<&'tcx Expr<
18991891 return None ;
19001892 }
19011893 if let StmtKind :: Local ( ref local) = block. stmts [ 0 ] . kind {
1902- if let Some ( expr) = local. init {
1903- Some ( expr)
1904- } else {
1905- None
1906- }
1894+ local. init . map ( |expr| expr)
19071895 } else {
19081896 None
19091897 }
@@ -2023,15 +2011,11 @@ impl<'a, 'tcx> Visitor<'tcx> for InitializeVisitor<'a, 'tcx> {
20232011 if let PatKind :: Binding ( .., ident, _) = local. pat . kind {
20242012 self . name = Some ( ident. name ) ;
20252013
2026- self . state = if let Some ( ref init) = local. init {
2027- if is_integer_const ( & self . cx , init, 0 ) {
2014+ self . state = local. init . as_ref ( ) . map_or ( VarState :: Declared , |init| if is_integer_const ( & self . cx , init, 0 ) {
20282015 VarState :: Warn
20292016 } else {
20302017 VarState :: Declared
2031- }
2032- } else {
2033- VarState :: Declared
2034- }
2018+ } )
20352019 }
20362020 }
20372021 }
0 commit comments