Skip to content

Commit

Permalink
correctly create Scalar for meta info
Browse files Browse the repository at this point in the history
  • Loading branch information
b-naber committed Jun 14, 2022
1 parent 90c4b94 commit 8093db6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions compiler/rustc_const_eval/src/const_eval/valtrees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ fn create_pointee_place<'tcx>(
let place = MPlaceTy::from_aligned_ptr_with_meta(
ptr.into(),
layout,
MemPlaceMeta::Meta(Scalar::from_u64(num_elems as u64)),
MemPlaceMeta::Meta(Scalar::from_machine_usize(num_elems as u64, &tcx)),
);
debug!(?place);

Expand Down Expand Up @@ -370,7 +370,8 @@ fn valtree_into_mplace<'tcx>(
let imm = match inner_ty.kind() {
ty::Slice(_) | ty::Str => {
let len = valtree.unwrap_branch().len();
let len_scalar = ScalarMaybeUninit::Scalar(Scalar::from_u64(len as u64));
let len_scalar =
ScalarMaybeUninit::Scalar(Scalar::from_machine_usize(len as u64, &tcx));

Immediate::ScalarPair(
ScalarMaybeUninit::from_maybe_pointer((*pointee_place).ptr, &tcx),
Expand Down Expand Up @@ -441,7 +442,10 @@ fn valtree_into_mplace<'tcx>(
place
.offset(
offset,
MemPlaceMeta::Meta(Scalar::from_u64(num_elems as u64)),
MemPlaceMeta::Meta(Scalar::from_machine_usize(
num_elems as u64,
&tcx,
)),
inner_layout,
&tcx,
)
Expand Down

0 comments on commit 8093db6

Please sign in to comment.