Structurally resolve correctly in check_pat_lit

This commit is contained in:
Michael Goulet 2023-06-08 04:19:27 +00:00
parent f383703e32
commit 54fb5a48b9
2 changed files with 13 additions and 3 deletions

View File

@ -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");

View File

@ -0,0 +1,11 @@
// compile-flags: -Ztrait-solver=next
// check-pass
fn test(s: &[u8]) {
match &s[0..3] {
b"uwu" => {}
_ => {}
}
}
fn main() {}