adjust constValue::Slice to work for arbitrary slice types
This commit is contained in:
parent
0692db1a90
commit
ea22adbabd
12 changed files with 75 additions and 63 deletions
|
@ -47,14 +47,12 @@ pub fn new_allocation<'tcx>(
|
|||
tables.tcx.layout_of(rustc_middle::ty::ParamEnv::empty().and(ty)).unwrap().align;
|
||||
new_empty_allocation(align.abi)
|
||||
}
|
||||
ConstValue::Slice { data, start, end } => {
|
||||
ConstValue::Slice { data, meta } => {
|
||||
let alloc_id = tables.tcx.reserve_and_set_memory_alloc(data);
|
||||
let ptr = Pointer::new(alloc_id, rustc_target::abi::Size::from_bytes(start));
|
||||
let ptr = Pointer::new(alloc_id, rustc_target::abi::Size::ZERO);
|
||||
let scalar_ptr = rustc_middle::mir::interpret::Scalar::from_pointer(ptr, &tables.tcx);
|
||||
let scalar_len = rustc_middle::mir::interpret::Scalar::from_target_usize(
|
||||
(end - start) as u64,
|
||||
&tables.tcx,
|
||||
);
|
||||
let scalar_meta =
|
||||
rustc_middle::mir::interpret::Scalar::from_target_usize(meta, &tables.tcx);
|
||||
let layout =
|
||||
tables.tcx.layout_of(rustc_middle::ty::ParamEnv::reveal_all().and(ty)).unwrap();
|
||||
let mut allocation =
|
||||
|
@ -69,8 +67,8 @@ pub fn new_allocation<'tcx>(
|
|||
allocation
|
||||
.write_scalar(
|
||||
&tables.tcx,
|
||||
alloc_range(tables.tcx.data_layout.pointer_size, scalar_len.size()),
|
||||
scalar_len,
|
||||
alloc_range(tables.tcx.data_layout.pointer_size, scalar_meta.size()),
|
||||
scalar_meta,
|
||||
)
|
||||
.unwrap();
|
||||
allocation.stable(tables)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue