Convert delayed_bugs to bugs.

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.

The next commit will convert some more back, based on human judgment.
This commit is contained in:
Nicholas Nethercote 2024-02-17 01:23:40 +11:00
parent bb594538fc
commit 010f3944e0
44 changed files with 87 additions and 157 deletions

View file

@ -62,14 +62,12 @@ pub fn is_const_evaluatable<'tcx>(
match unexpanded_ct.kind() {
ty::ConstKind::Expr(_) => {
// njn: ?
// 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",
)))
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,7 @@ fn do_normalize_predicates<'tcx>(
// the normalized predicates.
let errors = infcx.resolve_regions(&outlives_env);
if !errors.is_empty() {
tcx.dcx().span_delayed_bug(
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,7 +645,7 @@ 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"
@ -1190,11 +1190,10 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
ImplSource::Builtin(BuiltinImplSource::TraitUpcasting { .. }, _)
| ImplSource::Builtin(BuiltinImplSource::TupleUnsizing, _) => {
// These traits have no associated types.
selcx.tcx().dcx().span_delayed_bug(
selcx.tcx().dcx().span_bug(
obligation.cause.span,
format!("Cannot project an associated type from `{impl_source:?}`"),
);
return Err(());
}
};

View file

@ -82,7 +82,7 @@ where
let value = infcx.commit_if_ok(|_| {
let ocx = ObligationCtxt::new(infcx);
let value = op(&ocx).map_err(|_| {
infcx.dcx().span_delayed_bug(span, format!("error performing operation: {name}"))
infcx.dcx().span_bug(span, format!("error performing operation: {name}"))
})?;
let errors = ocx.select_all_or_error();
if errors.is_empty() {

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:?}"));
}
}