Skip to content

Commit 08504c6

Browse files
committed
Auto merge of #93244 - mark-i-m:doomed, r=oli-obk
Rename `ErrorReported` -> `ErrorGuaranteed` r? `@eddyb` cc #93222 #69426 The idea is that we would like to use it for both errors and `delay_span_bug`. Its semantics indicate a _guarantee_ that compilation will fail.
2 parents c42d846 + e489a94 commit 08504c6

File tree

112 files changed

+580
-559
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+580
-559
lines changed

Diff for: compiler/rustc_borrowck/src/borrowck_errors.rs

+31-27
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_errors::{struct_span_err, DiagnosticBuilder, DiagnosticId, ErrorReported};
1+
use rustc_errors::{struct_span_err, DiagnosticBuilder, DiagnosticId, ErrorGuaranteed};
22
use rustc_middle::ty::{self, Ty, TyCtxt};
33
use rustc_span::{MultiSpan, Span};
44

@@ -7,7 +7,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
77
&self,
88
span: Span,
99
desc: &str,
10-
) -> DiagnosticBuilder<'cx, ErrorReported> {
10+
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
1111
struct_span_err!(self, span, E0505, "cannot move out of {} because it is borrowed", desc,)
1212
}
1313

@@ -17,7 +17,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
1717
desc: &str,
1818
borrow_span: Span,
1919
borrow_desc: &str,
20-
) -> DiagnosticBuilder<'cx, ErrorReported> {
20+
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
2121
let mut err = struct_span_err!(
2222
self,
2323
span,
@@ -36,7 +36,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
3636
span: Span,
3737
verb: &str,
3838
desc: &str,
39-
) -> DiagnosticBuilder<'cx, ErrorReported> {
39+
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
4040
struct_span_err!(
4141
self,
4242
span,
@@ -55,7 +55,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
5555
old_loan_span: Span,
5656
old_opt_via: &str,
5757
old_load_end_span: Option<Span>,
58-
) -> DiagnosticBuilder<'cx, ErrorReported> {
58+
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
5959
let via =
6060
|msg: &str| if msg.is_empty() { "".to_string() } else { format!(" (via {})", msg) };
6161
let mut err = struct_span_err!(
@@ -103,7 +103,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
103103
desc: &str,
104104
old_loan_span: Span,
105105
old_load_end_span: Option<Span>,
106-
) -> DiagnosticBuilder<'cx, ErrorReported> {
106+
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
107107
let mut err = struct_span_err!(
108108
self,
109109
new_loan_span,
@@ -136,7 +136,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
136136
noun_old: &str,
137137
old_opt_via: &str,
138138
previous_end_span: Option<Span>,
139-
) -> DiagnosticBuilder<'cx, ErrorReported> {
139+
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
140140
let mut err = struct_span_err!(
141141
self,
142142
new_loan_span,
@@ -168,7 +168,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
168168
old_opt_via: &str,
169169
previous_end_span: Option<Span>,
170170
second_borrow_desc: &str,
171-
) -> DiagnosticBuilder<'cx, ErrorReported> {
171+
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
172172
let mut err = struct_span_err!(
173173
self,
174174
new_loan_span,
@@ -204,7 +204,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
204204
kind_old: &str,
205205
msg_old: &str,
206206
old_load_end_span: Option<Span>,
207-
) -> DiagnosticBuilder<'cx, ErrorReported> {
207+
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
208208
let via =
209209
|msg: &str| if msg.is_empty() { "".to_string() } else { format!(" (via {})", msg) };
210210
let mut err = struct_span_err!(
@@ -247,7 +247,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
247247
span: Span,
248248
borrow_span: Span,
249249
desc: &str,
250-
) -> DiagnosticBuilder<'cx, ErrorReported> {
250+
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
251251
let mut err = struct_span_err!(
252252
self,
253253
span,
@@ -266,20 +266,24 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
266266
span: Span,
267267
desc: &str,
268268
is_arg: bool,
269-
) -> DiagnosticBuilder<'cx, ErrorReported> {
269+
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
270270
let msg = if is_arg { "to immutable argument" } else { "twice to immutable variable" };
271271
struct_span_err!(self, span, E0384, "cannot assign {} {}", msg, desc)
272272
}
273273

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> {
275279
struct_span_err!(self, span, E0594, "cannot assign to {}", desc)
276280
}
277281

278282
crate fn cannot_move_out_of(
279283
&self,
280284
move_from_span: Span,
281285
move_from_desc: &str,
282-
) -> DiagnosticBuilder<'cx, ErrorReported> {
286+
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
283287
struct_span_err!(self, move_from_span, E0507, "cannot move out of {}", move_from_desc,)
284288
}
285289

@@ -291,7 +295,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
291295
move_from_span: Span,
292296
ty: Ty<'_>,
293297
is_index: Option<bool>,
294-
) -> DiagnosticBuilder<'cx, ErrorReported> {
298+
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
295299
let type_name = match (&ty.kind(), is_index) {
296300
(&ty::Array(_, _), Some(true)) | (&ty::Array(_, _), None) => "array",
297301
(&ty::Slice(_), _) => "slice",
@@ -313,7 +317,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
313317
&self,
314318
move_from_span: Span,
315319
container_ty: Ty<'_>,
316-
) -> DiagnosticBuilder<'cx, ErrorReported> {
320+
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
317321
let mut err = struct_span_err!(
318322
self,
319323
move_from_span,
@@ -331,7 +335,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
331335
verb: &str,
332336
optional_adverb_for_moved: &str,
333337
moved_path: Option<String>,
334-
) -> DiagnosticBuilder<'tcx, ErrorReported> {
338+
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
335339
let moved_path = moved_path.map(|mp| format!(": `{}`", mp)).unwrap_or_default();
336340

337341
struct_span_err!(
@@ -350,7 +354,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
350354
span: Span,
351355
path: &str,
352356
reason: &str,
353-
) -> DiagnosticBuilder<'cx, ErrorReported> {
357+
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
354358
struct_span_err!(self, span, E0596, "cannot borrow {} as mutable{}", path, reason,)
355359
}
356360

@@ -361,7 +365,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
361365
immutable_place: &str,
362366
immutable_section: &str,
363367
action: &str,
364-
) -> DiagnosticBuilder<'cx, ErrorReported> {
368+
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
365369
let mut err = struct_span_err!(
366370
self,
367371
mutate_span,
@@ -380,7 +384,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
380384
&self,
381385
span: Span,
382386
yield_span: Span,
383-
) -> DiagnosticBuilder<'cx, ErrorReported> {
387+
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
384388
let mut err = struct_span_err!(
385389
self,
386390
span,
@@ -394,7 +398,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
394398
crate fn cannot_borrow_across_destructor(
395399
&self,
396400
borrow_span: Span,
397-
) -> DiagnosticBuilder<'cx, ErrorReported> {
401+
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
398402
struct_span_err!(
399403
self,
400404
borrow_span,
@@ -407,7 +411,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
407411
&self,
408412
span: Span,
409413
path: &str,
410-
) -> DiagnosticBuilder<'cx, ErrorReported> {
414+
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
411415
struct_span_err!(self, span, E0597, "{} does not live long enough", path,)
412416
}
413417

@@ -417,7 +421,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
417421
return_kind: &str,
418422
reference_desc: &str,
419423
path_desc: &str,
420-
) -> DiagnosticBuilder<'cx, ErrorReported> {
424+
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
421425
let mut err = struct_span_err!(
422426
self,
423427
span,
@@ -442,7 +446,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
442446
closure_kind: &str,
443447
borrowed_path: &str,
444448
capture_span: Span,
445-
) -> DiagnosticBuilder<'cx, ErrorReported> {
449+
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
446450
let mut err = struct_span_err!(
447451
self,
448452
closure_span,
@@ -461,14 +465,14 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
461465
crate fn thread_local_value_does_not_live_long_enough(
462466
&self,
463467
span: Span,
464-
) -> DiagnosticBuilder<'cx, ErrorReported> {
468+
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
465469
struct_span_err!(self, span, E0712, "thread-local variable borrowed past end of function",)
466470
}
467471

468472
crate fn temporary_value_borrowed_for_too_long(
469473
&self,
470474
span: Span,
471-
) -> DiagnosticBuilder<'cx, ErrorReported> {
475+
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
472476
struct_span_err!(self, span, E0716, "temporary value dropped while borrowed",)
473477
}
474478

@@ -477,7 +481,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
477481
sp: S,
478482
msg: &str,
479483
code: DiagnosticId,
480-
) -> DiagnosticBuilder<'tcx, ErrorReported> {
484+
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
481485
self.infcx.tcx.sess.struct_span_err_with_code(sp, msg, code)
482486
}
483487
}
@@ -486,7 +490,7 @@ crate fn borrowed_data_escapes_closure<'tcx>(
486490
tcx: TyCtxt<'tcx>,
487491
escape_span: Span,
488492
escapes_from: &str,
489-
) -> DiagnosticBuilder<'tcx, ErrorReported> {
493+
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
490494
struct_span_err!(
491495
tcx.sess,
492496
escape_span,

Diff for: compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_errors::{DiagnosticBuilder, ErrorReported};
1+
use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed};
22
use rustc_infer::infer::canonical::Canonical;
33
use rustc_infer::infer::error_reporting::nice_region_error::NiceRegionError;
44
use rustc_infer::infer::region_constraints::Constraint;
@@ -124,7 +124,7 @@ trait TypeOpInfo<'tcx> {
124124
&self,
125125
tcx: TyCtxt<'tcx>,
126126
span: Span,
127-
) -> DiagnosticBuilder<'tcx, ErrorReported>;
127+
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed>;
128128

129129
fn base_universe(&self) -> ty::UniverseIndex;
130130

@@ -134,7 +134,7 @@ trait TypeOpInfo<'tcx> {
134134
cause: ObligationCause<'tcx>,
135135
placeholder_region: ty::Region<'tcx>,
136136
error_region: Option<ty::Region<'tcx>>,
137-
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>>;
137+
) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>>;
138138

139139
fn report_error(
140140
&self,
@@ -196,7 +196,7 @@ impl<'tcx> TypeOpInfo<'tcx> for PredicateQuery<'tcx> {
196196
&self,
197197
tcx: TyCtxt<'tcx>,
198198
span: Span,
199-
) -> DiagnosticBuilder<'tcx, ErrorReported> {
199+
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
200200
let mut err = tcx.sess.struct_span_err(span, "higher-ranked lifetime error");
201201
err.note(&format!("could not prove {}", self.canonical_query.value.value.predicate));
202202
err
@@ -212,7 +212,7 @@ impl<'tcx> TypeOpInfo<'tcx> for PredicateQuery<'tcx> {
212212
cause: ObligationCause<'tcx>,
213213
placeholder_region: ty::Region<'tcx>,
214214
error_region: Option<ty::Region<'tcx>>,
215-
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>> {
215+
) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
216216
tcx.infer_ctxt().enter_with_canonical(
217217
cause.span,
218218
&self.canonical_query,
@@ -243,7 +243,7 @@ where
243243
&self,
244244
tcx: TyCtxt<'tcx>,
245245
span: Span,
246-
) -> DiagnosticBuilder<'tcx, ErrorReported> {
246+
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
247247
let mut err = tcx.sess.struct_span_err(span, "higher-ranked lifetime error");
248248
err.note(&format!("could not normalize `{}`", self.canonical_query.value.value.value));
249249
err
@@ -259,7 +259,7 @@ where
259259
cause: ObligationCause<'tcx>,
260260
placeholder_region: ty::Region<'tcx>,
261261
error_region: Option<ty::Region<'tcx>>,
262-
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>> {
262+
) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
263263
tcx.infer_ctxt().enter_with_canonical(
264264
cause.span,
265265
&self.canonical_query,
@@ -304,7 +304,7 @@ impl<'tcx> TypeOpInfo<'tcx> for AscribeUserTypeQuery<'tcx> {
304304
&self,
305305
tcx: TyCtxt<'tcx>,
306306
span: Span,
307-
) -> DiagnosticBuilder<'tcx, ErrorReported> {
307+
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
308308
// FIXME: This error message isn't great, but it doesn't show up in the existing UI tests,
309309
// and is only the fallback when the nice error fails. Consider improving this some more.
310310
tcx.sess.struct_span_err(span, "higher-ranked lifetime error")
@@ -320,7 +320,7 @@ impl<'tcx> TypeOpInfo<'tcx> for AscribeUserTypeQuery<'tcx> {
320320
cause: ObligationCause<'tcx>,
321321
placeholder_region: ty::Region<'tcx>,
322322
error_region: Option<ty::Region<'tcx>>,
323-
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>> {
323+
) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
324324
tcx.infer_ctxt().enter_with_canonical(
325325
cause.span,
326326
&self.canonical_query,
@@ -345,7 +345,7 @@ fn try_extract_error_from_fulfill_cx<'tcx>(
345345
infcx: &InferCtxt<'_, 'tcx>,
346346
placeholder_region: ty::Region<'tcx>,
347347
error_region: Option<ty::Region<'tcx>>,
348-
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>> {
348+
) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
349349
let tcx = infcx.tcx;
350350

351351
// We generally shouldn't have errors here because the query was

0 commit comments

Comments
 (0)