Skip to content

Commit 23a797d

Browse files
delay_bug_unless_*
1 parent 1a3fad5 commit 23a797d

File tree

110 files changed

+331
-267
lines changed

Some content is hidden

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

110 files changed

+331
-267
lines changed

compiler/rustc_ast_lowering/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1404,7 +1404,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
14041404
}
14051405
TyKind::MacCall(_) => panic!("`TyKind::MacCall` should have been expanded by now"),
14061406
TyKind::CVarArgs => {
1407-
self.tcx.sess.delay_span_bug(
1407+
self.tcx.sess.delay_bug_unless_error(
14081408
t.span,
14091409
"`TyKind::CVarArgs` should have been handled elsewhere",
14101410
);

compiler/rustc_ast_passes/src/feature_gate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ impl<'a> PostExpansionVisitor<'a> {
102102
}
103103
Err(abi::AbiDisabled::Unrecognized) => {
104104
if self.sess.opts.pretty.map_or(true, |ppm| ppm.needs_hir()) {
105-
self.sess.parse_sess.span_diagnostic.delay_span_bug(
105+
self.sess.parse_sess.span_diagnostic.delay_bug_unless_error(
106106
span,
107107
&format!(
108108
"unrecognized ABI not caught in lowering: {}",

compiler/rustc_attr/src/builtin.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1092,9 +1092,10 @@ pub fn parse_repr_attr(sess: &Session, attr: &Attribute) -> Vec<ReprAttr> {
10921092
// Not a word we recognize. This will be caught and reported by
10931093
// the `check_mod_attrs` pass, but this pass doesn't always run
10941094
// (e.g. if we only pretty-print the source), so we have to gate
1095-
// the `delay_span_bug` call as follows:
1095+
// the `delay_bug_unless_error` call as follows:
10961096
if sess.opts.pretty.map_or(true, |pp| pp.needs_analysis()) {
1097-
diagnostic.delay_span_bug(item.span(), "unrecognized representation hint");
1097+
diagnostic
1098+
.delay_bug_unless_error(item.span(), "unrecognized representation hint");
10981099
}
10991100
}
11001101
}

compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ fn try_extract_error_from_fulfill_cx<'tcx>(
380380
error_region: Option<ty::Region<'tcx>>,
381381
) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
382382
// We generally shouldn't have errors here because the query was
383-
// already run, but there's no point using `delay_span_bug`
383+
// already run, but there's no point using `delay_bug_unless_error`
384384
// when we're going to emit an error here anyway.
385385
let _errors = ocx.select_all_or_error();
386386
let region_constraints = ocx.infcx.with_region_constraints(|r| r.clone());

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl<'tcx> RegionErrors<'tcx> {
8484
#[track_caller]
8585
pub fn push(&mut self, val: impl Into<RegionErrorKind<'tcx>>) {
8686
let val = val.into();
87-
self.1.sess.delay_span_bug(DUMMY_SP, format!("{val:?}"));
87+
self.1.sess.delay_bug_unless_error(DUMMY_SP, format!("{val:?}"));
8888
self.0.push(val);
8989
}
9090
pub fn is_empty(&self) -> bool {

compiler/rustc_borrowck/src/diagnostics/region_name.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -619,8 +619,8 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
619619
_,
620620
) => {
621621
// HIR lowering sometimes doesn't catch this in erroneous
622-
// programs, so we need to use delay_span_bug here. See #82126.
623-
self.infcx.tcx.sess.delay_span_bug(
622+
// programs, so we need to use delay_bug_unless_error here. See #82126.
623+
self.infcx.tcx.sess.delay_bug_unless_error(
624624
hir_arg.span(),
625625
&format!("unmatched subst and hir arg: found {kind:?} vs {hir_arg:?}"),
626626
);

compiler/rustc_borrowck/src/lib.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -2054,11 +2054,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
20542054
&& !self.has_buffered_errors()
20552055
{
20562056
// rust-lang/rust#46908: In pure NLL mode this code path should be
2057-
// unreachable, but we use `delay_span_bug` because we can hit this when
2057+
// unreachable, but we use `delay_bug_unless_error` because we can hit this when
20582058
// dereferencing a non-Copy raw pointer *and* have `-Ztreat-err-as-bug`
20592059
// enabled. We don't want to ICE for that case, as other errors will have
20602060
// been emitted (#52262).
2061-
self.infcx.tcx.sess.delay_span_bug(
2061+
self.infcx.tcx.sess.delay_bug_unless_error(
20622062
span,
20632063
&format!(
20642064
"Accessing `{:?}` with the kind `{:?}` shouldn't be possible",
@@ -2354,11 +2354,11 @@ mod error {
23542354

23552355
pub fn buffer_error(&mut self, t: DiagnosticBuilder<'_, ErrorGuaranteed>) {
23562356
if let None = self.tainted_by_errors {
2357-
self.tainted_by_errors = Some(
2358-
self.tcx
2359-
.sess
2360-
.delay_span_bug(t.span.clone(), "diagnostic buffered but not emitted"),
2361-
)
2357+
self.tainted_by_errors =
2358+
Some(self.tcx.sess.delay_bug_unless_error(
2359+
t.span.clone(),
2360+
"diagnostic buffered but not emitted",
2361+
))
23622362
}
23632363
t.buffer(&mut self.buffered);
23642364
}

compiler/rustc_borrowck/src/nll.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ pub(crate) fn compute_regions<'cx, 'tcx>(
303303

304304
if !nll_errors.is_empty() {
305305
// Suppress unhelpful extra errors in `infer_opaque_types`.
306-
infcx.set_tainted_by_errors(infcx.tcx.sess.delay_span_bug(
306+
infcx.set_tainted_by_errors(infcx.tcx.sess.delay_bug_unless_error(
307307
body.span,
308308
"`compute_regions` tainted `infcx` with errors but did not emit any errors",
309309
));

compiler/rustc_borrowck/src/type_check/free_region_relations.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
274274
.infcx
275275
.tcx
276276
.sess
277-
.delay_span_bug(span, &format!("failed to normalize {:?}", ty));
277+
.delay_bug_unless_error(span, &format!("failed to normalize {:?}", ty));
278278
TypeOpOutput {
279279
output: self.infcx.tcx.ty_error(guar),
280280
constraints: None,

compiler/rustc_borrowck/src/type_check/input_output.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,10 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
8080
// Equate expected input tys with those in the MIR.
8181
for (argument_index, &normalized_input_ty) in normalized_input_tys.iter().enumerate() {
8282
if argument_index + 1 >= body.local_decls.len() {
83-
self.tcx()
84-
.sess
85-
.delay_span_bug(body.span, "found more normalized_input_ty than local_decls");
83+
self.tcx().sess.delay_bug_unless_error(
84+
body.span,
85+
"found more normalized_input_ty than local_decls",
86+
);
8687
break;
8788
}
8889

@@ -106,10 +107,10 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
106107
);
107108

108109
// We will not have a universal_regions.yield_ty if we yield (by accident)
109-
// outside of a generator and return an `impl Trait`, so emit a delay_span_bug
110+
// outside of a generator and return an `impl Trait`, so emit a delay_bug_unless_error
110111
// because we don't want to panic in an assert here if we've already got errors.
111112
if body.yield_ty().is_some() != universal_regions.yield_ty.is_some() {
112-
self.tcx().sess.delay_span_bug(
113+
self.tcx().sess.delay_bug_unless_error(
113114
body.span,
114115
&format!(
115116
"Expected body to have yield_ty ({:?}) iff we have a UR yield_ty ({:?})",

compiler/rustc_borrowck/src/type_check/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ pub(crate) fn type_check<'mir, 'tcx>(
235235
let mut hidden_type = infcx.resolve_vars_if_possible(decl.hidden_type);
236236
trace!("finalized opaque type {:?} to {:#?}", opaque_type_key, hidden_type.ty.kind());
237237
if hidden_type.has_non_region_infer() {
238-
let reported = infcx.tcx.sess.delay_span_bug(
238+
let reported = infcx.tcx.sess.delay_bug_unless_error(
239239
decl.hidden_type.span,
240240
&format!("could not resolve {:#?}", hidden_type.ty.kind()),
241241
);
@@ -277,9 +277,9 @@ fn translate_outlives_facts(typeck: &mut TypeChecker<'_, '_>) {
277277
#[track_caller]
278278
fn mirbug(tcx: TyCtxt<'_>, span: Span, msg: &str) {
279279
// We sometimes see MIR failures (notably predicate failures) due to
280-
// the fact that we check rvalue sized predicates here. So use `delay_span_bug`
280+
// the fact that we check rvalue sized predicates here. So use `delay_bug_unless_error`
281281
// to avoid reporting bugs in those cases.
282-
tcx.sess.diagnostic().delay_span_bug(span, msg);
282+
tcx.sess.diagnostic().delay_bug_unless_error(span, msg);
283283
}
284284

285285
enum FieldAccessError {

compiler/rustc_codegen_ssa/src/codegen_attrs.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: DefId) -> CodegenFnAttrs {
7171
if let DefKind::Fn | DefKind::AssocFn | DefKind::Variant | DefKind::Ctor(..) = def_kind {
7272
true
7373
} else {
74-
tcx.sess.delay_span_bug(attr_sp, "this attribute can only be applied to functions");
74+
tcx.sess
75+
.delay_bug_unless_error(attr_sp, "this attribute can only be applied to functions");
7576
false
7677
}
7778
};

compiler/rustc_const_eval/src/const_eval/machine.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
378378
if ecx.tcx.is_ctfe_mir_available(def.did) {
379379
Ok(ecx.tcx.mir_for_ctfe_opt_const_arg(def))
380380
} else if ecx.tcx.def_kind(def.did) == DefKind::AssocConst {
381-
let guar = ecx.tcx.sess.delay_span_bug(
381+
let guar = ecx.tcx.sess.delay_bug_unless_error(
382382
rustc_span::DUMMY_SP,
383383
"This is likely a const item that is missing from its impl",
384384
);

compiler/rustc_const_eval/src/interpret/eval_context.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ impl<'tcx> fmt::Display for FrameInfo<'tcx> {
267267
{
268268
write!(f, "inside closure")
269269
} else {
270-
// Note: this triggers a `bug_unless_diagnostic_emitted` state, which means
270+
// Note: this triggers a `bug_unless_diagnostic` state, which means
271271
// that if we ever get here we must emit a diagnostic. We should never display
272272
// a `FrameInfo` unless we actually want to emit a warning or error to the user.
273273
write!(f, "inside `{}`", self.instance)
@@ -509,7 +509,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
509509
.instance
510510
.try_subst_mir_and_normalize_erasing_regions(*self.tcx, self.param_env, value)
511511
.map_err(|e| {
512-
self.tcx.sess.delay_span_bug(
512+
self.tcx.sess.delay_bug_unless_error(
513513
self.cur_span(),
514514
format!("failed to normalize {}", e.get_type_for_failure()).as_str(),
515515
);

compiler/rustc_const_eval/src/interpret/intern.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ fn intern_shallow<'rt, 'mir, 'tcx, M: CompileTimeMachine<'mir, 'tcx, const_eval:
9393
// If the pointer is dangling (neither in local nor global memory), we leave it
9494
// to validation to error -- it has the much better error messages, pointing out where
9595
// in the value the dangling reference lies.
96-
// The `delay_span_bug` ensures that we don't forget such a check in validation.
96+
// The `delay_bug_unless_error` ensures that we don't forget such a check in validation.
9797
if tcx.try_get_global_alloc(alloc_id).is_none() {
98-
tcx.sess.delay_span_bug(ecx.tcx.span, "tried to intern dangling pointer");
98+
tcx.sess.delay_bug_unless_error(ecx.tcx.span, "tried to intern dangling pointer");
9999
}
100100
// treat dangling pointers like other statics
101101
// just to stop trying to recurse into them
@@ -253,8 +253,10 @@ impl<'rt, 'mir, 'tcx: 'mir, M: CompileTimeMachine<'mir, 'tcx, const_eval::Memory
253253
} else {
254254
// Validation will error (with a better message) on an invalid vtable pointer.
255255
// Let validation show the error message, but make sure it *does* error.
256-
tcx.sess
257-
.delay_span_bug(tcx.span, "vtables pointers cannot be integer pointers");
256+
tcx.sess.delay_bug_unless_error(
257+
tcx.span,
258+
"vtables pointers cannot be integer pointers",
259+
);
258260
}
259261
}
260262
// Check if we have encountered this pointer+layout combination before.
@@ -385,7 +387,7 @@ pub fn intern_const_alloc_recursive<
385387
match res {
386388
Ok(()) => {}
387389
Err(error) => {
388-
ecx.tcx.sess.delay_span_bug(
390+
ecx.tcx.sess.delay_bug_unless_error(
389391
ecx.tcx.span,
390392
&format!(
391393
"error during interning should later cause validation failure: {}",

compiler/rustc_const_eval/src/interpret/step.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
285285
let layout = self.layout_of(ty)?;
286286
if layout.is_unsized() {
287287
// FIXME: This should be a span_bug (#80742)
288-
self.tcx.sess.delay_span_bug(
288+
self.tcx.sess.delay_bug_unless_error(
289289
self.frame().current_span(),
290290
&format!("Nullary MIR operator called for unsized type {}", ty),
291291
);

compiler/rustc_const_eval/src/transform/check_consts/check.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
223223
// `async` functions cannot be `const fn`. This is checked during AST lowering, so there's
224224
// no need to emit duplicate errors here.
225225
if self.ccx.is_async() || body.generator.is_some() {
226-
tcx.sess.delay_span_bug(body.span, "`async` functions cannot be `const fn`");
226+
tcx.sess.delay_bug_unless_error(body.span, "`async` functions cannot be `const fn`");
227227
return;
228228
}
229229

@@ -332,7 +332,9 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
332332

333333
fn check_static(&mut self, def_id: DefId, span: Span) {
334334
if self.tcx.is_thread_local_static(def_id) {
335-
self.tcx.sess.delay_span_bug(span, "tls access is checked in `Rvalue::ThreadLocalRef");
335+
self.tcx
336+
.sess
337+
.delay_bug_unless_error(span, "tls access is checked in `Rvalue::ThreadLocalRef");
336338
}
337339
self.check_op_spanned(ops::StaticAccess, span)
338340
}

compiler/rustc_const_eval/src/transform/check_consts/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ pub fn is_const_stable_const_fn(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
112112
None if is_parent_const_stable_trait(tcx, def_id) => {
113113
// Remove this when `#![feature(const_trait_impl)]` is stabilized,
114114
// returning `true` unconditionally.
115-
tcx.sess.delay_span_bug(
115+
tcx.sess.delay_bug_unless_error(
116116
tcx.def_span(def_id),
117117
"trait implementations cannot be const stable yet",
118118
);

compiler/rustc_const_eval/src/transform/validate.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
9292
#[track_caller]
9393
fn fail(&self, location: Location, msg: impl AsRef<str>) {
9494
let span = self.body.source_info(location).span;
95-
// We use `delay_span_bug` as we might see broken MIR when other errors have already
95+
// We use `delay_bug_unless_error` as we might see broken MIR when other errors have already
9696
// occurred.
97-
self.tcx.sess.diagnostic().delay_span_bug(
97+
self.tcx.sess.diagnostic().delay_bug_unless_error(
9898
span,
9999
&format!(
100100
"broken MIR in {:?} ({}) at {:?}:\n{}",
@@ -958,7 +958,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
958958

959959
fn visit_source_scope(&mut self, scope: SourceScope) {
960960
if self.body.source_scopes.get(scope).is_none() {
961-
self.tcx.sess.diagnostic().delay_span_bug(
961+
self.tcx.sess.diagnostic().delay_bug_unless_error(
962962
self.body.span,
963963
&format!(
964964
"broken MIR in {:?} ({}):\ninvalid source scope {:?}",

0 commit comments

Comments
 (0)