rust/crates
bors[bot] 71117e6812
Merge #8717
8717: Update match checking algorithm r=iDawer a=iDawer

I've recently got interest in the match checking to extend the current algo to support reporting witnesses of non-exhaustiveness.
It appears the algo is outdated from rustc's implementation. I decided to rewrite it based on the latest rustc's version. It is a diff-based port to ra codebase. That means you can diff-compare these files to rustc.
I'm striving to keep minimal ra-related changes in the algo to make it easier to backport future changes from the upstream.

Based on upstream algorithm of version rust-lang/rust 1.52.0-nightly (25c15cdbe 2021-04-22)
https://github.com/rust-lang/rust/blob/25c15cdbe/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs

The goal of this PR is to cover the current `missing-match-arm` diagnostic.

What is remaining to do:
- [x] Error handling. The errors that are unrelated to match checking will be handled before the check. Just like how it made in rustc.
  - [x] Lowering `hir_def::expr::Pat` to `hir_ty::diagnostics::match_check::Pat`. rustc's match checking works on top of `rustc_mir_build::thir::Pat`, which is lowered from `hir::Pat` and carries some extra semantics used by the check. All unrelated checks are done there. RA could use this to rule out running the check on unimplemented cases (`Pat::ConstBlock`, etc).
  - [x] ~~Proper~~Loose typecheck of match arm patterns (https://github.com/rust-analyzer/rust-analyzer/pull/8840, https://github.com/rust-analyzer/rust-analyzer/pull/8875).
- [x] Tests from `hir_ty::diagnostics::match_check::tests`.
- [x] Clean up `todo`s
- [x] Test run on real repos https://github.com/rust-analyzer/rust-analyzer/pull/8717#issuecomment-847120265.

Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
2021-05-31 21:01:52 +00:00
..
base_db Merge #8866 2021-05-31 12:42:32 +00:00
cfg internal: expose cfg attrs from hir::Crate 2021-05-07 23:50:24 +03:00
flycheck Use package root as cargo check working directory 2021-05-12 19:50:52 -07:00
hir Merge #8866 2021-05-31 12:42:32 +00:00
hir_def Expand fixme comments 2021-06-01 01:44:51 +05:00
hir_expand Thread proc-macro types through the HIR 2021-05-29 20:32:57 +02:00
hir_ty Merge #8717 2021-05-31 21:01:52 +00:00
ide Merge #8952 2021-05-31 15:48:41 +00:00
ide_assists clippy::redundant_clone fixes 2021-05-26 18:34:50 +03:00
ide_completion Merge #9079 2021-05-31 13:38:32 +00:00
ide_db Merge #8866 2021-05-31 12:42:32 +00:00
ide_ssr
mbe Treat pat_param like pat fragments 2021-05-29 18:32:32 +02:00
parser Add even more docs 2021-05-22 17:20:22 +03:00
paths
proc_macro_api Disable unaliged feature of object 2021-05-24 16:35:52 +03:00
proc_macro_srv Use cargo check again 2021-05-31 18:58:36 +02:00
proc_macro_test Simplify proc_macro_srv tests 2021-05-31 17:32:56 +02:00
profile Add more docs 2021-05-22 16:53:47 +03:00
project_model clippy::redundant_clone fixes 2021-05-26 18:34:50 +03:00
rust-analyzer Merge #9039 2021-05-31 13:21:31 +00:00
stdx Don't compare ast::Visibility by stringifying 2021-05-20 17:45:59 +02:00
syntax minor: remove debug print 2021-05-31 20:20:30 +03:00
test_utils simplify 2021-05-28 20:46:09 +02:00
text_edit
toolchain
tt Add more docs 2021-05-22 16:53:47 +03:00
vfs
vfs-notify