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:
@@ -257,8 +257,7 @@ fn check_static_inhabited(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
||||
fn check_opaque(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
||||
let item = tcx.hir().expect_item(def_id);
|
||||
let hir::ItemKind::OpaqueTy(hir::OpaqueTy { origin, .. }) = item.kind else {
|
||||
tcx.dcx().span_delayed_bug(item.span, "expected opaque item");
|
||||
return;
|
||||
tcx.dcx().span_bug(item.span, "expected opaque item");
|
||||
};
|
||||
|
||||
// HACK(jynelson): trying to infer the type of `impl trait` breaks documenting
|
||||
@@ -382,10 +381,10 @@ fn check_opaque_meets_bounds<'tcx>(
|
||||
Ok(()) => {}
|
||||
Err(ty_err) => {
|
||||
let ty_err = ty_err.to_string(tcx);
|
||||
return Err(tcx.dcx().span_delayed_bug(
|
||||
tcx.dcx().span_bug(
|
||||
span,
|
||||
format!("could not unify `{hidden_ty}` with revealed type:\n{ty_err}"),
|
||||
));
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -734,11 +734,8 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
|
||||
remapped_types.insert(def_id, ty::EarlyBinder::bind(ty));
|
||||
}
|
||||
Err(err) => {
|
||||
let reported = tcx.dcx().span_delayed_bug(
|
||||
return_span,
|
||||
format!("could not fully resolve: {ty} => {err:?}"),
|
||||
);
|
||||
remapped_types.insert(def_id, ty::EarlyBinder::bind(Ty::new_error(tcx, reported)));
|
||||
tcx.dcx()
|
||||
.span_bug(return_span, format!("could not fully resolve: {ty} => {err:?}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -917,7 +914,7 @@ impl<'tcx> ty::FallibleTypeFolder<TyCtxt<'tcx>> for RemapHiddenTyRegions<'tcx> {
|
||||
.with_note(format!("hidden type inferred to be `{}`", self.ty))
|
||||
.emit()
|
||||
}
|
||||
_ => self.tcx.dcx().delayed_bug("should've been able to remap region"),
|
||||
_ => self.tcx.dcx().bug("should've been able to remap region"),
|
||||
};
|
||||
return Err(guar);
|
||||
};
|
||||
@@ -1276,9 +1273,8 @@ fn compare_number_of_generics<'tcx>(
|
||||
// inheriting the generics from will also have mismatched arguments, and
|
||||
// we'll report an error for that instead. Delay a bug for safety, though.
|
||||
if trait_.is_impl_trait_in_trait() {
|
||||
return Err(tcx.dcx().delayed_bug(
|
||||
"errors comparing numbers of generics of trait/impl functions were not emitted",
|
||||
));
|
||||
tcx.dcx()
|
||||
.bug("errors comparing numbers of generics of trait/impl functions were not emitted");
|
||||
}
|
||||
|
||||
let matchings = [
|
||||
|
||||
@@ -154,8 +154,7 @@ pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
|
||||
trait_m_sig.inputs_and_output,
|
||||
));
|
||||
if !ocx.select_all_or_error().is_empty() {
|
||||
tcx.dcx().delayed_bug("encountered errors when checking RPITIT refinement (selection)");
|
||||
return;
|
||||
tcx.dcx().bug("encountered errors when checking RPITIT refinement (selection)");
|
||||
}
|
||||
let outlives_env = OutlivesEnvironment::with_bounds(
|
||||
param_env,
|
||||
@@ -163,13 +162,11 @@ pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
|
||||
);
|
||||
let errors = infcx.resolve_regions(&outlives_env);
|
||||
if !errors.is_empty() {
|
||||
tcx.dcx().delayed_bug("encountered errors when checking RPITIT refinement (regions)");
|
||||
return;
|
||||
tcx.dcx().bug("encountered errors when checking RPITIT refinement (regions)");
|
||||
}
|
||||
// Resolve any lifetime variables that may have been introduced during normalization.
|
||||
let Ok((trait_bounds, impl_bounds)) = infcx.fully_resolve((trait_bounds, impl_bounds)) else {
|
||||
tcx.dcx().delayed_bug("encountered errors when checking RPITIT refinement (resolution)");
|
||||
return;
|
||||
tcx.dcx().bug("encountered errors when checking RPITIT refinement (resolution)");
|
||||
};
|
||||
|
||||
// For quicker lookup, use an `IndexSet` (we don't use one earlier because
|
||||
|
||||
@@ -67,11 +67,10 @@ pub fn check_drop_impl(tcx: TyCtxt<'_>, drop_impl_did: DefId) -> Result<(), Erro
|
||||
// already checked by coherence, but compilation may
|
||||
// not have been terminated.
|
||||
let span = tcx.def_span(drop_impl_did);
|
||||
let reported = tcx.dcx().span_delayed_bug(
|
||||
tcx.dcx().span_bug(
|
||||
span,
|
||||
format!("should have been rejected by coherence check: {dtor_self_type}"),
|
||||
);
|
||||
Err(reported)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1088,10 +1088,8 @@ fn check_type_defn<'tcx>(
|
||||
let ty = tcx.type_of(variant.tail().did).instantiate_identity();
|
||||
let ty = tcx.erase_regions(ty);
|
||||
if ty.has_infer() {
|
||||
tcx.dcx()
|
||||
.span_delayed_bug(item.span, format!("inference variables in {ty:?}"));
|
||||
// Just treat unresolved type expression as if it needs drop.
|
||||
true
|
||||
// Unresolved type expression.
|
||||
tcx.dcx().span_bug(item.span, format!("inference variables in {ty:?}"));
|
||||
} else {
|
||||
ty.needs_drop(tcx, tcx.param_env(item.owner_id))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user