Skip to content

Commit b002d72

Browse files
ivarflakstadizagawd
authored andcommitted
Make unreachable path trigger ICE with span
1 parent 0348628 commit b002d72

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

compiler/rustc_const_eval/src/interpret/intrinsics.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use super::util::ensure_monomorphic_enough;
2323
use super::{
2424
Allocation, AllocId, CheckInAllocMsg, ConstAllocation, ImmTy, InterpCx, InterpResult, Machine, OpTy,
2525
PlaceTy, Pointer, PointerArithmetic, Provenance, Scalar, err_ub_custom, err_unsup_format,
26-
interp_ok, throw_inval, throw_ub_custom, throw_ub_format, throw_unsup_format,
26+
interp_ok, throw_inval, throw_ub_custom, throw_ub_format,
2727
};
2828
use crate::fluent_generated as fluent;
2929

@@ -227,17 +227,15 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
227227

228228
ensure_monomorphic_enough(tcx, tp_ty)?;
229229
ensure_monomorphic_enough(tcx, result_ty)?;
230-
231230
let ty::Dynamic(preds, _, ty::Dyn) = result_ty.kind() else {
232-
throw_unsup_format!(
231+
span_bug!(
232+
self.find_closest_untracked_caller_location(),
233233
"Invalid type provided to vtable_for::<T, U>. U must be dyn Trait, got {result_ty}."
234234
);
235235
};
236236

237-
let (infcx, param_env) = self
238-
.tcx
239-
.infer_ctxt()
240-
.build_with_typing_env(self.typing_env);
237+
let (infcx, param_env) =
238+
self.tcx.infer_ctxt().build_with_typing_env(self.typing_env);
241239

242240
let type_impls_trait = preds.iter().all(|pred| {
243241
let trait_ref = ty::TraitRef::new(tcx, pred.def_id(), [tp_ty]);

0 commit comments

Comments
 (0)