1
Fork 0

Rollup merge of #121208 - nnethercote:delayed_bug-to-bug, r=lcnr

Convert `delayed_bug`s to `bug`s.

I have a suspicion that quite a few delayed bug paths are impossible to reach, so I did an experiment.

I converted every `delayed_bug` to a `bug`, ran the full test suite, then converted back every `bug` that was hit. A surprising number were never hit.

This is too dangerous to merge. Increased coverage (fuzzing or a crater run) would likely hit more cases. But it might be useful for people to look at and think about which paths are genuinely unreachable.

r? `@ghost`
This commit is contained in:
Dylan DPC 2024-02-21 08:55:56 +00:00 committed by GitHub
commit d5206c6ecd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
39 changed files with 130 additions and 155 deletions

View file

@ -62,14 +62,11 @@ pub fn is_const_evaluatable<'tcx>(
match unexpanded_ct.kind() {
ty::ConstKind::Expr(_) => {
// FIXME(generic_const_exprs): we have a `ConstKind::Expr` which is fully concrete,
// but currently it is not possible to evaluate `ConstKind::Expr` so we are unable
// to tell if it is evaluatable or not. For now we just ICE until this is
// implemented.
Err(NotConstEvaluatable::Error(tcx.dcx().span_delayed_bug(
span,
"evaluating `ConstKind::Expr` is not currently supported",
)))
// FIXME(generic_const_exprs): we have a fully concrete `ConstKind::Expr`, but
// haven't implemented evaluating `ConstKind::Expr` yet, so we are unable to tell
// if it is evaluatable or not. As this is unreachable for now, we can simple ICE
// here.
tcx.dcx().span_bug(span, "evaluating `ConstKind::Expr` is not currently supported");
}
ty::ConstKind::Unevaluated(uv) => {
let concrete = infcx.const_eval_resolve(param_env, uv, Some(span));

View file

@ -3313,7 +3313,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
expected_trait_ref.self_ty().error_reported()?;
let Some(found_trait_ty) = found_trait_ref.self_ty().no_bound_vars() else {
return Err(self.dcx().delayed_bug("bound vars outside binder"));
self.dcx().bug("bound vars outside binder");
};
let found_did = match *found_trait_ty.kind() {

View file

@ -172,7 +172,9 @@ fn do_normalize_predicates<'tcx>(
// the normalized predicates.
let errors = infcx.resolve_regions(&outlives_env);
if !errors.is_empty() {
tcx.dcx().span_delayed_bug(
// @lcnr: Let's still ICE here for now. I want a test case
// for that.
tcx.dcx().span_bug(
span,
format!("failed region resolution while normalizing {elaborated_env:?}: {errors:?}"),
);

View file

@ -100,7 +100,7 @@ fn implied_outlives_bounds<'a, 'tcx>(
let errors = ocx.select_all_or_error();
if !errors.is_empty() {
infcx.dcx().span_delayed_bug(
infcx.dcx().span_bug(
span,
"implied_outlives_bounds failed to solve obligations from instantiation",
);

View file

@ -645,11 +645,9 @@ pub fn compute_inherent_assoc_ty_args<'a, 'b, 'tcx>(
match selcx.infcx.at(&cause, param_env).eq(DefineOpaqueTypes::No, impl_ty, self_ty) {
Ok(mut ok) => obligations.append(&mut ok.obligations),
Err(_) => {
tcx.dcx().span_delayed_bug(
tcx.dcx().span_bug(
cause.span,
format!(
"{self_ty:?} was a subtype of {impl_ty:?} during selection but now it is not"
),
format!("{self_ty:?} was equal to {impl_ty:?} during selection but now it is not"),
);
}
}
@ -1194,7 +1192,7 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
obligation.cause.span,
format!("Cannot project an associated type from `{impl_source:?}`"),
);
return Err(());
return Err(())
}
};

View file

@ -190,10 +190,9 @@ where
}
}
if !progress {
return Err(infcx.dcx().span_delayed_bug(
span,
format!("ambiguity processing {obligations:?} from {self:?}"),
));
infcx
.dcx()
.span_bug(span, format!("ambiguity processing {obligations:?} from {self:?}"));
}
}