Structurally resolve correctly in check_pat_lit
This commit is contained in:
parent
f383703e32
commit
54fb5a48b9
@ -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");
|
||||
|
11
tests/ui/traits/new-solver/slice-match-byte-lit.rs
Normal file
11
tests/ui/traits/new-solver/slice-match-byte-lit.rs
Normal file
@ -0,0 +1,11 @@
|
||||
// compile-flags: -Ztrait-solver=next
|
||||
// check-pass
|
||||
|
||||
fn test(s: &[u8]) {
|
||||
match &s[0..3] {
|
||||
b"uwu" => {}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
Loading…
x
Reference in New Issue
Block a user