diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-05-31 22:01:52 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-05-31 22:01:52 +0100 |
commit | 71117e6812f87e014bc8e984e195a75e222ac227 (patch) | |
tree | 8f5a74076cc2802c5de8fdb1b40e3eaf12252d51 /crates/hir_def/src | |
parent | 42dfdb87cb748e65d2c87687bde4d4712f9a850b (diff) | |
parent | e7c49666be180eba2720cce09d4d2116b1ef4d20 (diff) |
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 <[email protected]>
Diffstat (limited to 'crates/hir_def/src')
-rw-r--r-- | crates/hir_def/src/path.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/crates/hir_def/src/path.rs b/crates/hir_def/src/path.rs index 16440041d..4cdb5913d 100644 --- a/crates/hir_def/src/path.rs +++ b/crates/hir_def/src/path.rs | |||
@@ -166,7 +166,7 @@ impl Path { | |||
166 | } | 166 | } |
167 | 167 | ||
168 | /// Converts a known mod path to `Path`. | 168 | /// Converts a known mod path to `Path`. |
169 | pub(crate) fn from_known_path( | 169 | pub fn from_known_path( |
170 | path: ModPath, | 170 | path: ModPath, |
171 | generic_args: Vec<Option<Interned<GenericArgs>>>, | 171 | generic_args: Vec<Option<Interned<GenericArgs>>>, |
172 | ) -> Path { | 172 | ) -> Path { |