@@ -31,17 +31,15 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
3131 borrow_span : Span ,
3232 borrow_desc : & str ,
3333 ) -> DiagnosticBuilder < ' tcx > {
34- let mut err = struct_span_err ! (
34+ struct_span_err ! (
3535 self . dcx( ) ,
3636 span,
3737 E0503 ,
3838 "cannot use {} because it was mutably borrowed" ,
3939 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}" ) )
4543 }
4644
4745 pub ( crate ) fn cannot_mutably_borrow_multiply (
@@ -238,17 +236,15 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
238236 borrow_span : Span ,
239237 desc : & str ,
240238 ) -> DiagnosticBuilder < ' cx > {
241- let mut err = struct_span_err ! (
239+ struct_span_err ! (
242240 self . dcx( ) ,
243241 span,
244242 E0506 ,
245243 "cannot assign to {} because it is borrowed" ,
246244 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" ) )
252248 }
253249
254250 pub ( crate ) fn cannot_reassign_immutable (
@@ -287,32 +283,30 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
287283 ( & ty:: Slice ( _) , _) => "slice" ,
288284 _ => span_bug ! ( move_from_span, "this path should not cause illegal move" ) ,
289285 } ;
290- let mut err = struct_span_err ! (
286+ struct_span_err ! (
291287 self . dcx( ) ,
292288 move_from_span,
293289 E0508 ,
294290 "cannot move out of type `{}`, a non-copy {}" ,
295291 ty,
296292 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" )
300295 }
301296
302297 pub ( crate ) fn cannot_move_out_of_interior_of_drop (
303298 & self ,
304299 move_from_span : Span ,
305300 container_ty : Ty < ' _ > ,
306301 ) -> DiagnosticBuilder < ' cx > {
307- let mut err = struct_span_err ! (
302+ struct_span_err ! (
308303 self . dcx( ) ,
309304 move_from_span,
310305 E0509 ,
311306 "cannot move out of type `{}`, which implements the `Drop` trait" ,
312307 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" )
316310 }
317311
318312 pub ( crate ) fn cannot_act_on_moved_value (
@@ -352,18 +346,17 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
352346 immutable_section : & str ,
353347 action : & str ,
354348 ) -> DiagnosticBuilder < ' tcx > {
355- let mut err = struct_span_err ! (
349+ struct_span_err ! (
356350 self . dcx( ) ,
357351 mutate_span,
358352 E0510 ,
359353 "cannot {} {} in {}" ,
360354 action,
361355 immutable_place,
362356 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}" ) )
367360 }
368361
369362 pub ( crate ) fn cannot_borrow_across_coroutine_yield (
@@ -372,14 +365,13 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
372365 yield_span : Span ,
373366 ) -> DiagnosticBuilder < ' tcx > {
374367 let coroutine_kind = self . body . coroutine . as_ref ( ) . unwrap ( ) . coroutine_kind ;
375- let mut err = struct_span_err ! (
368+ struct_span_err ! (
376369 self . dcx( ) ,
377370 span,
378371 E0626 ,
379372 "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" )
383375 }
384376
385377 pub ( crate ) fn cannot_borrow_across_destructor (
@@ -409,22 +401,19 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
409401 reference_desc : & str ,
410402 path_desc : & str ,
411403 ) -> DiagnosticBuilder < ' tcx > {
412- let mut err = struct_span_err ! (
404+ struct_span_err ! (
413405 self . dcx( ) ,
414406 span,
415407 E0515 ,
416408 "cannot {RETURN} {REFERENCE} {LOCAL}" ,
417409 RETURN = return_kind,
418410 REFERENCE = reference_desc,
419411 LOCAL = path_desc,
420- ) ;
421-
422- err. span_label (
412+ )
413+ . span_label_mv (
423414 span,
424415 format ! ( "{return_kind}s a {reference_desc} data owned by the current function" ) ,
425- ) ;
426-
427- err
416+ )
428417 }
429418
430419 pub ( crate ) fn cannot_capture_in_long_lived_closure (
@@ -435,16 +424,15 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
435424 capture_span : Span ,
436425 scope : & str ,
437426 ) -> DiagnosticBuilder < ' tcx > {
438- let mut err = struct_span_err ! (
427+ struct_span_err ! (
439428 self . dcx( ) ,
440429 closure_span,
441430 E0373 ,
442431 "{closure_kind} may outlive the current {scope}, but it borrows {borrowed_path}, \
443432 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}" ) )
448436 }
449437
450438 pub ( crate ) fn thread_local_value_does_not_live_long_enough (
0 commit comments