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``
This commit is contained in:
Matthias Krüger 2023-06-09 08:15:57 +02:00 committed by GitHub
commit a4490b18a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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() {}