Skip to content

Commit d7eddef

Browse files
Structurally normalize in range pattern checking in HIR typeck
1 parent f5d3fe2 commit d7eddef

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

compiler/rustc_hir_typeck/src/pat.rs

+1
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
866866
// be peeled to `str` while ty here is still `&str`, if we don't
867867
// err early here, a rather confusing unification error will be
868868
// emitted instead).
869+
let ty = self.structurally_resolve_type(expr.span, ty);
869870
let fail =
870871
!(ty.is_numeric() || ty.is_char() || ty.is_ty_var() || ty.references_error());
871872
Some((fail, ty, expr.span))
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//@ check-pass
2+
//@ revisions: current next
3+
//@ ignore-compare-mode-next-solver (explicit revisions)
4+
//@[next] compile-flags: -Znext-solver
5+
6+
// Regression test for <https://github.com/rust-lang/trait-system-refactor-initiative/issues/200>.
7+
// Make sure we structurally normalize in range pattern checking in HIR typeck.
8+
9+
trait Foo {
10+
type Bar;
11+
}
12+
13+
impl Foo for () {
14+
type Bar = i32;
15+
}
16+
17+
fn main() {
18+
const X: <() as Foo>::Bar = 0;
19+
20+
match 0 {
21+
X..=X => {}
22+
_ => {}
23+
}
24+
}

0 commit comments

Comments
 (0)