|
2 | 2 |
|
3 | 3 | use rustc_span::DUMMY_SP; |
4 | 4 |
|
| 5 | +use rustc_ast::Mutability; |
5 | 6 | use rustc_data_structures::fx::{FxHashMap, FxHashSet}; |
6 | 7 | use rustc_errors::ErrorReported; |
7 | 8 | use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; |
8 | 9 | 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, |
10 | 11 | }; |
11 | 12 | use rustc_middle::ty::ConstKind; |
12 | 13 |
|
@@ -175,9 +176,9 @@ pub(crate) fn codegen_const_value<'tcx>( |
175 | 176 | let mut alloc = Allocation::from_bytes( |
176 | 177 | std::iter::repeat(0).take(size.bytes_usize()).collect::<Vec<u8>>(), |
177 | 178 | align, |
| 179 | + Mutability::Not, |
178 | 180 | ); |
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(); |
181 | 182 | let alloc = fx.tcx.intern_const_alloc(alloc); |
182 | 183 | return CValue::by_ref(pointer_for_allocation(fx, alloc), layout); |
183 | 184 | } |
|
0 commit comments