@@ -1345,11 +1345,13 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
13451345 // See `tests/ui/moves/needs-clone-through-deref.rs`
13461346 return false ;
13471347 }
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.
13491350 if self . in_move_closure ( expr) {
13501351 return false ;
13511352 }
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.
13531355 if let hir:: ExprKind :: Closure ( _) = expr. kind {
13541356 return false ;
13551357 }
@@ -1381,7 +1383,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
13811383 }
13821384 }
13831385 }
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)
13851388 if inner_expr. span . lo ( ) != expr. span . lo ( ) && !is_raw_ptr {
13861389 // Remove "(*" or "(&"
13871390 sugg. push ( ( expr. span . with_hi ( inner_expr. span . lo ( ) ) , String :: new ( ) ) ) ;
@@ -1553,8 +1556,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
15531556 let use_spans = self . move_spans ( place. as_ref ( ) , location) ;
15541557 let span = use_spans. var_or_use ( ) ;
15551558
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.
15581562 let mut err = self . cannot_use_when_mutably_borrowed (
15591563 span,
15601564 & self . describe_any_place ( place. as_ref ( ) ) ,
@@ -2480,7 +2484,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
24802484 if let hir:: ExprKind :: Closure ( closure) = ex. kind
24812485 && ex. span . contains ( self . borrow_span )
24822486 // 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).
24842489 && self . res . as_ref ( ) . map_or ( true , |( prev_res, _) | prev_res. span . contains ( ex. span ) )
24852490 {
24862491 self . res = Some ( ( ex, closure) ) ;
@@ -2733,7 +2738,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
27332738 /// cannot borrow `a.u` (via `a.u.z.c`) as immutable because it is also borrowed as
27342739 /// mutable (via `a.u.s.b`) [E0502]
27352740 /// ```
2736- pub ( crate ) fn describe_place_for_conflicting_borrow (
2741+ fn describe_place_for_conflicting_borrow (
27372742 & self ,
27382743 first_borrowed_place : Place < ' tcx > ,
27392744 second_borrowed_place : Place < ' tcx > ,
@@ -3188,8 +3193,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
31883193 /// misleading users in cases like `tests/ui/nll/borrowed-temporary-error.rs`.
31893194 /// We could expand the analysis to suggest hoising all of the relevant parts of
31903195 /// 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.
31933199 struct NestedStatementVisitor < ' tcx > {
31943200 span : Span ,
31953201 current : usize ,
@@ -3420,7 +3426,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
34203426 let ( sugg_span, suggestion) = match tcx. sess . source_map ( ) . span_to_snippet ( args_span) {
34213427 Ok ( string) => {
34223428 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`.
34243431 Some ( 5 )
34253432 } else if string. starts_with ( "gen" ) {
34263433 // `gen` is 3 chars long
@@ -3618,10 +3625,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
36183625 let stmt_kind =
36193626 self . body [ location. block ] . statements . get ( location. statement_index ) . map ( |s| & s. kind ) ;
36203627 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.
36253631 } else {
36263632 // If we are found a use of a.b.c which was in error, then we want to look for
36273633 // moves not only of a.b.c but also a.b and a.
@@ -3706,13 +3712,12 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
37063712 }
37073713 }
37083714 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.
37163721 while let Some ( location) = back_edge_stack. pop ( ) {
37173722 if dfs_iter ( & mut result, location, true ) {
37183723 continue ;
0 commit comments