|
9 | 9 |
|
10 | 10 | use crate::rustc_internal::{self, opaque};
|
11 | 11 | use crate::stable_mir::mir::{CopyNonOverlapping, UserTypeProjection, VariantIdx};
|
12 |
| -use crate::stable_mir::ty::{new_allocation, FloatTy, IntTy, Movability, RigidTy, TyKind, UintTy}; |
| 12 | +use crate::stable_mir::ty::{ |
| 13 | + allocation_filter, new_allocation, FloatTy, IntTy, Movability, RigidTy, TyKind, UintTy, |
| 14 | +}; |
13 | 15 | use crate::stable_mir::{self, Context};
|
14 | 16 | use rustc_hir as hir;
|
15 | 17 | use rustc_middle::mir::coverage::CodeRegion;
|
| 18 | +use rustc_middle::mir::interpret::alloc_range; |
16 | 19 | use rustc_middle::mir::{self, ConstantKind};
|
17 | 20 | use rustc_middle::ty::{self, Ty, TyCtxt, Variance};
|
18 | 21 | use rustc_span::def_id::{CrateNum, DefId, LOCAL_CRATE};
|
@@ -1080,30 +1083,7 @@ impl<'tcx> Stable<'tcx> for mir::interpret::Allocation {
|
1080 | 1083 | type T = stable_mir::ty::Allocation;
|
1081 | 1084 |
|
1082 | 1085 | fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
|
1083 |
| - let size = self.size(); |
1084 |
| - let mut bytes: Vec<Option<u8>> = self |
1085 |
| - .inspect_with_uninit_and_ptr_outside_interpreter(0..size.bytes_usize()) |
1086 |
| - .iter() |
1087 |
| - .copied() |
1088 |
| - .map(Some) |
1089 |
| - .collect(); |
1090 |
| - for (i, b) in bytes.iter_mut().enumerate() { |
1091 |
| - if !self.init_mask().get(rustc_target::abi::Size::from_bytes(i)) { |
1092 |
| - *b = None; |
1093 |
| - } |
1094 |
| - } |
1095 |
| - stable_mir::ty::Allocation { |
1096 |
| - bytes: bytes, |
1097 |
| - provenance: { |
1098 |
| - let mut ptrs = Vec::new(); |
1099 |
| - for (size, prov) in self.provenance().ptrs().iter() { |
1100 |
| - ptrs.push((size.bytes_usize(), opaque(prov))); |
1101 |
| - } |
1102 |
| - stable_mir::ty::ProvenanceMap { ptrs } |
1103 |
| - }, |
1104 |
| - align: self.align.bytes(), |
1105 |
| - mutability: self.mutability.stable(tables), |
1106 |
| - } |
| 1086 | + allocation_filter(self, alloc_range(rustc_target::abi::Size::ZERO, self.size()), tables) |
1107 | 1087 | }
|
1108 | 1088 | }
|
1109 | 1089 |
|
|
0 commit comments