Aleksey Kladov
cfa3f679e9
internal: don't expose impl details out of hir
2021-08-29 18:55:25 +03:00
Aleksey Kladov
76b60efbfb
internal: improve compile times a bit
...
before after for cargo llvm-lines -q --lib --release -p ide_ssr | head -n 24
Lines Copies Function name
----- ------ -------------
297146 (100%) 12748 (100%) (TOTAL)
5970 (2.0%) 47 (0.4%) core::iter::traits::iterator::Iterator::try_fold
4750 (1.6%) 27 (0.2%) hashbrown::raw::RawTable<T,A>::resize
4080 (1.4%) 30 (0.2%) alloc::raw_vec::RawVec<T,A>::grow_amortized
3933 (1.3%) 69 (0.5%) alloc::raw_vec::RawVec<T,A>::current_memory
3668 (1.2%) 89 (0.7%) <core::result::Result<T,E> as core::ops::try_trait::Try>::branch
3500 (1.2%) 50 (0.4%) hashbrown::raw::RawTable<T,A>::drop_elements
3436 (1.2%) 33 (0.3%) hashbrown::raw::RawTable<T,A>::find
3415 (1.1%) 17 (0.1%) hashbrown::raw::RawTable<T,A>::rehash_in_place
3400 (1.1%) 50 (0.4%) <hashbrown::raw::RawIterRange<T> as core::iter::traits::iterator::Iterator>::next
2840 (1.0%) 20 (0.2%) alloc::raw_vec::RawVec<T,A>::allocate_in
2700 (0.9%) 30 (0.2%) core::alloc::layout::Layout::array
2666 (0.9%) 86 (0.7%) core::ptr::metadata::from_raw_parts_mut
2495 (0.8%) 50 (0.4%) core::option::Option<T>::map
2354 (0.8%) 38 (0.3%) alloc::alloc::box_free
2302 (0.8%) 7 (0.1%) ide_ssr::parsing::RuleBuilder::try_add
2146 (0.7%) 45 (0.4%) core::mem::replace
2070 (0.7%) 69 (0.5%) <alloc::raw_vec::RawVec<T,A> as core::ops::drop::Drop>::drop
1979 (0.7%) 16 (0.1%) hashbrown::map::HashMap<K,V,S,A>::insert
1926 (0.6%) 18 (0.1%) <core::iter::adapters::zip::Zip<A,B> as core::iter::adapters::zip::ZipImpl<A,B>>::next
1922 (0.6%) 62 (0.5%) core::fmt::ArgumentV1::new
1885 (0.6%) 13 (0.1%) alloc::raw_vec::RawVec<T,A>::shrink
Lines Copies Function name
----- ------ -------------
261717 (100%) 11666 (100%) (TOTAL)
5239 (2.0%) 42 (0.4%) core::iter::traits::iterator::Iterator::try_fold
4750 (1.8%) 27 (0.2%) hashbrown::raw::RawTable<T,A>::resize
3933 (1.5%) 69 (0.6%) alloc::raw_vec::RawVec<T,A>::current_memory
3536 (1.4%) 26 (0.2%) alloc::raw_vec::RawVec<T,A>::grow_amortized
3500 (1.3%) 50 (0.4%) hashbrown::raw::RawTable<T,A>::drop_elements
3400 (1.3%) 50 (0.4%) <hashbrown::raw::RawIterRange<T> as core::iter::traits::iterator::Iterator>::next
3124 (1.2%) 30 (0.3%) hashbrown::raw::RawTable<T,A>::find
2812 (1.1%) 14 (0.1%) hashbrown::raw::RawTable<T,A>::rehash_in_place
2604 (1.0%) 84 (0.7%) core::ptr::metadata::from_raw_parts_mut
2340 (0.9%) 26 (0.2%) core::alloc::layout::Layout::array
2302 (0.9%) 7 (0.1%) ide_ssr::parsing::RuleBuilder::try_add
2272 (0.9%) 16 (0.1%) alloc::raw_vec::RawVec<T,A>::allocate_in
2201 (0.8%) 35 (0.3%) alloc::alloc::box_free
2104 (0.8%) 44 (0.4%) core::mem::replace
2079 (0.8%) 42 (0.4%) <core::result::Result<T,E> as core::ops::try_trait::Try>::branch
2070 (0.8%) 69 (0.6%) <alloc::raw_vec::RawVec<T,A> as core::ops::drop::Drop>::drop
1926 (0.7%) 18 (0.2%) <core::iter::adapters::zip::Zip<A,B> as core::iter::adapters::zip::ZipImpl<A,B>>::next
1885 (0.7%) 13 (0.1%) alloc::raw_vec::RawVec<T,A>::shrink
1833 (0.7%) 13 (0.1%) hashbrown::raw::RawTable<T,A>::shrink_to
1771 (0.7%) 91 (0.8%) core::ptr::read
1701 (0.6%) 35 (0.3%) core::option::Option<T>::map
2021-08-29 18:49:16 +03:00
Florian Diebold
424dda8113
Refactor & improve handling of overloaded binary operators
...
Fixes #9971 . Also records them as method resolutions, which we could use
later.
2021-08-22 17:35:50 +02:00
Frank Steffahn
35a7fdd2c1
Fix two more “a”/“an” typos
2021-08-22 17:24:48 +02:00
Frank Steffahn
3a5a93595f
Fix typos “a”→“an”
2021-08-22 14:31:37 +02:00
bors[bot]
9e3517f8f3
Merge #9975
...
9975: minor: Fix panic caused by #9966 r=flodiebold a=flodiebold
Chalk can introduce new type variables when doing lazy normalization, so we have to do the proper 'fudging' after all.
Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2021-08-21 18:07:36 +00:00
Florian Diebold
df77e2448c
Fix panic caused by #9966
...
Chalk can introduce new type variables when doing lazy normalization, so
we have to do the proper 'fudging' after all.
2021-08-21 20:07:07 +02:00
Laurențiu Nicola
104d6124d7
Handle coercion on binary operator RHS
2021-08-21 17:54:45 +03:00
Florian Diebold
1791a35f9f
Determine expected parameters from expected return in calls
...
Fixes #9560
2021-08-21 14:33:31 +02:00
Florian Diebold
cd64353288
Adapt tests for correct behavior
2021-08-21 13:35:36 +02:00
Florian Diebold
5cff355059
Add another test
2021-08-21 13:35:34 +02:00
Lukas Wirth
95923c7b29
Fix imports
2021-08-19 17:33:58 +02:00
Jonas Schievink
4757679b9a
feat: type inference for if-let guards
2021-08-14 00:09:30 +02:00
Jonas Schievink
d568e7686a
Support if let
match guards
2021-08-13 00:25:14 +02:00
bors[bot]
baf1494374
Merge #9807
...
9807: Implicit `Sized` bounds r=iDawer a=iDawer
This should close #8984
`hir_ty`:
- Type parameters, associated types and `impl Trait` are `Sized` by deafault except `Self` in a trait.
- Implicit `Sized` bound is added to end of predicate list. It does not check if such bound is present already. Also it does not track the bound is implicit.
- Allowed ambiguous unsize coercion if Chalk returns definite guidance.
- Allowed ambiguous autoderef if Chalk returns definite guidance.
`hir_def`:
- `ItemTree` pretty printing shows `?Sized` bounds.
`HirDisplay`:
- `impl Trait` with weird bounds rendered correctly.
- `Sized`/`?Sized` bounds are not shown if they are default.
### Perf
`./target/rust-analyzer-baseline_8a843113 -q analysis-stats --memory-usage .`
```
Database loaded: 1.63s, 287minstr, 91mb
crates: 38, mods: 741, decls: 15914, fns: 11835
Item Collection: 26.80s, 73ginstr, 338mb
exprs: 318994, ??ty: 398 (0%), ?ty: 435 (0%), !ty: 174
Inference: 50.28s, 116ginstr, 516mb
Total: 77.08s, 189ginstr, 855mb
```
`./target/rust-analyzer-sized-fixed_ambig_coercion-de074fe6 -q analysis-stats --memory-usage .`
```
Database loaded: 1.63s, 287minstr, 91mb
crates: 38, mods: 741, decls: 15914, fns: 11835
Item Collection: 26.95s, 73ginstr, 338mb
exprs: 318994, ??ty: 398 (0%), ?ty: 435 (0%), !ty: 166
Inference: 96.39s, 234ginstr, 543mb
Total: 123.33s, 307ginstr, 881mb
```
Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
2021-08-12 17:55:29 +00:00
Dawer
6c366ade00
Clean up
2021-08-12 21:20:28 +05:00
Dawer
de074fe636
Accept ambiguous unsize coercion only if it has definite guidance.
2021-08-11 22:09:32 +05:00
Dawer
e89ad9f345
Allow ambiguous autoderef with defininte guidance.
...
This enables autoderefing types with inference variables inside.
2021-08-09 14:30:05 +05:00
Laurențiu Nicola
ab10ac7d92
Increase chalk overflow depth
2021-08-08 18:40:28 +03:00
ivan770
be3e70c604
Add reference here diagnostic
2021-08-08 10:12:40 +02:00
Dawer
14898729f4
Account sized bounds in parentheses printing inside of ptr/ref of rpit.
2021-08-08 00:54:38 +05:00
Florian Diebold
16ab75a83a
Upgrade Chalk
2021-08-07 13:12:35 +02:00
Florian Diebold
ac4f3e61f8
Fix binders with bare dyn trait
...
Fixes #9639 .
2021-08-05 22:44:38 +02:00
Dawer
98ae530f2a
Fix missing ?Sized bounds in tests.
2021-08-04 20:24:52 +05:00
Dawer
0f6621fbfa
Fix tests.
2021-08-04 20:20:14 +05:00
Dawer
5f2486e9a8
Handle impl ?Sized
. Fix tests.
2021-08-04 20:20:10 +05:00
Dawer
421979bc68
HirDisplay prints ?Sized
bounds now; impl Trait: Sized
by default.
2021-08-04 20:05:46 +05:00
Dawer
d9e6377b91
adjust hir_def::TypeBound::as_path
2021-08-04 19:49:19 +05:00
Dawer
b217e9cc50
add implicit Sized bound to associated types
2021-08-04 19:41:05 +05:00
Dawer
8f2a040d10
add implicit sized to impl Trait
parameters
2021-08-04 19:40:57 +05:00
Dawer
72002b401d
internal: allow ambiguous unsize coercion.
2021-08-04 19:15:23 +05:00
Dawer
3981373b93
internal: add implicit Sized
bounds to type parameters.
2021-08-04 19:04:21 +05:00
Jade
e3a67ccec6
tree-wide: fix rustdoc warnings, add some links
2021-08-03 21:34:20 -07:00
Aleksey Kladov
12d7f5b56e
internal: explain that we don't ref
in style.md
2021-08-02 15:59:28 +03:00
Lukas Wirth
1edbaa29f9
Wrap inner tail expressions in MissingOkOrSomeInTailExpr
2021-07-31 20:00:09 +02:00
bors[bot]
8232804d3e
Merge #9706
...
9706: minor: perf and grammar fixes r=lnicola a=lnicola
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-07-29 16:14:10 +00:00
Alexander Gonzalez
e57ad5456c
fix: Typos
2021-07-27 18:31:21 -04:00
Laurențiu Nicola
ea0014c500
Remove some redundant clones
2021-07-27 21:32:55 +03:00
Jonas Schievink
b596c32a41
Resolve tuple variants in value namespace
2021-07-22 13:40:18 +02:00
bors[bot]
0bee7cb716
Merge #9453
...
9453: Add first-class limits. r=matklad,lnicola a=rbartlensky
Partially fixes #9286 .
This introduces a new `Limits` structure which is passed as an input
to `SourceDatabase`. This makes limits accessible almost everywhere in
the code, since most places have a database in scope.
One downside of this approach is that whenever you query limits, you
essentially do an `Arc::clone` which is less than ideal.
Let me know if I missed anything, or would like me to take a different approach!
Co-authored-by: Robert Bartlensky <bartlensky.robert@gmail.com>
2021-07-22 10:33:05 +00:00
Jonas Schievink
837eec8dab
filter visiblities when resolving in extern crate
2021-07-21 17:51:56 +02:00
Florian Diebold
7c00ca2f51
Revert "Merge #9655 "
...
This reverts commit 8c8c6fb73d
, reversing
changes made to ec7b4cbf8f
.
2021-07-20 22:53:39 +02:00
Robert Bartlensky
0b3d0cde8b
Add Limit
struct.
...
Fixes #9286 .
2021-07-19 13:26:11 +01:00
Florian Diebold
ae22050a42
Determine expected parameters from expected return in calls
...
Fixes #9560
2021-07-18 20:56:44 +02:00
Florian Diebold
eb2cc1036a
Adapt tests for correct behavior
2021-07-15 20:02:48 +02:00
Florian Diebold
44d3c32922
Add test for #9560
2021-07-11 16:14:39 +02:00
bors[bot]
f83f069f94
Merge #9552
...
9552: internal: `add_explicit_type` respects coercions r=Veykril a=Veykril
or so I'd like to say but there is one odd case here where it doesn't work(see [review](https://github.com/rust-analyzer/rust-analyzer/pull/9552#discussion_r667351856 ))
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/6107
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-10 16:25:58 +00:00
Lukas Wirth
576e3a4e12
add_explicit_type
respects coercions
2021-07-10 18:19:46 +02:00
Lukas Wirth
d5a43d1f85
Resolve type adjustments
2021-07-10 18:19:23 +02:00
Laurențiu Nicola
df729eda69
Bump chalk
2021-07-10 18:58:14 +03:00
bors[bot]
10273a7d63
Merge #9545
...
9545: Record autoderef adjustments r=flodiebold a=Veykril
cc #9475
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-10 10:27:16 +00:00
Lukas Wirth
69e6511820
Record autoderef adjustments
2021-07-10 12:26:18 +02:00
bors[bot]
eab5d985ec
Merge #9512
...
9512: Record coercion adjustments r=Veykril a=Veykril
cc https://github.com/rust-analyzer/rust-analyzer/issues/9475
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-09 14:07:23 +00:00
Lukas Wirth
9272942b92
Use CoerceMany
in BreakableContext
2021-07-09 15:51:07 +02:00
Florian Diebold
d674d7185d
Represent opaque types with TyKind::OpaqueType
...
... instead of using `AliasTy`. Chalk turns the alias type into the
placeholder during unification anyway, which confuses our method
resolution logic.
Fixes #9530 .
2021-07-08 21:40:35 +02:00
Lukas Wirth
e968d834ca
Add some more adjustment test annotations
2021-07-08 15:03:57 +02:00
Lukas Wirth
349f2535fb
Copy some comments from rustc
2021-07-08 14:31:16 +02:00
Lukas Wirth
f73d0ee439
Minor cleanup
2021-07-08 14:27:54 +02:00
Lukas Wirth
64a1b26b8d
Implement CoerceMany
2021-07-08 14:16:23 +02:00
Lukas Wirth
9779526d8f
Record coercion adjustments
2021-07-08 13:07:24 +02:00
Laurențiu Nicola
3b2602cbb2
Don't unify array elements with their arrays
2021-07-08 12:55:00 +03:00
Jonas Schievink
cb63b021ff
Implement LUB coercion of array elements
2021-07-07 22:50:20 +02:00
Aleksey Kladov
86720f2953
minor: drop dummy authors field
2021-07-05 14:19:41 +03:00
bors[bot]
16871f6f93
Merge #9428
...
9428: fix: Fix deduction of `dyn Fn` closure parameter types r=flodiebold a=jonas-schievink
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-07-02 12:49:34 +00:00
Jonas Schievink
835d1cec59
Substitute self type instead of fusing binders
2021-07-02 00:16:36 +02:00
Jonas Schievink
cee9a7e26a
Bind the right number of variables in the FnPointer
2021-07-01 20:54:25 +02:00
Jonas Schievink
e6fdb38d38
Use as_tuple()
2021-07-01 20:45:47 +02:00
Jonas Schievink
b5a2289676
Remove unneeded shifted_in
2021-06-30 15:45:00 +02:00
Jonas Schievink
b502a10b1e
update comment
2021-06-30 15:13:59 +02:00
Jonas Schievink
88a86d4ff9
Fix deduction of dyn Fn
closure parameter types
2021-06-30 15:04:04 +02:00
Lukas Wirth
af739731db
Implement TypeRef::ForLifetime
2021-06-30 01:34:54 +02:00
Florian Diebold
a1120b6879
Fix benchmark_include_macro
2021-06-20 19:37:45 +02:00
Florian Diebold
78419779f1
More cleanups, use check
for display_source_code
tests
2021-06-20 19:12:06 +02:00
Florian Diebold
0219b145ea
Clean up coercion tests
2021-06-20 19:12:06 +02:00
Florian Diebold
04fbdce426
Unify check_mismatches and check_types
2021-06-20 19:12:06 +02:00
Florian Diebold
679bb21633
Add coverage mark for block local impls
2021-06-20 19:12:06 +02:00
Aleksey Kladov
89a0e58393
internal: use minicore deref more
2021-06-18 22:47:02 +03:00
Aleksey Kladov
991919e71f
internal: add index to minicore
2021-06-18 22:37:34 +03:00
Aleksey Kladov
73b3ee664e
minor: use minicore
2021-06-18 22:25:35 +03:00
Laurențiu Nicola
e3ce88f6f2
Minor clippy perf fixes
2021-06-18 14:40:51 +03:00
Lukas Wirth
95c8c65139
Nest all the or-patterns!
2021-06-17 17:37:14 +02:00
Aleksey Kladov
ee7b649d44
internal: switch some tests to minicore
2021-06-16 22:54:57 +03:00
Aleksey Kladov
604267088c
internal: add iterator to minicore
2021-06-16 22:48:48 +03:00
Aleksey Kladov
8a4d9bb80a
internal: add fn to minicore
2021-06-16 12:15:45 +03:00
Aleksey Kladov
0798cce9e5
internal: add result to minicore
2021-06-15 23:07:25 +03:00
Aleksey Kladov
2870d2bade
internal: add option to minicore
2021-06-15 22:59:51 +03:00
Aleksey Kladov
3efe5c3426
internal: add future to minicore
2021-06-15 22:49:00 +03:00
Aleksey Kladov
09c4013ec0
internal: switch some tests to minicore
2021-06-15 22:02:29 +03:00
Aleksey Kladov
ee13e895e3
internal: switch some tests to minicore
2021-06-15 21:57:56 +03:00
Aleksey Kladov
0bb1f1bc90
internal: add ranges to minicore
2021-06-15 21:45:25 +03:00
Aleksey Kladov
f4b52682da
internal: unindent some tests
2021-06-15 21:39:44 +03:00
Aleksey Kladov
b737b894cb
internal: switch some tests to minicore
2021-06-15 21:36:50 +03:00
Aleksey Kladov
7ebac5e54c
internal: switch some tests to minicore
2021-06-15 21:34:26 +03:00
Aleksey Kladov
0475201538
internal: switch some tests to minicore
2021-06-15 21:19:51 +03:00
Aleksey Kladov
f841369fee
internal: switch some tests to minicore
2021-06-15 21:11:53 +03:00
Aleksey Kladov
f521e41853
internal: introduce minicore -- a subset of libcore for testing
2021-06-15 21:03:08 +03:00
bors[bot]
fa4c851619
Merge #9278
...
9278: internal: document that we don't #[ignore] tests r=matklad a=matklad
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-06-15 08:48:15 +00:00
Aleksey Kladov
3f4ad44082
internal: document that we don't #[ignore] tests
2021-06-15 11:46:47 +03:00
Aleksey Kladov
06f5d6f640
internal: don't pull tracing via chalk
2021-06-14 20:41:08 +03:00
bors[bot]
5a8ddb4b2d
Merge #9260
...
9260: tree-wide: make rustdoc links spiky so they are clickable r=matklad a=lf-
Rustdoc was complaining about these while I was running with --document-private-items and I figure they should be fixed.
Co-authored-by: Jade <software@lfcode.ca>
2021-06-14 07:16:48 +00:00
Jade
20b325c7d5
tree-wide: make rustdoc links spiky so they are clickable
2021-06-13 21:58:05 -07:00
Aleksey Kladov
935c53b92e
internal: use cov-mark rather than bailing out diagnostic
2021-06-13 21:55:51 +03:00
Aleksey Kladov
fc30c5ccbe
internal: refactor incorrect case diagnostics
2021-06-13 21:09:03 +03:00
bors[bot]
cc6d761a99
Merge #9246
...
9246: internal: unified missing fields diagnostic r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-06-13 12:49:37 +00:00
Aleksey Kladov
6383252cc2
internal: unified missing fields diagnostic
2021-06-13 15:48:54 +03:00
bors[bot]
be9742809c
Merge #9244
...
9244: feat: Make block-local trait impls work r=flodiebold a=flodiebold
As long as either the trait or the implementing type are defined in the same block.
CC #8961
Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2021-06-13 11:13:31 +00:00
Florian Diebold
5ca71a1990
Make block-local trait impls work
...
As long as either the trait or the implementing type are defined in the
same block.
2021-06-13 13:00:34 +02:00
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