1- use rustc_errors:: { struct_span_err, DiagnosticBuilder , DiagnosticId } ;
1+ use rustc_errors:: { struct_span_err, DiagnosticBuilder , DiagnosticId , ErrorReported } ;
22use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
33use rustc_span:: { MultiSpan , Span } ;
44
55impl < ' cx , ' tcx > crate :: MirBorrowckCtxt < ' cx , ' tcx > {
6- crate fn cannot_move_when_borrowed ( & self , span : Span , desc : & str ) -> DiagnosticBuilder < ' cx > {
6+ crate fn cannot_move_when_borrowed (
7+ & self ,
8+ span : Span ,
9+ desc : & str ,
10+ ) -> DiagnosticBuilder < ' cx , ErrorReported > {
711 struct_span_err ! ( self , span, E0505 , "cannot move out of {} because it is borrowed" , desc, )
812 }
913
@@ -13,7 +17,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
1317 desc : & str ,
1418 borrow_span : Span ,
1519 borrow_desc : & str ,
16- ) -> DiagnosticBuilder < ' cx > {
20+ ) -> DiagnosticBuilder < ' cx , ErrorReported > {
1721 let mut err = struct_span_err ! (
1822 self ,
1923 span,
@@ -32,7 +36,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
3236 span : Span ,
3337 verb : & str ,
3438 desc : & str ,
35- ) -> DiagnosticBuilder < ' cx > {
39+ ) -> DiagnosticBuilder < ' cx , ErrorReported > {
3640 struct_span_err ! (
3741 self ,
3842 span,
@@ -51,7 +55,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
5155 old_loan_span : Span ,
5256 old_opt_via : & str ,
5357 old_load_end_span : Option < Span > ,
54- ) -> DiagnosticBuilder < ' cx > {
58+ ) -> DiagnosticBuilder < ' cx , ErrorReported > {
5559 let via =
5660 |msg : & str | if msg. is_empty ( ) { "" . to_string ( ) } else { format ! ( " (via {})" , msg) } ;
5761 let mut err = struct_span_err ! (
@@ -99,7 +103,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
99103 desc : & str ,
100104 old_loan_span : Span ,
101105 old_load_end_span : Option < Span > ,
102- ) -> DiagnosticBuilder < ' cx > {
106+ ) -> DiagnosticBuilder < ' cx , ErrorReported > {
103107 let mut err = struct_span_err ! (
104108 self ,
105109 new_loan_span,
@@ -132,7 +136,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
132136 noun_old : & str ,
133137 old_opt_via : & str ,
134138 previous_end_span : Option < Span > ,
135- ) -> DiagnosticBuilder < ' cx > {
139+ ) -> DiagnosticBuilder < ' cx , ErrorReported > {
136140 let mut err = struct_span_err ! (
137141 self ,
138142 new_loan_span,
@@ -164,7 +168,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
164168 old_opt_via : & str ,
165169 previous_end_span : Option < Span > ,
166170 second_borrow_desc : & str ,
167- ) -> DiagnosticBuilder < ' cx > {
171+ ) -> DiagnosticBuilder < ' cx , ErrorReported > {
168172 let mut err = struct_span_err ! (
169173 self ,
170174 new_loan_span,
@@ -200,7 +204,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
200204 kind_old : & str ,
201205 msg_old : & str ,
202206 old_load_end_span : Option < Span > ,
203- ) -> DiagnosticBuilder < ' cx > {
207+ ) -> DiagnosticBuilder < ' cx , ErrorReported > {
204208 let via =
205209 |msg : & str | if msg. is_empty ( ) { "" . to_string ( ) } else { format ! ( " (via {})" , msg) } ;
206210 let mut err = struct_span_err ! (
@@ -243,7 +247,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
243247 span : Span ,
244248 borrow_span : Span ,
245249 desc : & str ,
246- ) -> DiagnosticBuilder < ' cx > {
250+ ) -> DiagnosticBuilder < ' cx , ErrorReported > {
247251 let mut err = struct_span_err ! (
248252 self ,
249253 span,
@@ -262,20 +266,20 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
262266 span : Span ,
263267 desc : & str ,
264268 is_arg : bool ,
265- ) -> DiagnosticBuilder < ' cx > {
269+ ) -> DiagnosticBuilder < ' cx , ErrorReported > {
266270 let msg = if is_arg { "to immutable argument" } else { "twice to immutable variable" } ;
267271 struct_span_err ! ( self , span, E0384 , "cannot assign {} {}" , msg, desc)
268272 }
269273
270- crate fn cannot_assign ( & self , span : Span , desc : & str ) -> DiagnosticBuilder < ' cx > {
274+ crate fn cannot_assign ( & self , span : Span , desc : & str ) -> DiagnosticBuilder < ' cx , ErrorReported > {
271275 struct_span_err ! ( self , span, E0594 , "cannot assign to {}" , desc)
272276 }
273277
274278 crate fn cannot_move_out_of (
275279 & self ,
276280 move_from_span : Span ,
277281 move_from_desc : & str ,
278- ) -> DiagnosticBuilder < ' cx > {
282+ ) -> DiagnosticBuilder < ' cx , ErrorReported > {
279283 struct_span_err ! ( self , move_from_span, E0507 , "cannot move out of {}" , move_from_desc, )
280284 }
281285
@@ -287,7 +291,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
287291 move_from_span : Span ,
288292 ty : Ty < ' _ > ,
289293 is_index : Option < bool > ,
290- ) -> DiagnosticBuilder < ' cx > {
294+ ) -> DiagnosticBuilder < ' cx , ErrorReported > {
291295 let type_name = match ( & ty. kind ( ) , is_index) {
292296 ( & ty:: Array ( _, _) , Some ( true ) ) | ( & ty:: Array ( _, _) , None ) => "array" ,
293297 ( & ty:: Slice ( _) , _) => "slice" ,
@@ -309,7 +313,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
309313 & self ,
310314 move_from_span : Span ,
311315 container_ty : Ty < ' _ > ,
312- ) -> DiagnosticBuilder < ' cx > {
316+ ) -> DiagnosticBuilder < ' cx , ErrorReported > {
313317 let mut err = struct_span_err ! (
314318 self ,
315319 move_from_span,
@@ -327,7 +331,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
327331 verb : & str ,
328332 optional_adverb_for_moved : & str ,
329333 moved_path : Option < String > ,
330- ) -> DiagnosticBuilder < ' tcx > {
334+ ) -> DiagnosticBuilder < ' tcx , ErrorReported > {
331335 let moved_path = moved_path. map ( |mp| format ! ( ": `{}`" , mp) ) . unwrap_or_default ( ) ;
332336
333337 struct_span_err ! (
@@ -346,7 +350,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
346350 span : Span ,
347351 path : & str ,
348352 reason : & str ,
349- ) -> DiagnosticBuilder < ' cx > {
353+ ) -> DiagnosticBuilder < ' cx , ErrorReported > {
350354 struct_span_err ! ( self , span, E0596 , "cannot borrow {} as mutable{}" , path, reason, )
351355 }
352356
@@ -357,7 +361,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
357361 immutable_place : & str ,
358362 immutable_section : & str ,
359363 action : & str ,
360- ) -> DiagnosticBuilder < ' cx > {
364+ ) -> DiagnosticBuilder < ' cx , ErrorReported > {
361365 let mut err = struct_span_err ! (
362366 self ,
363367 mutate_span,
@@ -376,7 +380,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
376380 & self ,
377381 span : Span ,
378382 yield_span : Span ,
379- ) -> DiagnosticBuilder < ' cx > {
383+ ) -> DiagnosticBuilder < ' cx , ErrorReported > {
380384 let mut err = struct_span_err ! (
381385 self ,
382386 span,
@@ -387,7 +391,10 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
387391 err
388392 }
389393
390- crate fn cannot_borrow_across_destructor ( & self , borrow_span : Span ) -> DiagnosticBuilder < ' cx > {
394+ crate fn cannot_borrow_across_destructor (
395+ & self ,
396+ borrow_span : Span ,
397+ ) -> DiagnosticBuilder < ' cx , ErrorReported > {
391398 struct_span_err ! (
392399 self ,
393400 borrow_span,
@@ -400,7 +407,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
400407 & self ,
401408 span : Span ,
402409 path : & str ,
403- ) -> DiagnosticBuilder < ' cx > {
410+ ) -> DiagnosticBuilder < ' cx , ErrorReported > {
404411 struct_span_err ! ( self , span, E0597 , "{} does not live long enough" , path, )
405412 }
406413
@@ -410,7 +417,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
410417 return_kind : & str ,
411418 reference_desc : & str ,
412419 path_desc : & str ,
413- ) -> DiagnosticBuilder < ' cx > {
420+ ) -> DiagnosticBuilder < ' cx , ErrorReported > {
414421 let mut err = struct_span_err ! (
415422 self ,
416423 span,
@@ -435,7 +442,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
435442 closure_kind : & str ,
436443 borrowed_path : & str ,
437444 capture_span : Span ,
438- ) -> DiagnosticBuilder < ' cx > {
445+ ) -> DiagnosticBuilder < ' cx , ErrorReported > {
439446 let mut err = struct_span_err ! (
440447 self ,
441448 closure_span,
@@ -454,11 +461,14 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
454461 crate fn thread_local_value_does_not_live_long_enough (
455462 & self ,
456463 span : Span ,
457- ) -> DiagnosticBuilder < ' cx > {
464+ ) -> DiagnosticBuilder < ' cx , ErrorReported > {
458465 struct_span_err ! ( self , span, E0712 , "thread-local variable borrowed past end of function" , )
459466 }
460467
461- crate fn temporary_value_borrowed_for_too_long ( & self , span : Span ) -> DiagnosticBuilder < ' cx > {
468+ crate fn temporary_value_borrowed_for_too_long (
469+ & self ,
470+ span : Span ,
471+ ) -> DiagnosticBuilder < ' cx , ErrorReported > {
462472 struct_span_err ! ( self , span, E0716 , "temporary value dropped while borrowed" , )
463473 }
464474
@@ -467,7 +477,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
467477 sp : S ,
468478 msg : & str ,
469479 code : DiagnosticId ,
470- ) -> DiagnosticBuilder < ' tcx > {
480+ ) -> DiagnosticBuilder < ' tcx , ErrorReported > {
471481 self . infcx . tcx . sess . struct_span_err_with_code ( sp, msg, code)
472482 }
473483}
@@ -476,7 +486,7 @@ crate fn borrowed_data_escapes_closure<'tcx>(
476486 tcx : TyCtxt < ' tcx > ,
477487 escape_span : Span ,
478488 escapes_from : & str ,
479- ) -> DiagnosticBuilder < ' tcx > {
489+ ) -> DiagnosticBuilder < ' tcx , ErrorReported > {
480490 struct_span_err ! (
481491 tcx. sess,
482492 escape_span,
0 commit comments