Skip to content

Commit 906d2b1

Browse files
Structurally normalize again for byte string lit pat checking
1 parent bd8aabe commit 906d2b1

File tree

3 files changed

+3
-14
lines changed

3 files changed

+3
-14
lines changed

compiler/rustc_hir_typeck/src/pat.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
394394
let mut pat_ty = ty;
395395
if let hir::ExprKind::Lit(Spanned { node: ast::LitKind::ByteStr(..), .. }) = lt.kind {
396396
let expected = self.structurally_resolve_type(span, expected);
397-
if let ty::Ref(_, inner_ty, _) = expected.kind()
398-
&& matches!(inner_ty.kind(), ty::Slice(_))
397+
if let ty::Ref(_, inner_ty, _) = *expected.kind()
398+
&& self.try_structurally_resolve_type(span, inner_ty).is_slice()
399399
{
400400
let tcx = self.tcx;
401401
trace!(?lt.hir_id.local_id, "polymorphic byte string lit");

tests/ui/traits/new-solver/slice-match-byte-lit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// compile-flags: -Ztrait-solver=next
2-
// known-bug: rust-lang/trait-system-refactor-initiative#38
2+
// check-pass
33

44
fn test(s: &[u8]) {
55
match &s[0..3] {

tests/ui/traits/new-solver/slice-match-byte-lit.stderr

-11
This file was deleted.

0 commit comments

Comments
 (0)