|
1 | 1 | use super::{error_to_const_error, CompileTimeEvalContext, CompileTimeInterpreter, MemoryExtra}; |
2 | 2 | use crate::interpret::eval_nullary_intrinsic; |
3 | 3 | use crate::interpret::{ |
4 | | - intern_const_alloc_recursive, Allocation, ConstValue, GlobalId, ImmTy, Immediate, InternKind, |
| 4 | + intern_const_alloc_recursive, Allocation, ConstValue, GlobalId, Immediate, InternKind, |
5 | 5 | InterpCx, InterpResult, MPlaceTy, MemoryKind, OpTy, RawConst, RefTracking, Scalar, |
6 | 6 | ScalarMaybeUndef, StackPopCleanup, |
7 | 7 | }; |
@@ -147,24 +147,26 @@ pub(super) fn op_to_const<'tcx>( |
147 | 147 | match immediate { |
148 | 148 | Ok(mplace) => to_const_value(mplace), |
149 | 149 | // see comment on `let try_as_immediate` above |
150 | | - Err(ImmTy { imm: Immediate::Scalar(x), .. }) => match x { |
151 | | - ScalarMaybeUndef::Scalar(s) => ConstValue::Scalar(s), |
152 | | - ScalarMaybeUndef::Undef => to_const_value(op.assert_mem_place(ecx)), |
153 | | - }, |
154 | | - Err(ImmTy { imm: Immediate::ScalarPair(a, b), .. }) => { |
155 | | - let (data, start) = match a.not_undef().unwrap() { |
156 | | - Scalar::Ptr(ptr) => { |
157 | | - (ecx.tcx.alloc_map.lock().unwrap_memory(ptr.alloc_id), ptr.offset.bytes()) |
158 | | - } |
159 | | - Scalar::Raw { .. } => ( |
160 | | - ecx.tcx.intern_const_alloc(Allocation::from_byte_aligned_bytes(b"" as &[u8])), |
161 | | - 0, |
162 | | - ), |
163 | | - }; |
164 | | - let len = b.to_machine_usize(&ecx.tcx.tcx).unwrap(); |
165 | | - let start = start.try_into().unwrap(); |
166 | | - let len: usize = len.try_into().unwrap(); |
167 | | - ConstValue::Slice { data, start, end: start + len } |
| 150 | + Err(imm) => match *imm { |
| 151 | + Immediate::Scalar(x) => match x { |
| 152 | + ScalarMaybeUndef::Scalar(s) => ConstValue::Scalar(s), |
| 153 | + ScalarMaybeUndef::Undef => to_const_value(op.assert_mem_place(ecx)), |
| 154 | + }, |
| 155 | + Immediate::ScalarPair(a, b) => { |
| 156 | + let (data, start) = match a.not_undef().unwrap() { |
| 157 | + Scalar::Ptr(ptr) => { |
| 158 | + (ecx.tcx.alloc_map.lock().unwrap_memory(ptr.alloc_id), ptr.offset.bytes()) |
| 159 | + } |
| 160 | + Scalar::Raw { .. } => ( |
| 161 | + ecx.tcx.intern_const_alloc(Allocation::from_byte_aligned_bytes(b"" as &[u8])), |
| 162 | + 0, |
| 163 | + ), |
| 164 | + }; |
| 165 | + let len = b.to_machine_usize(&ecx.tcx.tcx).unwrap(); |
| 166 | + let start = start.try_into().unwrap(); |
| 167 | + let len: usize = len.try_into().unwrap(); |
| 168 | + ConstValue::Slice { data, start, end: start + len } |
| 169 | + } |
168 | 170 | } |
169 | 171 | } |
170 | 172 | } |
|
0 commit comments