diff options
| author | bors <bors@rust-lang.org> | 2024-09-23 04:56:10 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-09-23 04:56:10 +0000 |
| commit | 702987f75b74f789ba227ee04a3d7bb1680c2309 (patch) | |
| tree | a7056e093f9d3596604c4bf561fc55475007883a /compiler/rustc_pattern_analysis | |
| parent | 66b0b29e65c77e5801c308e725a233c0728df300 (diff) | |
| parent | 693269b2be59f36d1c95a6e57ee44b2002dc65e9 (diff) | |
| download | rust-702987f75b74f789ba227ee04a3d7bb1680c2309.tar.gz rust-702987f75b74f789ba227ee04a3d7bb1680c2309.zip | |
Auto merge of #130732 - matthiaskrgr:rollup-ke1j314, r=matthiaskrgr
Rollup of 10 pull requests
Successful merges:
- #129550 (Add str.as_str() for easy Deref to string slices)
- #130344 (Handle unsized consts with type `str` in v0 symbol mangling)
- #130659 (Support `char::encode_utf16` in const scenarios.)
- #130705 (No longer mark RTN as incomplete)
- #130712 (Don't call `ty::Const::normalize` in error reporting)
- #130713 (Mark `u8::make_ascii_uppercase` and `u8::make_ascii_lowercase` as const.)
- #130714 (Introduce `structurally_normalize_const`, use it in `rustc_hir_typeck`)
- #130715 (Replace calls to `ty::Const::{try_}eval` in mir build/pattern analysis)
- #130723 (Add test for `available_parallelism()`)
- #130726 (tests: Remove spuriously failing vec-tryinto-array codegen test)
r? `@ghost`
`@rustbot` modify labels: rollup
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 d164b8ab832..72737fb98cb 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()), }; |
