diff options
| author | Michael Goulet <michael@errs.io> | 2024-09-22 14:11:44 -0400 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-09-22 14:12:37 -0400 |
| commit | 2273aeed9decabdbbb0713a8b0749de0e9cd4ea7 (patch) | |
| tree | 8f70b3fb244172a6d34d6bde29974354de63cd40 /compiler/rustc_pattern_analysis | |
| parent | 0af7f0f4c4bdec179f42d0db4ec322040582de9d (diff) | |
| download | rust-2273aeed9decabdbbb0713a8b0749de0e9cd4ea7.tar.gz rust-2273aeed9decabdbbb0713a8b0749de0e9cd4ea7.zip | |
Replace calls to Const::eval in mir build
Diffstat (limited to 'compiler/rustc_pattern_analysis')
| -rw-r--r-- | compiler/rustc_pattern_analysis/src/rustc.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/compiler/rustc_pattern_analysis/src/rustc.rs b/compiler/rustc_pattern_analysis/src/rustc.rs index 6c09f97bfe7..78195a3177d 100644 --- a/compiler/rustc_pattern_analysis/src/rustc.rs +++ b/compiler/rustc_pattern_analysis/src/rustc.rs @@ -352,7 +352,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> { ty::Array(sub_ty, len) => { // We treat arrays of a constant but unknown length like slices. ConstructorSet::Slice { - array_len: len.try_eval_target_usize(cx.tcx, cx.param_env).map(|l| l as usize), + array_len: len.try_to_target_usize(cx.tcx).map(|l| l as usize), subtype_is_empty: cx.is_uninhabited(*sub_ty), } } @@ -685,9 +685,12 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> { } PatKind::Array { prefix, slice, suffix } | PatKind::Slice { prefix, slice, suffix } => { let array_len = match ty.kind() { - ty::Array(_, length) => { - Some(length.eval_target_usize(cx.tcx, cx.param_env) as usize) - } + ty::Array(_, length) => Some( + length + .try_to_target_usize(cx.tcx) + .expect("expected len of array pat to be definite") + as usize, + ), ty::Slice(_) => None, _ => span_bug!(pat.span, "bad ty {} for slice pattern", ty.inner()), }; |
