Commit Graph

611 Commits

Author SHA1 Message Date
Aleksey Kladov
0eafc88079 minor: put a mark back 2021-06-13 11:49:32 +03:00
Maan2003
5ac6804bb3
cargo fmt 2021-06-13 09:48:15 +05:30
Maan2003
aabd41cafc
clippy::redundant_field_names 2021-06-13 09:40:22 +05:30
Maan2003
75370312fb
clippy::redundant_closure 2021-06-13 09:29:36 +05:30
Maan2003
6cc6dee9e9
clippy::useless_conversion 2021-06-13 09:25:55 +05:30
Maan2003
c9b4ac5be4
clippy::redudant_borrow 2021-06-13 09:24:16 +05:30
bors[bot]
d6737e55fb
Merge #9239
9239: fix: Fix coercion in match with expected type r=flodiebold a=flodiebold

Plus add infrastructure to test type mismatches without expect.

CC #8961

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2021-06-12 21:05:12 +00:00
Florian Diebold
20487a1b4a Fix coercion in match with expected type
Plus add infrastructure to test type mismatches without expect.
2021-06-12 23:04:43 +02:00
Aleksey Kladov
0463d76a1f internal: cross-crate cov-marks 2021-06-12 23:40:52 +03:00
Aleksey Kladov
7731714578 internal: move diagnostics infra to hir 2021-06-12 22:05:23 +03:00
Aleksey Kladov
6940cfed1e Move some hir_ty diagnostics to hir 2021-06-12 21:00:22 +03:00
Aleksey Kladov
1b1e3de988 minor: reduce visibility 2021-06-12 17:41:47 +03:00
Aleksey Kladov
0413d51317 internal: move missing unsafe diagnostic to hir 2021-06-12 17:39:46 +03:00
Aleksey Kladov
f8009666be internal: move inference diagnostics to hir 2021-06-12 17:17:23 +03:00
Jonas Schievink
17565f4dea Set enable_proc_attr_macros in hir_ty TestDB 2021-06-03 18:11:33 +02:00
bors[bot]
c7eb19ebf9
Merge #9104
9104: Implement `#[rustc_skip_array_during_method_dispatch]` r=flodiebold a=jonas-schievink

haxx run the world

Closes https://github.com/rust-analyzer/rust-analyzer/issues/8552
Part of https://github.com/rust-analyzer/rust-analyzer/issues/9056

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-06-03 11:52:15 +00:00
bors[bot]
50936397cc
Merge #9105
9105: internal: calculate pattern adjustments r=flodiebold a=iDawer

This extends `InferenceResult` with `pub pat_adjustments: FxHashMap<PatId, Vec<Ty>>`.

Fixes #9095 


Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
2021-06-03 09:55:37 +00:00
Lukas Wirth
ded4e7cc83 Fix bind patterns always being treated as ref taking patterns 2021-06-02 20:00:39 +02:00
Dawer
0a8c30a96f internal: implement pattern adjustments. 2021-06-02 01:32:05 +05:00
Dawer
99516bbd67 minor: Avoid eprintln on panic 2021-06-02 01:32:05 +05:00
Jonas Schievink
955064b6aa Implement #[rustc_skip_array_during_method_dispatch] 2021-06-01 21:34:08 +02:00
Jonas Schievink
f96c1a0414 Implement per-edition preludes 2021-06-01 13:39:19 +02:00
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
Dawer
e7c49666be Expand fixme comments 2021-06-01 01:44:51 +05:00
Dawer
31b6a750f8 fix: panic on extra fields in a pattern 2021-06-01 00:49:44 +05:00
Dawer
4899ac8c05 Correct binding pattern's type; handle invalid records. 2021-06-01 00:49:44 +05:00
Dawer
3088ca0a53 Take substitutions into account. 2021-06-01 00:49:44 +05:00
Dawer
e16f413582 eprint panic context 2021-06-01 00:49:44 +05:00
Dawer
f571b62a13 minor: doc comment pat_util 2021-06-01 00:49:44 +05:00
Dawer
977ba46bb1 Test match guards, reference patterns 2021-06-01 00:49:44 +05:00
Dawer
4cce7a6407 Box field detection; test #[non-exhaustive] attribute 2021-06-01 00:49:44 +05:00
Dawer
f46a42f73a Better tests: check if match checking bails out. 2021-06-01 00:49:27 +05:00
Dawer
e84efc4a46 Replace the old match checking algorithm 2021-06-01 00:23:09 +05:00
Dawer
894b4c64ff Include old tests 2021-06-01 00:08:43 +05:00
Dawer
7d675eda80 Don't panic on a pattern of unresolved ADT variant. 2021-06-01 00:08:43 +05:00
Dawer
466345ca81 Clean up, more docs. 2021-06-01 00:08:27 +05:00
Dawer
49e016169f Check pattern types. 2021-06-01 00:03:47 +05:00
Dawer
9b841a9a04 Expand binding patterns. 2021-06-01 00:03:47 +05:00
Dawer
d7239e5ab4 Fix visibility warnings 2021-06-01 00:03:47 +05:00
Dawer
a236bfa57a Lower binding pattern 2021-06-01 00:03:47 +05:00
Dawer
cf6f989a8d Lower bool literals 2021-06-01 00:03:47 +05:00
Dawer
d6d77e8a35 Treat ctor of unhandled type as non-exhaustive. 2021-06-01 00:03:47 +05:00
Dawer
e711abc290 Lower Pat::Path 2021-06-01 00:03:47 +05:00
Dawer
e50ce67631 Do not do match check if lowering failed. 2021-06-01 00:03:47 +05:00
Dawer
de6f430140 Fix panics on pattern_arena.borrow with ugly cloning 2021-06-01 00:03:46 +05:00
Dawer
975109051c Basic lowering hir_def::exrp::Pat -> typed HIR.
Pattern arena is broken
2021-06-01 00:03:46 +05:00
Dawer
2431ff5987 Handle unordered fields in struct patterns 2021-06-01 00:03:46 +05:00
Dawer
3ffcb2658c Complete field replacing 2021-06-01 00:03:46 +05:00
Dawer
3a85e47f6a Support bool literal patterns 2021-06-01 00:03:46 +05:00
Dawer
5a8a0b6269 Check enum patterns 2021-06-01 00:03:46 +05:00