1
- use rustc_errors::{struct_span_err, DiagnosticBuilder, DiagnosticId, ErrorReported };
1
+ use rustc_errors::{struct_span_err, DiagnosticBuilder, DiagnosticId, ErrorGuaranteed };
2
2
use rustc_middle::ty::{self, Ty, TyCtxt};
3
3
use rustc_span::{MultiSpan, Span};
4
4
@@ -7,7 +7,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
7
7
&self,
8
8
span: Span,
9
9
desc: &str,
10
- ) -> DiagnosticBuilder<'cx, ErrorReported > {
10
+ ) -> DiagnosticBuilder<'cx, ErrorGuaranteed > {
11
11
struct_span_err!(self, span, E0505, "cannot move out of {} because it is borrowed", desc,)
12
12
}
13
13
@@ -17,7 +17,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
17
17
desc: &str,
18
18
borrow_span: Span,
19
19
borrow_desc: &str,
20
- ) -> DiagnosticBuilder<'cx, ErrorReported > {
20
+ ) -> DiagnosticBuilder<'cx, ErrorGuaranteed > {
21
21
let mut err = struct_span_err!(
22
22
self,
23
23
span,
@@ -36,7 +36,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
36
36
span: Span,
37
37
verb: &str,
38
38
desc: &str,
39
- ) -> DiagnosticBuilder<'cx, ErrorReported > {
39
+ ) -> DiagnosticBuilder<'cx, ErrorGuaranteed > {
40
40
struct_span_err!(
41
41
self,
42
42
span,
@@ -55,7 +55,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
55
55
old_loan_span: Span,
56
56
old_opt_via: &str,
57
57
old_load_end_span: Option<Span>,
58
- ) -> DiagnosticBuilder<'cx, ErrorReported > {
58
+ ) -> DiagnosticBuilder<'cx, ErrorGuaranteed > {
59
59
let via =
60
60
|msg: &str| if msg.is_empty() { "".to_string() } else { format!(" (via {})", msg) };
61
61
let mut err = struct_span_err!(
@@ -103,7 +103,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
103
103
desc: &str,
104
104
old_loan_span: Span,
105
105
old_load_end_span: Option<Span>,
106
- ) -> DiagnosticBuilder<'cx, ErrorReported > {
106
+ ) -> DiagnosticBuilder<'cx, ErrorGuaranteed > {
107
107
let mut err = struct_span_err!(
108
108
self,
109
109
new_loan_span,
@@ -136,7 +136,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
136
136
noun_old: &str,
137
137
old_opt_via: &str,
138
138
previous_end_span: Option<Span>,
139
- ) -> DiagnosticBuilder<'cx, ErrorReported > {
139
+ ) -> DiagnosticBuilder<'cx, ErrorGuaranteed > {
140
140
let mut err = struct_span_err!(
141
141
self,
142
142
new_loan_span,
@@ -168,7 +168,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
168
168
old_opt_via: &str,
169
169
previous_end_span: Option<Span>,
170
170
second_borrow_desc: &str,
171
- ) -> DiagnosticBuilder<'cx, ErrorReported > {
171
+ ) -> DiagnosticBuilder<'cx, ErrorGuaranteed > {
172
172
let mut err = struct_span_err!(
173
173
self,
174
174
new_loan_span,
@@ -204,7 +204,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
204
204
kind_old: &str,
205
205
msg_old: &str,
206
206
old_load_end_span: Option<Span>,
207
- ) -> DiagnosticBuilder<'cx, ErrorReported > {
207
+ ) -> DiagnosticBuilder<'cx, ErrorGuaranteed > {
208
208
let via =
209
209
|msg: &str| if msg.is_empty() { "".to_string() } else { format!(" (via {})", msg) };
210
210
let mut err = struct_span_err!(
@@ -247,7 +247,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
247
247
span: Span,
248
248
borrow_span: Span,
249
249
desc: &str,
250
- ) -> DiagnosticBuilder<'cx, ErrorReported > {
250
+ ) -> DiagnosticBuilder<'cx, ErrorGuaranteed > {
251
251
let mut err = struct_span_err!(
252
252
self,
253
253
span,
@@ -266,20 +266,24 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
266
266
span: Span,
267
267
desc: &str,
268
268
is_arg: bool,
269
- ) -> DiagnosticBuilder<'cx, ErrorReported > {
269
+ ) -> DiagnosticBuilder<'cx, ErrorGuaranteed > {
270
270
let msg = if is_arg { "to immutable argument" } else { "twice to immutable variable" };
271
271
struct_span_err!(self, span, E0384, "cannot assign {} {}", msg, desc)
272
272
}
273
273
274
- crate fn cannot_assign(&self, span: Span, desc: &str) -> DiagnosticBuilder<'cx, ErrorReported> {
274
+ crate fn cannot_assign(
275
+ &self,
276
+ span: Span,
277
+ desc: &str,
278
+ ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
275
279
struct_span_err!(self, span, E0594, "cannot assign to {}", desc)
276
280
}
277
281
278
282
crate fn cannot_move_out_of(
279
283
&self,
280
284
move_from_span: Span,
281
285
move_from_desc: &str,
282
- ) -> DiagnosticBuilder<'cx, ErrorReported > {
286
+ ) -> DiagnosticBuilder<'cx, ErrorGuaranteed > {
283
287
struct_span_err!(self, move_from_span, E0507, "cannot move out of {}", move_from_desc,)
284
288
}
285
289
@@ -291,7 +295,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
291
295
move_from_span: Span,
292
296
ty: Ty<'_>,
293
297
is_index: Option<bool>,
294
- ) -> DiagnosticBuilder<'cx, ErrorReported > {
298
+ ) -> DiagnosticBuilder<'cx, ErrorGuaranteed > {
295
299
let type_name = match (&ty.kind(), is_index) {
296
300
(&ty::Array(_, _), Some(true)) | (&ty::Array(_, _), None) => "array",
297
301
(&ty::Slice(_), _) => "slice",
@@ -313,7 +317,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
313
317
&self,
314
318
move_from_span: Span,
315
319
container_ty: Ty<'_>,
316
- ) -> DiagnosticBuilder<'cx, ErrorReported > {
320
+ ) -> DiagnosticBuilder<'cx, ErrorGuaranteed > {
317
321
let mut err = struct_span_err!(
318
322
self,
319
323
move_from_span,
@@ -331,7 +335,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
331
335
verb: &str,
332
336
optional_adverb_for_moved: &str,
333
337
moved_path: Option<String>,
334
- ) -> DiagnosticBuilder<'tcx, ErrorReported > {
338
+ ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed > {
335
339
let moved_path = moved_path.map(|mp| format!(": `{}`", mp)).unwrap_or_default();
336
340
337
341
struct_span_err!(
@@ -350,7 +354,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
350
354
span: Span,
351
355
path: &str,
352
356
reason: &str,
353
- ) -> DiagnosticBuilder<'cx, ErrorReported > {
357
+ ) -> DiagnosticBuilder<'cx, ErrorGuaranteed > {
354
358
struct_span_err!(self, span, E0596, "cannot borrow {} as mutable{}", path, reason,)
355
359
}
356
360
@@ -361,7 +365,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
361
365
immutable_place: &str,
362
366
immutable_section: &str,
363
367
action: &str,
364
- ) -> DiagnosticBuilder<'cx, ErrorReported > {
368
+ ) -> DiagnosticBuilder<'cx, ErrorGuaranteed > {
365
369
let mut err = struct_span_err!(
366
370
self,
367
371
mutate_span,
@@ -380,7 +384,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
380
384
&self,
381
385
span: Span,
382
386
yield_span: Span,
383
- ) -> DiagnosticBuilder<'cx, ErrorReported > {
387
+ ) -> DiagnosticBuilder<'cx, ErrorGuaranteed > {
384
388
let mut err = struct_span_err!(
385
389
self,
386
390
span,
@@ -394,7 +398,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
394
398
crate fn cannot_borrow_across_destructor(
395
399
&self,
396
400
borrow_span: Span,
397
- ) -> DiagnosticBuilder<'cx, ErrorReported > {
401
+ ) -> DiagnosticBuilder<'cx, ErrorGuaranteed > {
398
402
struct_span_err!(
399
403
self,
400
404
borrow_span,
@@ -407,7 +411,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
407
411
&self,
408
412
span: Span,
409
413
path: &str,
410
- ) -> DiagnosticBuilder<'cx, ErrorReported > {
414
+ ) -> DiagnosticBuilder<'cx, ErrorGuaranteed > {
411
415
struct_span_err!(self, span, E0597, "{} does not live long enough", path,)
412
416
}
413
417
@@ -417,7 +421,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
417
421
return_kind: &str,
418
422
reference_desc: &str,
419
423
path_desc: &str,
420
- ) -> DiagnosticBuilder<'cx, ErrorReported > {
424
+ ) -> DiagnosticBuilder<'cx, ErrorGuaranteed > {
421
425
let mut err = struct_span_err!(
422
426
self,
423
427
span,
@@ -442,7 +446,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
442
446
closure_kind: &str,
443
447
borrowed_path: &str,
444
448
capture_span: Span,
445
- ) -> DiagnosticBuilder<'cx, ErrorReported > {
449
+ ) -> DiagnosticBuilder<'cx, ErrorGuaranteed > {
446
450
let mut err = struct_span_err!(
447
451
self,
448
452
closure_span,
@@ -461,14 +465,14 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
461
465
crate fn thread_local_value_does_not_live_long_enough(
462
466
&self,
463
467
span: Span,
464
- ) -> DiagnosticBuilder<'cx, ErrorReported > {
468
+ ) -> DiagnosticBuilder<'cx, ErrorGuaranteed > {
465
469
struct_span_err!(self, span, E0712, "thread-local variable borrowed past end of function",)
466
470
}
467
471
468
472
crate fn temporary_value_borrowed_for_too_long(
469
473
&self,
470
474
span: Span,
471
- ) -> DiagnosticBuilder<'cx, ErrorReported > {
475
+ ) -> DiagnosticBuilder<'cx, ErrorGuaranteed > {
472
476
struct_span_err!(self, span, E0716, "temporary value dropped while borrowed",)
473
477
}
474
478
@@ -477,7 +481,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
477
481
sp: S,
478
482
msg: &str,
479
483
code: DiagnosticId,
480
- ) -> DiagnosticBuilder<'tcx, ErrorReported > {
484
+ ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed > {
481
485
self.infcx.tcx.sess.struct_span_err_with_code(sp, msg, code)
482
486
}
483
487
}
@@ -486,7 +490,7 @@ crate fn borrowed_data_escapes_closure<'tcx>(
486
490
tcx: TyCtxt<'tcx>,
487
491
escape_span: Span,
488
492
escapes_from: &str,
489
- ) -> DiagnosticBuilder<'tcx, ErrorReported > {
493
+ ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed > {
490
494
struct_span_err!(
491
495
tcx.sess,
492
496
escape_span,
0 commit comments