diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-06-09 08:15:57 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-09 08:15:57 +0200 |
| commit | a4490b18a7b0fcf48f2effb806f67e6c82cc5758 (patch) | |
| tree | 67aa9135ac58897d93e9e2acbcada257d03fa877 | |
| parent | d09b8d19228a5861629b1f4b10d50015c3ddd330 (diff) | |
| parent | 54fb5a48b968b3a329ceeb57226d9ac60f983f04 (diff) | |
| download | rust-a4490b18a7b0fcf48f2effb806f67e6c82cc5758.tar.gz rust-a4490b18a7b0fcf48f2effb806f67e6c82cc5758.zip | |
Rollup merge of #112428 - compiler-errors:next-solver-struct-resolv-pat, r=lcnr
Structurally resolve pointee in `check_pat_lit` Gotta make sure to eager norm the pointee of the match scrutinee with the new solver. r? ``@lcnr``
| -rw-r--r-- | compiler/rustc_hir_typeck/src/pat.rs | 5 | ||||
| -rw-r--r-- | tests/ui/traits/new-solver/slice-match-byte-lit.rs | 11 |
2 files changed, 13 insertions, 3 deletions
diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs index 5af955d3134..2f9871a103a 100644 --- a/compiler/rustc_hir_typeck/src/pat.rs +++ b/compiler/rustc_hir_typeck/src/pat.rs @@ -393,9 +393,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // They can denote both statically and dynamically-sized byte arrays. let mut pat_ty = ty; if let hir::ExprKind::Lit(Spanned { node: ast::LitKind::ByteStr(..), .. }) = lt.kind { - let expected = self.structurally_resolved_type(span, expected); - if let ty::Ref(_, inner_ty, _) = expected.kind() - && matches!(inner_ty.kind(), ty::Slice(_)) + if let ty::Ref(_, inner_ty, _) = *self.structurally_resolved_type(span, expected).kind() + && self.structurally_resolved_type(span, inner_ty).is_slice() { let tcx = self.tcx; trace!(?lt.hir_id.local_id, "polymorphic byte string lit"); diff --git a/tests/ui/traits/new-solver/slice-match-byte-lit.rs b/tests/ui/traits/new-solver/slice-match-byte-lit.rs new file mode 100644 index 00000000000..4f848062595 --- /dev/null +++ b/tests/ui/traits/new-solver/slice-match-byte-lit.rs @@ -0,0 +1,11 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +fn test(s: &[u8]) { + match &s[0..3] { + b"uwu" => {} + _ => {} + } +} + +fn main() {} |
