Get rid of const eval_* and try_eval_* helpers
This commit is contained in:
parent
a2a1206811
commit
e83e4e8112
31 changed files with 119 additions and 172 deletions
|
@ -43,7 +43,7 @@ pub(crate) fn try_destructure_mir_constant_for_user_output<'tcx>(
|
|||
|
||||
// We go to `usize` as we cannot allocate anything bigger anyway.
|
||||
let (field_count, variant, down) = match ty.kind() {
|
||||
ty::Array(_, len) => (len.eval_target_usize(tcx.tcx, param_env) as usize, None, op),
|
||||
ty::Array(_, len) => (len.try_to_target_usize(tcx.tcx)? as usize, None, op),
|
||||
ty::Adt(def, _) if def.variants().is_empty() => {
|
||||
return None;
|
||||
}
|
||||
|
|
|
@ -391,7 +391,9 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
|||
let ptr = self.read_pointer(src)?;
|
||||
let val = Immediate::new_slice(
|
||||
ptr,
|
||||
length.eval_target_usize(*self.tcx, self.param_env),
|
||||
length
|
||||
.try_to_target_usize(*self.tcx)
|
||||
.expect("expected monomorphic const in const eval"),
|
||||
self,
|
||||
);
|
||||
self.write_immediate(val, dest)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue