@@ -714,7 +714,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
714
714
_ => None ,
715
715
} ;
716
716
717
- let Some ( borrow_level) = borrow_level else { return false ; } ;
717
+ let Some ( borrow_level) = borrow_level else {
718
+ return false ;
719
+ } ;
718
720
let sugg = move_sites
719
721
. iter ( )
720
722
. map ( |move_site| {
@@ -763,7 +765,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
763
765
. typeck_root_def_id ( self . mir_def_id ( ) . to_def_id ( ) )
764
766
. as_local ( )
765
767
. and_then ( |def_id| tcx. hir ( ) . get_generics ( def_id) )
766
- else { return ; } ;
768
+ else {
769
+ return ;
770
+ } ;
767
771
// Try to find predicates on *generic params* that would allow copying `ty`
768
772
let ocx = ObligationCtxt :: new ( & self . infcx ) ;
769
773
let copy_did = tcx. require_lang_item ( LangItem :: Copy , Some ( span) ) ;
@@ -1220,18 +1224,20 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1220
1224
return ;
1221
1225
} ;
1222
1226
let inner_param_uses = find_all_local_uses:: find ( self . body , inner_param. local ) ;
1223
- let Some ( ( inner_call_loc, inner_call_term) ) = inner_param_uses. into_iter ( ) . find_map ( |loc| {
1224
- let Either :: Right ( term) = self . body . stmt_at ( loc) else {
1225
- debug ! ( "{:?} is a statement, so it can't be a call" , loc) ;
1226
- return None ;
1227
- } ;
1228
- let TerminatorKind :: Call { args, .. } = & term. kind else {
1229
- debug ! ( "not a call: {:?}" , term) ;
1230
- return None ;
1231
- } ;
1232
- debug ! ( "checking call args for uses of inner_param: {:?}" , args) ;
1233
- args. contains ( & Operand :: Move ( inner_param) ) . then_some ( ( loc, term) )
1234
- } ) else {
1227
+ let Some ( ( inner_call_loc, inner_call_term) ) =
1228
+ inner_param_uses. into_iter ( ) . find_map ( |loc| {
1229
+ let Either :: Right ( term) = self . body . stmt_at ( loc) else {
1230
+ debug ! ( "{:?} is a statement, so it can't be a call" , loc) ;
1231
+ return None ;
1232
+ } ;
1233
+ let TerminatorKind :: Call { args, .. } = & term. kind else {
1234
+ debug ! ( "not a call: {:?}" , term) ;
1235
+ return None ;
1236
+ } ;
1237
+ debug ! ( "checking call args for uses of inner_param: {:?}" , args) ;
1238
+ args. contains ( & Operand :: Move ( inner_param) ) . then_some ( ( loc, term) )
1239
+ } )
1240
+ else {
1235
1241
debug ! ( "no uses of inner_param found as a by-move call arg" ) ;
1236
1242
return ;
1237
1243
} ;
@@ -1442,21 +1448,24 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1442
1448
}
1443
1449
1444
1450
// Get closure's arguments
1445
- let ty:: Closure ( _, substs) = typeck_results. expr_ty ( closure_expr) . kind ( ) else { /* hir::Closure can be a generator too */ return } ;
1451
+ let ty:: Closure ( _, substs) = typeck_results. expr_ty ( closure_expr) . kind ( ) else {
1452
+ /* hir::Closure can be a generator too */
1453
+ return ;
1454
+ } ;
1446
1455
let sig = substs. as_closure ( ) . sig ( ) ;
1447
1456
let tupled_params =
1448
1457
tcx. erase_late_bound_regions ( sig. inputs ( ) . iter ( ) . next ( ) . unwrap ( ) . map_bound ( |& b| b) ) ;
1449
1458
let ty:: Tuple ( params) = tupled_params. kind ( ) else { return } ;
1450
1459
1451
1460
// Find the first argument with a matching type, get its name
1452
- let Some ( ( _, this_name) ) = params
1453
- . iter ( )
1454
- . zip ( hir. body_param_names ( closure. body ) )
1455
- . find ( |( param_ty, name) |{
1461
+ let Some ( ( _, this_name) ) =
1462
+ params. iter ( ) . zip ( hir. body_param_names ( closure. body ) ) . find ( |( param_ty, name) | {
1456
1463
// FIXME: also support deref for stuff like `Rc` arguments
1457
1464
param_ty. peel_refs ( ) == local_ty && name != & Ident :: empty ( )
1458
1465
} )
1459
- else { return } ;
1466
+ else {
1467
+ return ;
1468
+ } ;
1460
1469
1461
1470
let spans;
1462
1471
if let Some ( ( _path_expr, qpath) ) = finder. error_path
@@ -2899,7 +2908,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
2899
2908
{
2900
2909
let def_id = def_id. expect_local ( ) ;
2901
2910
for operand in operands {
2902
- let ( Operand :: Copy ( assigned_from) | Operand :: Move ( assigned_from) ) = operand else {
2911
+ let ( Operand :: Copy ( assigned_from) | Operand :: Move ( assigned_from) ) =
2912
+ operand
2913
+ else {
2903
2914
continue ;
2904
2915
} ;
2905
2916
debug ! (
@@ -2908,7 +2919,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
2908
2919
) ;
2909
2920
2910
2921
// Find the local from the operand.
2911
- let Some ( assigned_from_local) = assigned_from. local_or_deref_local ( ) else {
2922
+ let Some ( assigned_from_local) =
2923
+ assigned_from. local_or_deref_local ( )
2924
+ else {
2912
2925
continue ;
2913
2926
} ;
2914
2927
@@ -2961,7 +2974,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
2961
2974
) ;
2962
2975
2963
2976
// Find the local from the rvalue.
2964
- let Some ( assigned_from_local) = assigned_from. local_or_deref_local ( ) else { continue } ;
2977
+ let Some ( assigned_from_local) = assigned_from. local_or_deref_local ( ) else {
2978
+ continue ;
2979
+ } ;
2965
2980
debug ! (
2966
2981
"annotate_argument_and_return_for_borrow: \
2967
2982
assigned_from_local={:?}",
@@ -3009,7 +3024,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
3009
3024
assigned_to, args
3010
3025
) ;
3011
3026
for operand in args {
3012
- let ( Operand :: Copy ( assigned_from) | Operand :: Move ( assigned_from) ) = operand else {
3027
+ let ( Operand :: Copy ( assigned_from) | Operand :: Move ( assigned_from) ) = operand
3028
+ else {
3013
3029
continue ;
3014
3030
} ;
3015
3031
debug ! (
0 commit comments