Skip to content

Commit 7addc11

Browse files
committed
Work around type normalization issues
1 parent 3bf94b2 commit 7addc11

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/librustc_mir_build/hair/pattern/_match.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1870,7 +1870,9 @@ crate fn is_useful<'p, 'tcx>(
18701870
return if any_is_useful { Useful(unreachable_pats) } else { NotUseful };
18711871
}
18721872

1873-
let pcx = PatCtxt { ty: v.head().ty, span: v.head().span };
1873+
// FIXME(Nadrieril): Hack to work around type normalization issues (see #72476).
1874+
let ty = matrix.heads().next().map(|r| r.ty).unwrap_or(v.head().ty);
1875+
let pcx = PatCtxt { ty, span: v.head().span };
18741876

18751877
debug!("is_useful_expand_first_col: pcx={:#?}, expanding {:#?}", pcx, v.head());
18761878

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// check-pass
2+
3+
// From https://github.com/rust-lang/rust/issues/72476
4+
5+
trait A {
6+
type Projection;
7+
}
8+
9+
impl A for () {
10+
type Projection = bool;
11+
// using () instead of bool here does compile though
12+
}
13+
14+
struct Next<T: A>(T::Projection);
15+
16+
fn f(item: Next<()>) {
17+
match item {
18+
Next(true) => {}
19+
Next(false) => {}
20+
}
21+
}
22+
23+
fn main() {}

0 commit comments

Comments
 (0)