@@ -687,11 +687,7 @@ fn never_loop_expr(expr: &Expr<'_>, main_loop_id: HirId) -> NeverLoopResult {
687
687
}
688
688
} ,
689
689
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 ) )
695
691
} ,
696
692
ExprKind :: InlineAsm ( ref asm) => asm
697
693
. operands
@@ -1882,11 +1878,7 @@ fn is_iterable_array<'tcx>(ty: Ty<'tcx>, cx: &LateContext<'tcx>) -> bool {
1882
1878
// IntoIterator is currently only implemented for array sizes <= 32 in rustc
1883
1879
match ty. kind {
1884
1880
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) )
1890
1882
} ,
1891
1883
_ => false ,
1892
1884
}
@@ -1899,11 +1891,7 @@ fn extract_expr_from_first_stmt<'tcx>(block: &Block<'tcx>) -> Option<&'tcx Expr<
1899
1891
return None ;
1900
1892
}
1901
1893
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)
1907
1895
} else {
1908
1896
None
1909
1897
}
@@ -2023,15 +2011,11 @@ impl<'a, 'tcx> Visitor<'tcx> for InitializeVisitor<'a, 'tcx> {
2023
2011
if let PatKind :: Binding ( .., ident, _) = local. pat . kind {
2024
2012
self . name = Some ( ident. name ) ;
2025
2013
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 ) {
2028
2015
VarState :: Warn
2029
2016
} else {
2030
2017
VarState :: Declared
2031
- }
2032
- } else {
2033
- VarState :: Declared
2034
- }
2018
+ } )
2035
2019
}
2036
2020
}
2037
2021
}
0 commit comments