Skip to content

Commit 6048adc

Browse files
committed
Support allocation failures when interperting MIR
Note that this breaks Miri. Closes rust-lang#79601
1 parent b186f86 commit 6048adc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/vtable.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ pub(crate) fn get_vtable<'tcx>(
7272
let vtable_ptr = if let Some(vtable_ptr) = fx.vtables.get(&(ty, trait_ref)) {
7373
*vtable_ptr
7474
} else {
75-
let vtable_alloc_id = fx.tcx.vtable_allocation(ty, trait_ref);
75+
let vtable_alloc_id = match fx.tcx.vtable_allocation(ty, trait_ref) {
76+
Ok(alloc) => alloc,
77+
Err(_) => fx.tcx.sess().fatal("allocation of constant vtable failed"),
78+
};
7679
let vtable_allocation = fx.tcx.global_alloc(vtable_alloc_id).unwrap_memory();
7780
let vtable_ptr = pointer_for_allocation(fx, vtable_allocation);
7881

0 commit comments

Comments
 (0)