Commit Graph

765 Commits

Author SHA1 Message Date
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