Replace calls to Const::eval in mir build
This commit is contained in:
parent
0af7f0f4c4
commit
2273aeed9d
4 changed files with 17 additions and 7 deletions
|
@ -57,7 +57,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
this.in_scope(region_scope, lint_level, |this| this.as_rvalue(block, scope, value))
|
||||
}
|
||||
ExprKind::Repeat { value, count } => {
|
||||
if Some(0) == count.try_eval_target_usize(this.tcx, this.param_env) {
|
||||
if Some(0) == count.try_to_target_usize(this.tcx) {
|
||||
this.build_zero_repeat(block, value, scope, source_info)
|
||||
} else {
|
||||
let value_operand = unpack!(
|
||||
|
|
|
@ -42,7 +42,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
let tcx = self.tcx;
|
||||
let (min_length, exact_size) = if let Some(place_resolved) = place.try_to_place(self) {
|
||||
match place_resolved.ty(&self.local_decls, tcx).ty.kind() {
|
||||
ty::Array(_, length) => (length.eval_target_usize(tcx, self.param_env), true),
|
||||
ty::Array(_, length) => (
|
||||
length
|
||||
.try_to_target_usize(tcx)
|
||||
.expect("expected len of array pat to be definite"),
|
||||
true,
|
||||
),
|
||||
_ => ((prefix.len() + suffix.len()).try_into().unwrap(), false),
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -441,7 +441,9 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
|||
ty::Slice(..) => PatKind::Slice { prefix, slice, suffix },
|
||||
// Fixed-length array, `[T; len]`.
|
||||
ty::Array(_, len) => {
|
||||
let len = len.eval_target_usize(self.tcx, self.param_env);
|
||||
let len = len
|
||||
.try_to_target_usize(self.tcx)
|
||||
.expect("expected len of array pat to be definite");
|
||||
assert!(len >= prefix.len() as u64 + suffix.len() as u64);
|
||||
PatKind::Array { prefix, slice, suffix }
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue