Skip to content

Commit 54fb5a4

Browse files
Structurally resolve correctly in check_pat_lit
1 parent f383703 commit 54fb5a4

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

compiler/rustc_hir_typeck/src/pat.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
393393
// They can denote both statically and dynamically-sized byte arrays.
394394
let mut pat_ty = ty;
395395
if let hir::ExprKind::Lit(Spanned { node: ast::LitKind::ByteStr(..), .. }) = lt.kind {
396-
let expected = self.structurally_resolved_type(span, expected);
397-
if let ty::Ref(_, inner_ty, _) = expected.kind()
398-
&& matches!(inner_ty.kind(), ty::Slice(_))
396+
if let ty::Ref(_, inner_ty, _) = *self.structurally_resolved_type(span, expected).kind()
397+
&& self.structurally_resolved_type(span, inner_ty).is_slice()
399398
{
400399
let tcx = self.tcx;
401400
trace!(?lt.hir_id.local_id, "polymorphic byte string lit");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// compile-flags: -Ztrait-solver=next
2+
// check-pass
3+
4+
fn test(s: &[u8]) {
5+
match &s[0..3] {
6+
b"uwu" => {}
7+
_ => {}
8+
}
9+
}
10+
11+
fn main() {}

0 commit comments

Comments
 (0)