Skip to content

Commit

Permalink
Rollup merge of rust-lang#113399 - compiler-errors:next-solver-byte-p…
Browse files Browse the repository at this point in the history
…at-again, r=oli-obk

Structurally normalize again for byte string lit pat checking

We need to structurally normalize the pointee of a match scrutinee when trying to match byte string patterns -- we used[^1] to call `structurally_resolve_type`, which errors for type vars[^2], but lcnr added `try_structurally_resolve_type`[^3] in the mean time, which is the right thing to use here since it's totally opportunistic.

Fixes rust-lang/trait-system-refactor-initiative#38

[^1]: rust-lang#112428
[^2]: rust-lang#112993
[^3]: rust-lang#113086
  • Loading branch information
matthiaskrgr authored Jul 8, 2023
2 parents d5b1ef9 + 906d2b1 commit 8dc9461
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 14 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_hir_typeck/src/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let mut pat_ty = ty;
if let hir::ExprKind::Lit(Spanned { node: ast::LitKind::ByteStr(..), .. }) = lt.kind {
let expected = self.structurally_resolve_type(span, expected);
if let ty::Ref(_, inner_ty, _) = expected.kind()
&& matches!(inner_ty.kind(), ty::Slice(_))
if let ty::Ref(_, inner_ty, _) = *expected.kind()
&& self.try_structurally_resolve_type(span, inner_ty).is_slice()
{
let tcx = self.tcx;
trace!(?lt.hir_id.local_id, "polymorphic byte string lit");
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/traits/new-solver/slice-match-byte-lit.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// compile-flags: -Ztrait-solver=next
// known-bug: rust-lang/trait-system-refactor-initiative#38
// check-pass

fn test(s: &[u8]) {
match &s[0..3] {
Expand Down
11 changes: 0 additions & 11 deletions tests/ui/traits/new-solver/slice-match-byte-lit.stderr

This file was deleted.

0 comments on commit 8dc9461

Please sign in to comment.