Skip to content

Commit e20fe21

Browse files
committed
Sync from rust 1969c2e
2 parents 39ffd9a + 9d41e8f commit e20fe21

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/constant.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
33
use rustc_span::DUMMY_SP;
44

5+
use rustc_ast::Mutability;
56
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
67
use rustc_errors::ErrorReported;
78
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
89
use rustc_middle::mir::interpret::{
9-
read_target_uint, AllocId, Allocation, ConstValue, ErrorHandled, GlobalAlloc, Pointer, Scalar,
10+
alloc_range, read_target_uint, AllocId, Allocation, ConstValue, ErrorHandled, GlobalAlloc, Scalar,
1011
};
1112
use rustc_middle::ty::ConstKind;
1213

@@ -175,9 +176,9 @@ pub(crate) fn codegen_const_value<'tcx>(
175176
let mut alloc = Allocation::from_bytes(
176177
std::iter::repeat(0).take(size.bytes_usize()).collect::<Vec<u8>>(),
177178
align,
179+
Mutability::Not,
178180
);
179-
let ptr = Pointer::new(AllocId(!0), Size::ZERO); // The alloc id is never used
180-
alloc.write_scalar(fx, ptr, x.into(), size).unwrap();
181+
alloc.write_scalar(fx, alloc_range(Size::ZERO, size), x.into()).unwrap();
181182
let alloc = fx.tcx.intern_const_alloc(alloc);
182183
return CValue::by_ref(pointer_for_allocation(fx, alloc), layout);
183184
}

src/intrinsics/simd.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
8686

8787
let idx_bytes = match idx_const {
8888
ConstValue::ByRef { alloc, offset } => {
89-
let ptr = Pointer::new(AllocId(0 /* dummy */), offset);
9089
let size = Size::from_bytes(4 * ret_lane_count /* size_of([u32; ret_lane_count]) */);
91-
alloc.get_bytes(fx, ptr, size).unwrap()
90+
alloc.get_bytes(fx, alloc_range(offset, size)).unwrap()
9291
}
9392
_ => unreachable!("{:?}", idx_const),
9493
};

0 commit comments

Comments
 (0)