@@ -31,17 +31,15 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
31
31
borrow_span : Span ,
32
32
borrow_desc : & str ,
33
33
) -> DiagnosticBuilder < ' tcx > {
34
- let mut err = struct_span_err ! (
34
+ struct_span_err ! (
35
35
self . dcx( ) ,
36
36
span,
37
37
E0503 ,
38
38
"cannot use {} because it was mutably borrowed" ,
39
39
desc,
40
- ) ;
41
-
42
- err. span_label ( borrow_span, format ! ( "{borrow_desc} is borrowed here" ) ) ;
43
- err. span_label ( span, format ! ( "use of borrowed {borrow_desc}" ) ) ;
44
- err
40
+ )
41
+ . span_label_mv ( borrow_span, format ! ( "{borrow_desc} is borrowed here" ) )
42
+ . span_label_mv ( span, format ! ( "use of borrowed {borrow_desc}" ) )
45
43
}
46
44
47
45
pub ( crate ) fn cannot_mutably_borrow_multiply (
@@ -238,17 +236,15 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
238
236
borrow_span : Span ,
239
237
desc : & str ,
240
238
) -> DiagnosticBuilder < ' cx > {
241
- let mut err = struct_span_err ! (
239
+ struct_span_err ! (
242
240
self . dcx( ) ,
243
241
span,
244
242
E0506 ,
245
243
"cannot assign to {} because it is borrowed" ,
246
244
desc,
247
- ) ;
248
-
249
- err. span_label ( borrow_span, format ! ( "{desc} is borrowed here" ) ) ;
250
- err. span_label ( span, format ! ( "{desc} is assigned to here but it was already borrowed" ) ) ;
251
- err
245
+ )
246
+ . span_label_mv ( borrow_span, format ! ( "{desc} is borrowed here" ) )
247
+ . span_label_mv ( span, format ! ( "{desc} is assigned to here but it was already borrowed" ) )
252
248
}
253
249
254
250
pub ( crate ) fn cannot_reassign_immutable (
@@ -287,32 +283,30 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
287
283
( & ty:: Slice ( _) , _) => "slice" ,
288
284
_ => span_bug ! ( move_from_span, "this path should not cause illegal move" ) ,
289
285
} ;
290
- let mut err = struct_span_err ! (
286
+ struct_span_err ! (
291
287
self . dcx( ) ,
292
288
move_from_span,
293
289
E0508 ,
294
290
"cannot move out of type `{}`, a non-copy {}" ,
295
291
ty,
296
292
type_name,
297
- ) ;
298
- err. span_label ( move_from_span, "cannot move out of here" ) ;
299
- err
293
+ )
294
+ . span_label_mv ( move_from_span, "cannot move out of here" )
300
295
}
301
296
302
297
pub ( crate ) fn cannot_move_out_of_interior_of_drop (
303
298
& self ,
304
299
move_from_span : Span ,
305
300
container_ty : Ty < ' _ > ,
306
301
) -> DiagnosticBuilder < ' cx > {
307
- let mut err = struct_span_err ! (
302
+ struct_span_err ! (
308
303
self . dcx( ) ,
309
304
move_from_span,
310
305
E0509 ,
311
306
"cannot move out of type `{}`, which implements the `Drop` trait" ,
312
307
container_ty,
313
- ) ;
314
- err. span_label ( move_from_span, "cannot move out of here" ) ;
315
- err
308
+ )
309
+ . span_label_mv ( move_from_span, "cannot move out of here" )
316
310
}
317
311
318
312
pub ( crate ) fn cannot_act_on_moved_value (
@@ -352,18 +346,17 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
352
346
immutable_section : & str ,
353
347
action : & str ,
354
348
) -> DiagnosticBuilder < ' tcx > {
355
- let mut err = struct_span_err ! (
349
+ struct_span_err ! (
356
350
self . dcx( ) ,
357
351
mutate_span,
358
352
E0510 ,
359
353
"cannot {} {} in {}" ,
360
354
action,
361
355
immutable_place,
362
356
immutable_section,
363
- ) ;
364
- err. span_label ( mutate_span, format ! ( "cannot {action}" ) ) ;
365
- err. span_label ( immutable_span, format ! ( "value is immutable in {immutable_section}" ) ) ;
366
- err
357
+ )
358
+ . span_label_mv ( mutate_span, format ! ( "cannot {action}" ) )
359
+ . span_label_mv ( immutable_span, format ! ( "value is immutable in {immutable_section}" ) )
367
360
}
368
361
369
362
pub ( crate ) fn cannot_borrow_across_coroutine_yield (
@@ -372,14 +365,13 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
372
365
yield_span : Span ,
373
366
) -> DiagnosticBuilder < ' tcx > {
374
367
let coroutine_kind = self . body . coroutine . as_ref ( ) . unwrap ( ) . coroutine_kind ;
375
- let mut err = struct_span_err ! (
368
+ struct_span_err ! (
376
369
self . dcx( ) ,
377
370
span,
378
371
E0626 ,
379
372
"borrow may still be in use when {coroutine_kind:#} yields" ,
380
- ) ;
381
- err. span_label ( yield_span, "possible yield occurs here" ) ;
382
- err
373
+ )
374
+ . span_label_mv ( yield_span, "possible yield occurs here" )
383
375
}
384
376
385
377
pub ( crate ) fn cannot_borrow_across_destructor (
@@ -409,22 +401,19 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
409
401
reference_desc : & str ,
410
402
path_desc : & str ,
411
403
) -> DiagnosticBuilder < ' tcx > {
412
- let mut err = struct_span_err ! (
404
+ struct_span_err ! (
413
405
self . dcx( ) ,
414
406
span,
415
407
E0515 ,
416
408
"cannot {RETURN} {REFERENCE} {LOCAL}" ,
417
409
RETURN = return_kind,
418
410
REFERENCE = reference_desc,
419
411
LOCAL = path_desc,
420
- ) ;
421
-
422
- err. span_label (
412
+ )
413
+ . span_label_mv (
423
414
span,
424
415
format ! ( "{return_kind}s a {reference_desc} data owned by the current function" ) ,
425
- ) ;
426
-
427
- err
416
+ )
428
417
}
429
418
430
419
pub ( crate ) fn cannot_capture_in_long_lived_closure (
@@ -435,16 +424,15 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
435
424
capture_span : Span ,
436
425
scope : & str ,
437
426
) -> DiagnosticBuilder < ' tcx > {
438
- let mut err = struct_span_err ! (
427
+ struct_span_err ! (
439
428
self . dcx( ) ,
440
429
closure_span,
441
430
E0373 ,
442
431
"{closure_kind} may outlive the current {scope}, but it borrows {borrowed_path}, \
443
432
which is owned by the current {scope}",
444
- ) ;
445
- err. span_label ( capture_span, format ! ( "{borrowed_path} is borrowed here" ) )
446
- . span_label ( closure_span, format ! ( "may outlive borrowed value {borrowed_path}" ) ) ;
447
- err
433
+ )
434
+ . span_label_mv ( capture_span, format ! ( "{borrowed_path} is borrowed here" ) )
435
+ . span_label_mv ( closure_span, format ! ( "may outlive borrowed value {borrowed_path}" ) )
448
436
}
449
437
450
438
pub ( crate ) fn thread_local_value_does_not_live_long_enough (
0 commit comments