about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_codegen_cranelift/src/vtable.rs5
-rw-r--r--compiler/rustc_codegen_ssa/src/meth.rs5
-rw-r--r--compiler/rustc_middle/src/ty/vtable.rs11
-rw-r--r--compiler/rustc_mir/src/interpret/traits.rs2
4 files changed, 9 insertions, 14 deletions
diff --git a/compiler/rustc_codegen_cranelift/src/vtable.rs b/compiler/rustc_codegen_cranelift/src/vtable.rs
index 7ee34b23e46..12f7092d935 100644
--- a/compiler/rustc_codegen_cranelift/src/vtable.rs
+++ b/compiler/rustc_codegen_cranelift/src/vtable.rs
@@ -72,10 +72,7 @@ pub(crate) fn get_vtable<'tcx>(
     let vtable_ptr = if let Some(vtable_ptr) = fx.vtables.get(&(ty, trait_ref)) {
         *vtable_ptr
     } else {
-        let vtable_alloc_id = match fx.tcx.vtable_allocation(ty, trait_ref) {
-            Ok(alloc) => alloc,
-            Err(_) => fx.tcx.sess.fatal("allocation of constant vtable failed"),
-        };
+        let vtable_alloc_id = fx.tcx.vtable_allocation(ty, trait_ref);
         let vtable_allocation = fx.tcx.global_alloc(vtable_alloc_id).unwrap_memory();
         let vtable_ptr = pointer_for_allocation(fx, vtable_allocation);
 
diff --git a/compiler/rustc_codegen_ssa/src/meth.rs b/compiler/rustc_codegen_ssa/src/meth.rs
index fcaafb94cfd..63245a94c8e 100644
--- a/compiler/rustc_codegen_ssa/src/meth.rs
+++ b/compiler/rustc_codegen_ssa/src/meth.rs
@@ -70,10 +70,7 @@ pub fn get_vtable<'tcx, Cx: CodegenMethods<'tcx>>(
         return val;
     }
 
-    let vtable_alloc_id = match tcx.vtable_allocation(ty, trait_ref) {
-        Ok(alloc) => alloc,
-        Err(_) => tcx.sess.fatal("allocation of constant vtable failed"),
-    };
+    let vtable_alloc_id = tcx.vtable_allocation(ty, trait_ref);
     let vtable_allocation = tcx.global_alloc(vtable_alloc_id).unwrap_memory();
     let vtable_const = cx.const_data_from_alloc(vtable_allocation);
     let align = cx.data_layout().pointer_align.abi;
diff --git a/compiler/rustc_middle/src/ty/vtable.rs b/compiler/rustc_middle/src/ty/vtable.rs
index ef1c941bee4..0940137a7c3 100644
--- a/compiler/rustc_middle/src/ty/vtable.rs
+++ b/compiler/rustc_middle/src/ty/vtable.rs
@@ -1,6 +1,6 @@
 use std::convert::TryFrom;
 
-use crate::mir::interpret::{alloc_range, AllocId, Allocation, InterpResult, Pointer, Scalar};
+use crate::mir::interpret::{alloc_range, AllocId, Allocation, Pointer, Scalar};
 use crate::ty::fold::TypeFoldable;
 use crate::ty::{self, DefId, SubstsRef, Ty, TyCtxt};
 use rustc_ast::Mutability;
@@ -28,11 +28,11 @@ impl<'tcx> TyCtxt<'tcx> {
         self,
         ty: Ty<'tcx>,
         poly_trait_ref: Option<ty::PolyExistentialTraitRef<'tcx>>,
-    ) -> InterpResult<'tcx, AllocId> {
+    ) -> AllocId {
         let tcx = self;
         let vtables_cache = tcx.vtables_cache.lock();
         if let Some(alloc_id) = vtables_cache.get(&(ty, poly_trait_ref)).cloned() {
-            return Ok(alloc_id);
+            return alloc_id;
         }
         drop(vtables_cache);
 
@@ -60,7 +60,8 @@ impl<'tcx> TyCtxt<'tcx> {
         let ptr_align = tcx.data_layout.pointer_align.abi;
 
         let vtable_size = ptr_size * u64::try_from(vtable_entries.len()).unwrap();
-        let mut vtable = Allocation::uninit(vtable_size, ptr_align, true)?;
+        let mut vtable =
+            Allocation::uninit(vtable_size, ptr_align, /* panic_on_fail */ true).unwrap();
 
         // No need to do any alignment checks on the memory accesses below, because we know the
         // allocation is correctly aligned as we created it above. Also we're only offsetting by
@@ -101,6 +102,6 @@ impl<'tcx> TyCtxt<'tcx> {
         let alloc_id = tcx.create_memory_alloc(tcx.intern_const_alloc(vtable));
         let mut vtables_cache = self.vtables_cache.lock();
         vtables_cache.insert((ty, poly_trait_ref), alloc_id);
-        Ok(alloc_id)
+        alloc_id
     }
 }
diff --git a/compiler/rustc_mir/src/interpret/traits.rs b/compiler/rustc_mir/src/interpret/traits.rs
index 94948948ccf..5332e615bc8 100644
--- a/compiler/rustc_mir/src/interpret/traits.rs
+++ b/compiler/rustc_mir/src/interpret/traits.rs
@@ -30,7 +30,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
         ensure_monomorphic_enough(*self.tcx, ty)?;
         ensure_monomorphic_enough(*self.tcx, poly_trait_ref)?;
 
-        let vtable_allocation = self.tcx.vtable_allocation(ty, poly_trait_ref)?;
+        let vtable_allocation = self.tcx.vtable_allocation(ty, poly_trait_ref);
 
         let vtable_ptr = self.memory.global_base_pointer(Pointer::from(vtable_allocation))?;