@@ -1345,11 +1345,13 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
1345
1345
// See `tests/ui/moves/needs-clone-through-deref.rs`
1346
1346
return false ;
1347
1347
}
1348
- // We don't want to suggest `.clone()` in a move closure, since the value has already been captured.
1348
+ // We don't want to suggest `.clone()` in a move closure, since the value has already been
1349
+ // captured.
1349
1350
if self . in_move_closure ( expr) {
1350
1351
return false ;
1351
1352
}
1352
- // We also don't want to suggest cloning a closure itself, since the value has already been captured.
1353
+ // We also don't want to suggest cloning a closure itself, since the value has already been
1354
+ // captured.
1353
1355
if let hir:: ExprKind :: Closure ( _) = expr. kind {
1354
1356
return false ;
1355
1357
}
@@ -1381,7 +1383,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
1381
1383
}
1382
1384
}
1383
1385
}
1384
- // Cloning the raw pointer doesn't make sense in some cases and would cause a type mismatch error. (see #126863)
1386
+ // Cloning the raw pointer doesn't make sense in some cases and would cause a type mismatch
1387
+ // error. (see #126863)
1385
1388
if inner_expr. span . lo ( ) != expr. span . lo ( ) && !is_raw_ptr {
1386
1389
// Remove "(*" or "(&"
1387
1390
sugg. push ( ( expr. span . with_hi ( inner_expr. span . lo ( ) ) , String :: new ( ) ) ) ;
@@ -1553,8 +1556,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
1553
1556
let use_spans = self . move_spans ( place. as_ref ( ) , location) ;
1554
1557
let span = use_spans. var_or_use ( ) ;
1555
1558
1556
- // If the attempted use is in a closure then we do not care about the path span of the place we are currently trying to use
1557
- // we call `var_span_label` on `borrow_spans` to annotate if the existing borrow was in a closure
1559
+ // If the attempted use is in a closure then we do not care about the path span of the
1560
+ // place we are currently trying to use we call `var_span_label` on `borrow_spans` to
1561
+ // annotate if the existing borrow was in a closure.
1558
1562
let mut err = self . cannot_use_when_mutably_borrowed (
1559
1563
span,
1560
1564
& self . describe_any_place ( place. as_ref ( ) ) ,
@@ -2480,7 +2484,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
2480
2484
if let hir:: ExprKind :: Closure ( closure) = ex. kind
2481
2485
&& ex. span . contains ( self . borrow_span )
2482
2486
// To support cases like `|| { v.call(|this| v.get()) }`
2483
- // FIXME: actually support such cases (need to figure out how to move from the capture place to original local)
2487
+ // FIXME: actually support such cases (need to figure out how to move from the
2488
+ // capture place to original local).
2484
2489
&& self . res . as_ref ( ) . map_or ( true , |( prev_res, _) | prev_res. span . contains ( ex. span ) )
2485
2490
{
2486
2491
self . res = Some ( ( ex, closure) ) ;
@@ -2733,7 +2738,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
2733
2738
/// cannot borrow `a.u` (via `a.u.z.c`) as immutable because it is also borrowed as
2734
2739
/// mutable (via `a.u.s.b`) [E0502]
2735
2740
/// ```
2736
- pub ( crate ) fn describe_place_for_conflicting_borrow (
2741
+ fn describe_place_for_conflicting_borrow (
2737
2742
& self ,
2738
2743
first_borrowed_place : Place < ' tcx > ,
2739
2744
second_borrowed_place : Place < ' tcx > ,
@@ -3188,8 +3193,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
3188
3193
/// misleading users in cases like `tests/ui/nll/borrowed-temporary-error.rs`.
3189
3194
/// We could expand the analysis to suggest hoising all of the relevant parts of
3190
3195
/// the users' code to make the code compile, but that could be too much.
3191
- /// We found the `prop_expr` by the way to check whether the expression is a `FormatArguments`,
3192
- /// which is a special case since it's generated by the compiler.
3196
+ /// We found the `prop_expr` by the way to check whether the expression is a
3197
+ /// `FormatArguments`, which is a special case since it's generated by the
3198
+ /// compiler.
3193
3199
struct NestedStatementVisitor < ' tcx > {
3194
3200
span : Span ,
3195
3201
current : usize ,
@@ -3420,7 +3426,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
3420
3426
let ( sugg_span, suggestion) = match tcx. sess . source_map ( ) . span_to_snippet ( args_span) {
3421
3427
Ok ( string) => {
3422
3428
let coro_prefix = if string. starts_with ( "async" ) {
3423
- // `async` is 5 chars long. Not using `.len()` to avoid the cast from `usize` to `u32`
3429
+ // `async` is 5 chars long. Not using `.len()` to avoid the cast from `usize`
3430
+ // to `u32`.
3424
3431
Some ( 5 )
3425
3432
} else if string. starts_with ( "gen" ) {
3426
3433
// `gen` is 3 chars long
@@ -3618,10 +3625,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
3618
3625
let stmt_kind =
3619
3626
self . body [ location. block ] . statements . get ( location. statement_index ) . map ( |s| & s. kind ) ;
3620
3627
if let Some ( StatementKind :: StorageDead ( ..) ) = stmt_kind {
3621
- // this analysis only tries to find moves explicitly
3622
- // written by the user, so we ignore the move-outs
3623
- // created by `StorageDead` and at the beginning
3624
- // of a function.
3628
+ // This analysis only tries to find moves explicitly written by the user, so we
3629
+ // ignore the move-outs created by `StorageDead` and at the beginning of a
3630
+ // function.
3625
3631
} else {
3626
3632
// If we are found a use of a.b.c which was in error, then we want to look for
3627
3633
// moves not only of a.b.c but also a.b and a.
@@ -3706,13 +3712,12 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
3706
3712
}
3707
3713
}
3708
3714
if ( is_argument || !reached_start) && result. is_empty ( ) {
3709
- /* Process back edges (moves in future loop iterations) only if
3710
- the move path is definitely initialized upon loop entry,
3711
- to avoid spurious "in previous iteration" errors.
3712
- During DFS, if there's a path from the error back to the start
3713
- of the function with no intervening init or move, then the
3714
- move path may be uninitialized at loop entry.
3715
- */
3715
+ // Process back edges (moves in future loop iterations) only if
3716
+ // the move path is definitely initialized upon loop entry,
3717
+ // to avoid spurious "in previous iteration" errors.
3718
+ // During DFS, if there's a path from the error back to the start
3719
+ // of the function with no intervening init or move, then the
3720
+ // move path may be uninitialized at loop entry.
3716
3721
while let Some ( location) = back_edge_stack. pop ( ) {
3717
3722
if dfs_iter ( & mut result, location, true ) {
3718
3723
continue ;
0 commit comments