|
1 | 1 | use std::convert::TryFrom;
|
2 | 2 |
|
3 |
| -use crate::mir::interpret::{alloc_range, AllocId, Allocation, InterpResult, Pointer, Scalar}; |
| 3 | +use crate::mir::interpret::{alloc_range, AllocId, Allocation, Pointer, Scalar}; |
4 | 4 | use crate::ty::fold::TypeFoldable;
|
5 | 5 | use crate::ty::{self, DefId, SubstsRef, Ty, TyCtxt};
|
6 | 6 | use rustc_ast::Mutability;
|
@@ -28,11 +28,11 @@ impl<'tcx> TyCtxt<'tcx> {
|
28 | 28 | self,
|
29 | 29 | ty: Ty<'tcx>,
|
30 | 30 | poly_trait_ref: Option<ty::PolyExistentialTraitRef<'tcx>>,
|
31 |
| - ) -> InterpResult<'tcx, AllocId> { |
| 31 | + ) -> AllocId { |
32 | 32 | let tcx = self;
|
33 | 33 | let vtables_cache = tcx.vtables_cache.lock();
|
34 | 34 | if let Some(alloc_id) = vtables_cache.get(&(ty, poly_trait_ref)).cloned() {
|
35 |
| - return Ok(alloc_id); |
| 35 | + return alloc_id; |
36 | 36 | }
|
37 | 37 | drop(vtables_cache);
|
38 | 38 |
|
@@ -60,7 +60,8 @@ impl<'tcx> TyCtxt<'tcx> {
|
60 | 60 | let ptr_align = tcx.data_layout.pointer_align.abi;
|
61 | 61 |
|
62 | 62 | let vtable_size = ptr_size * u64::try_from(vtable_entries.len()).unwrap();
|
63 |
| - let mut vtable = Allocation::uninit(vtable_size, ptr_align, true)?; |
| 63 | + let mut vtable = |
| 64 | + Allocation::uninit(vtable_size, ptr_align, /* panic_on_fail */ true).unwrap(); |
64 | 65 |
|
65 | 66 | // No need to do any alignment checks on the memory accesses below, because we know the
|
66 | 67 | // allocation is correctly aligned as we created it above. Also we're only offsetting by
|
@@ -101,6 +102,6 @@ impl<'tcx> TyCtxt<'tcx> {
|
101 | 102 | let alloc_id = tcx.create_memory_alloc(tcx.intern_const_alloc(vtable));
|
102 | 103 | let mut vtables_cache = self.vtables_cache.lock();
|
103 | 104 | vtables_cache.insert((ty, poly_trait_ref), alloc_id);
|
104 |
| - Ok(alloc_id) |
| 105 | + alloc_id |
105 | 106 | }
|
106 | 107 | }
|
0 commit comments