@@ -170,7 +170,7 @@ fn live_node_kind_to_string(lnk: LiveNodeKind, tcx: TyCtxt<'_, '_, '_>) -> Strin
170170 VarDefNode ( s) => {
171171 format ! ( "Var def node [{}]" , cm. span_to_string( s) )
172172 }
173- ExitNode => "Exit node" . to_string ( ) ,
173+ ExitNode => "Exit node" . to_owned ( ) ,
174174 }
175175}
176176
@@ -330,7 +330,7 @@ impl<'a, 'tcx> IrMaps<'a, 'tcx> {
330330 Local ( LocalInfo { name, .. } ) | Arg ( _, name) => {
331331 name. to_string ( )
332332 } ,
333- CleanExit => "<clean-exit>" . to_string ( )
333+ CleanExit => "<clean-exit>" . to_owned ( )
334334 }
335335 }
336336
@@ -1049,12 +1049,9 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
10491049
10501050 // the construction of a closure itself is not important,
10511051 // but we have to consider the closed over variables.
1052- let caps = match self . ir . capture_info_map . get ( & expr. id ) {
1053- Some ( caps) => caps. clone ( ) ,
1054- None => {
1055- span_bug ! ( expr. span, "no registered caps" ) ;
1056- }
1057- } ;
1052+ let caps = self . ir . capture_info_map . get ( & expr. id ) . cloned ( ) . unwrap_or_else ( ||
1053+ span_bug ! ( expr. span, "no registered caps" ) ) ;
1054+
10581055 caps. iter ( ) . rev ( ) . fold ( succ, |succ, cap| {
10591056 self . init_from_succ ( cap. ln , succ) ;
10601057 let var = self . variable ( cap. var_hid , expr. span ) ;
@@ -1114,15 +1111,12 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
11141111 self . init_empty ( ln, succ) ;
11151112 let mut first_merge = true ;
11161113 for arm in arms {
1117- let body_succ =
1118- self . propagate_through_expr ( & arm. body , succ) ;
1119- let guard_succ =
1120- self . propagate_through_opt_expr (
1121- arm. guard . as_ref ( ) . map ( |g|
1122- match g {
1123- hir:: Guard :: If ( e) => & * * e,
1124- } ) ,
1125- body_succ) ;
1114+ let body_succ = self . propagate_through_expr ( & arm. body , succ) ;
1115+
1116+ let guard_succ = self . propagate_through_opt_expr (
1117+ arm. guard . as_ref ( ) . map ( |hir:: Guard :: If ( e) | & * * e) ,
1118+ body_succ
1119+ ) ;
11261120 // only consider the first pattern; any later patterns must have
11271121 // the same bindings, and we also consider the first pattern to be
11281122 // the "authoritative" set of ids
@@ -1146,10 +1140,9 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
11461140 let target = match label. target_id {
11471141 Ok ( node_id) => self . break_ln . get ( & node_id) ,
11481142 Err ( err) => span_bug ! ( expr. span, "loop scope error: {}" , err) ,
1149- } . map ( |x| * x) ;
1150-
11511143 // Now that we know the label we're going to,
11521144 // look it up in the break loop nodes table
1145+ } . cloned ( ) ;
11531146
11541147 match target {
11551148 Some ( b) => self . propagate_through_opt_expr ( opt_expr. as_ref ( ) . map ( |e| & * * e) , b) ,
@@ -1159,18 +1152,13 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
11591152
11601153 hir:: ExprKind :: Continue ( label) => {
11611154 // Find which label this expr continues to
1162- let sc = match label. target_id {
1163- Ok ( node_id) => node_id,
1164- Err ( err) => span_bug ! ( expr. span, "loop scope error: {}" , err) ,
1165- } ;
1155+ let sc = label. target_id . unwrap_or_else ( |err|
1156+ span_bug ! ( expr. span, "loop scope error: {}" , err) ) ;
11661157
11671158 // Now that we know the label we're going to,
11681159 // look it up in the continue loop nodes table
1169-
1170- match self . cont_ln . get ( & sc) {
1171- Some ( & b) => b,
1172- None => span_bug ! ( expr. span, "continue to unknown label" )
1173- }
1160+ self . cont_ln . get ( & sc) . cloned ( ) . unwrap_or_else ( ||
1161+ span_bug ! ( expr. span, "continue to unknown label" ) )
11741162 }
11751163
11761164 hir:: ExprKind :: Assign ( ref l, ref r) => {
@@ -1450,8 +1438,8 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
14501438 self . propagate_through_expr ( & cond, ln)
14511439 }
14521440 } ;
1453- assert ! ( cond_ln == new_cond_ln) ;
1454- assert ! ( body_ln == self . propagate_through_block( body, cond_ln) ) ;
1441+ assert_eq ! ( cond_ln, new_cond_ln) ;
1442+ assert_eq ! ( body_ln, self . propagate_through_block( body, cond_ln) ) ;
14551443 }
14561444
14571445 cond_ln
@@ -1576,7 +1564,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
15761564
15771565 fn should_warn ( & self , var : Variable ) -> Option < String > {
15781566 let name = self . ir . variable_name ( var) ;
1579- if name. is_empty ( ) || name. as_bytes ( ) [ 0 ] == ( '_' as u8 ) {
1567+ if name. is_empty ( ) || name. as_bytes ( ) [ 0 ] == b '_' {
15801568 None
15811569 } else {
15821570 Some ( name)
0 commit comments