diff options
| author | Nadrieril <nadrieril+git@gmail.com> | 2020-05-23 18:59:27 +0100 |
|---|---|---|
| committer | Nadrieril <nadrieril+git@gmail.com> | 2020-05-23 18:59:27 +0100 |
| commit | 7addc115eb18fb4a1e5347b55a138d0428fb6344 (patch) | |
| tree | 619f0f1b32c37d311531664a1ba85b94f13ffda6 /src | |
| parent | 3bf94b2c9d300132e391a27dfa6d44256ebee316 (diff) | |
| download | rust-7addc115eb18fb4a1e5347b55a138d0428fb6344.tar.gz rust-7addc115eb18fb4a1e5347b55a138d0428fb6344.zip | |
Work around type normalization issues
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_mir_build/hair/pattern/_match.rs | 4 | ||||
| -rw-r--r-- | src/test/ui/pattern/usefulness/issue-72476-associated-type.rs | 23 |
2 files changed, 26 insertions, 1 deletions
diff --git a/src/librustc_mir_build/hair/pattern/_match.rs b/src/librustc_mir_build/hair/pattern/_match.rs index 32c54fbbfd9..575ddcef997 100644 --- a/src/librustc_mir_build/hair/pattern/_match.rs +++ b/src/librustc_mir_build/hair/pattern/_match.rs @@ -1870,7 +1870,9 @@ crate fn is_useful<'p, 'tcx>( return if any_is_useful { Useful(unreachable_pats) } else { NotUseful }; } - let pcx = PatCtxt { ty: v.head().ty, span: v.head().span }; + // FIXME(Nadrieril): Hack to work around type normalization issues (see #72476). + let ty = matrix.heads().next().map(|r| r.ty).unwrap_or(v.head().ty); + let pcx = PatCtxt { ty, span: v.head().span }; debug!("is_useful_expand_first_col: pcx={:#?}, expanding {:#?}", pcx, v.head()); diff --git a/src/test/ui/pattern/usefulness/issue-72476-associated-type.rs b/src/test/ui/pattern/usefulness/issue-72476-associated-type.rs new file mode 100644 index 00000000000..21ad6c7d989 --- /dev/null +++ b/src/test/ui/pattern/usefulness/issue-72476-associated-type.rs @@ -0,0 +1,23 @@ +// check-pass + +// From https://github.com/rust-lang/rust/issues/72476 + +trait A { + type Projection; +} + +impl A for () { + type Projection = bool; + // using () instead of bool here does compile though +} + +struct Next<T: A>(T::Projection); + +fn f(item: Next<()>) { + match item { + Next(true) => {} + Next(false) => {} + } +} + +fn main() {} |
