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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 7 additions & 7 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 6 additions & 5 deletions
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 ({:?})",

0 commit comments

Comments
 (0)