Commit Graph

124 Commits

Author SHA1 Message Date
bors
1da9156b0d Auto merge of #12982 - jridgewell:into_future, r=Veykril
Implement IntoFuture type inference

One of my projects is using [IntoFuture](https://doc.rust-lang.org/std/future/trait.IntoFuture.html) to make our async code a little less verbose. However, rust-analyzer can't infer the output type of an await expression if the value uses `IntoFuture` to convert into another type. So we're getting `{unknown}` types everywhere since switching.

`foo.await` itself [desugars](e4417cf020/compiler/rustc_ast_lowering/src/expr.rs (L644-L658)) into a `match into_future(foo) {}`, with every `Future` impl getting a [default](e4417cf020/library/core/src/future/into_future.rs (L131-L139)) `IntoFuture` implementation. I'm not sure if we want to disable the old `future_trait` paths, since this only recently [stabilize](https://github.com/rust-lang/rust/pull/98718).
2022-08-18 07:37:47 +00:00
Ryo Yoshida
12abaf8ddd
fix: resolve associated types of bare dyn types 2022-08-18 07:05:41 +09:00
Dominik Gschwind
ad7a1ed8cc
fix: Fix panics on GATs involving const generics
This workaround avoids constant crashing of rust analyzer when using GATs with const generics,
even when the const generics are only on the `impl` block.

The workaround treats GATs as non-existing if either itself or the parent has const generics and
removes relevant panicking code-paths.
2022-08-16 17:30:17 +02:00
Jonas Schievink
8c60813096 Fix lowering of empty macro expressions in trailing position 2022-08-15 18:01:58 +02:00
Ryo Yoshida
ffc6b42901
fix: infer byte string pattern as &[u8] when matched against slices 2022-08-10 19:17:13 +09:00
Justin Ridgewell
5810c8188a Implement IntoFuture type inference 2022-08-08 21:05:56 -04:00
KaDiWa
232176b46a
remove imports that are also in edition 2021's prelude 2022-08-09 01:16:32 +02:00
oxalica
326ffee5b7 Returns the old value for la_arena::ArenaMap::insert 2022-08-07 04:53:23 +08:00
Lukas Wirth
d6e78b04d0 feat: Handle operators like their trait functions in the IDE 2022-08-05 14:16:36 +02:00
Lukas Wirth
1f8daa180f fix: Honor ref expressions for compute_ref_match completions 2022-07-27 13:48:26 +02:00
Ryo Yoshida
805ac666ca
fix: consider assignee expressions in record fields exhaustiveness check 2022-07-24 22:40:04 +09:00
Ryo Yoshida
64758bd481
Add info whether it's assignee expr to relevant HIR Expr variants 2022-07-24 22:40:00 +09:00
Ryo Yoshida
fb063d360c
Add ellipsis to HIR RecordLit 2022-07-24 17:10:31 +09:00
bors
84a6fac37a Auto merge of #12841 - Veykril:query-fix, r=Veykril
fix: Fix `trait_impls_in_deps_query` being called directly instead of as a query

Fixes the inlay hint performance regression introdcuced by https://github.com/rust-analyzer/rust-analyzer/issues/12549
2022-07-21 08:23:19 +00:00
Lukas Wirth
cfad882745 fix: Fix trait_impls_in_deps_query being called directly instead of as a query 2022-07-21 10:23:07 +02:00
Amos Wenger
ade31ad757 Rename proc macro server from 'Rustc' to 'RustAnalyzer' 2022-07-20 15:40:23 +02:00
Amos Wenger
7e285e1ef5 Run cargo fmt 2022-07-20 15:06:15 +02:00
Amos Wenger
816f7fe12a Run cargo fix --edition-idioms 2022-07-20 15:02:08 +02:00
Amos Wenger
23d25a3094 Enable extra warnings required by rust-lang/rust 2022-07-20 15:00:17 +02:00
Amos Wenger
1b416473a3 Upgrade to expect-test@1.4.0
cf. https://github.com/rust-analyzer/expect-test/issues/33
cf. https://github.com/rust-lang/rust/pull/99444#issuecomment-1188844202
2022-07-19 13:00:45 +02:00
bors
22e53f1d33 Auto merge of #12549 - bitgaoshu:goto_where_trait_m_impl, r=Veykril
feat: Go to implementation of trait methods

try goto where the trait method implies,  #4558
2022-07-18 16:29:23 +00:00
bors
db6a85d358 Auto merge of #12778 - Logarithmus:feature/fix-negative-const-generics, r=flodiebold
Support negative, `char` & `bool` const generics

Before:
![Before](https://user-images.githubusercontent.com/29541480/179379832-0c3b2a74-fef6-427e-b89f-7e31d9c37b3d.png)

After:
![After](https://user-images.githubusercontent.com/29541480/179379863-b62475dd-e7bf-41f2-b437-08dfe55951af.png)

I tried to implement stuff like `Const<{NUM1 + 3 + NUM2}>` by using already existing constant evaluation mechanism for ordinary constants, but turned out to be harder than I thought, maybe because I've never ever tinkered with compilers before
2022-07-17 17:17:39 +00:00
Artur Sinila
83177a7cfe
fix: address suggestions 2022-07-17 18:22:11 +03:00
iDawer
a0fd58bbbe Check for local IDs belong to same definition 2022-07-17 11:43:08 +05:00
Artur Sinila
a96f0aa7cd
feat: support negative const generic parameters
* feat: support `bool` & `char` const generics
2022-07-17 04:18:53 +03:00
Jonas Schievink
6c6ae965ba Update remaining GitHub URLs 2022-07-08 15:44:49 +02:00
Laurențiu Nicola
78beb4c444 Bump chalk 2022-07-03 10:22:10 +03:00
Laurențiu Nicola
5381811368 Bump tracing-subscriber 2022-07-03 10:12:58 +03:00
Laurențiu Nicola
791f2a0bec Bump smallvec 2022-07-03 10:09:35 +03:00
Ryo Yoshida
649e1f54cf
fix: report type mismatch on identifier in destructuring assignments 2022-07-03 03:29:15 +09:00
Ryo Yoshida
afdbd6cce2
fix: infer lhs first on ordinary assignment expressions 2022-07-03 03:29:02 +09:00
a-kenji
f2963cf8ff fix: typos in hir-ty 2022-07-02 17:19:06 +02:00
Florian Diebold
e71519572c Add tests for #12669 2022-07-01 19:00:07 +02:00
Lukas Wirth
e5e5a0932d Fix blocks not considering stmt without semi as tails 2022-07-01 16:25:52 +02:00
Lukas Wirth
58d5c69a63 Fix Expr::MacroStmts using wrong scopes 2022-07-01 15:34:29 +02:00
Lukas Wirth
9165e3b381 Update hir-ty test outputs 2022-07-01 15:21:55 +02:00
Lukas Wirth
531e152390 fix: Simplify macro statement expansion handling 2022-07-01 14:49:30 +02:00
bors
642084093a Auto merge of #12634 - iDawer:match-check.witnesses, r=flodiebold
feat: Show witnesses of non-exhaustiveness in `missing-match-arm` diagnostic

Shamelessly copied from rustc. Thus reporting format is same.

This extends public api  `hir::diagnostics::MissingMatchArms` with `uncovered_patterns: String` field. It does not expose data for implementing a quick fix yet.

-----
Worth to note: current implementation does not give a comprehensive list of missing patterns. Also mentioned in [paper](http://moscova.inria.fr/~maranget/papers/warn/warn.pdf):

> One may think that algorithm I should make an additional effort to provide more
> non-matching values, by systematically computing recursive calls on specialized
> matrices when possible, and by returning a list of all pattern vectors returned by
> recursive calls. We can first observe that it is not possible in general to supply the
> users with all non-matching values, since the signature of integers is (potentially)
> infinite.
2022-06-30 14:51:58 +00:00
iDawer
e417992674 Add static assertions for some unreachble paths 2022-06-30 18:36:05 +05:00
iDawer
461c0cc07a Correct wording 2022-06-30 17:19:03 +05:00
bors
2ff505ab48 Auto merge of #12428 - lowr:experimental/destructuring-assignment, r=flodiebold
feat: implement destructuring assignment

This is an attempt to implement destructuring assignments, or more specifically, type inference for [assignee expressions](https://doc.rust-lang.org/reference/expressions.html#place-expressions-and-value-expressions).

I'm not sure if this is the right approach, so I don't even expect this to be merged (hence the branch name 😉) but rather want to propose one direction we could choose. I don't mind getting merged if this is good enough though!

Some notes on the implementation choices:

- Assignee expressions are **not** desugared on HIR level unlike rustc, but are inferred directly along with other expressions. This matches the processing of other syntaxes that are desugared in rustc but not in r-a. I find this reasonable because r-a only needs to infer types and it's easier to relate AST nodes and HIR nodes, so I followed it.
- Assignee expressions obviously resemble patterns, so type inference for each kind of pattern and its corresponding assignee expressions share a significant amount of logic. I tried to reuse the type inference functions for patterns by introducing `PatLike` trait which generalizes assignee expressions and patterns.
  - This is not the most elegant solution I suspect (and I really don't like the name of the trait!), but it's cleaner and the change is smaller than other ways I experimented, like making the functions generic without such trait, or making them take `Either<ExprId, PatId>` in place of `PatId`.

in case this is merged:
Closes #11532
Closes #11839
Closes #12322
2022-06-30 09:14:12 +00:00
bitgaoshu
dcb4837b2d WellFormed -> Holds 2022-06-26 23:09:06 +08:00
iDawer
fb6278e750 Reduce intermediate allocations while printing witnesses 2022-06-25 20:08:00 +05:00
Lukas Wirth
2642f64570 internal: Simplify 2022-06-23 20:08:29 +02:00
Florian Diebold
36fadc4224 Fix unstable feature use 2022-06-23 16:05:59 +02:00
Florian Diebold
29f01cd9d2 Various cleanups
- remove Valid, it serves no purpose and just obscures the diff
 - rename some things
 - don't use is_valid_candidate when searching for impl, it's not necessary
2022-06-23 14:38:28 +02:00
bitgaoshu
1064c7513a reformat code 2022-06-23 14:01:22 +02:00
bitgaoshu
1ef5e14c2c goto where trait method impl 2022-06-23 14:01:22 +02:00
iDawer
4ff9bedbed Display witnesses of non-exhaustive match
Reporting format follows rustc and shows at most three witnesses.
2022-06-20 15:48:09 +05:00
bors
4f2a67b26f Auto merge of #12513 - Veykril:ty-utils, r=Veykril
internal: Simplify `hir_ty::utils`
2022-06-12 14:08:08 +00:00
Lukas Wirth
9153f17382 internal: Simplify hir_ty::utils 2022-06-12 16:07:08 +02:00
bors
d513f657a3 Auto merge of #12509 - Veykril:ty-utils, r=Veykril
internal: Remove `Generics::type_iter` in favor of `Generics::iter`
2022-06-12 12:40:57 +00:00
Lukas Wirth
7a0ab1358c internal: Remove Generics::type_iter in favor of Generics::iter 2022-06-12 14:40:37 +02:00
bors
eacade27ce Auto merge of #12455 - bitgaoshu:fix_12441, r=flodiebold
fix: #12441 False-positive type-mismatch error with generic future

I think the reason is same with #11815.
add ```Sized``` bound for ```AsyncBlockTypeImplTrait```.
2022-06-12 09:01:00 +00:00
Lukas Wirth
76ae5434fa internal: Bump Dependencies 2022-06-10 17:30:02 +02:00
bitgaoshu
1a97ab34db fix: #12441 False-positive type-mismatch error with generic future 2022-06-03 10:47:41 +08:00
Ryo Yoshida
b7a4175cbb
Implement type inference for assignee expressions 2022-06-01 01:28:12 +09:00
Ryo Yoshida
62d6b5a594
Generalize some inference functions for patterns 2022-06-01 01:22:11 +09:00
Ryo Yoshida
c1c867506b
Add Expr::Underscore 2022-06-01 01:21:57 +09:00
bors
c2099fe941 Auto merge of #12336 - bitgaoshu:mismatch, r=flodiebold
fix: #12267  type-mismatch when using equals w/ a trait bound
2022-05-31 09:48:54 +00:00
Ryo Yoshida
be2fa2b31b
fix overflow during tuple struct type inference 2022-05-29 16:22:33 +09:00
Roland Ruckerbauer
86bb27f1a4 Fix inference when pattern matching a tuple field with a wildcard. 2022-05-23 12:24:54 +02:00
Laurențiu Nicola
8b56d42db9 Increase defalt chalk overflow depth to match max solver size 2022-05-22 18:10:38 +03:00
bitgaoshu
7c5e97221f mismatch 2022-05-21 17:26:03 +08:00
Jonas Schievink
60a2ab4c67 Rename Expr::Lambda to Expr::Closure 2022-05-20 15:40:32 +02:00
bors
825ce48180 Auto merge of #12271 - bitgaoshu:box_with_expec, r=flodiebold
fix #12227 Type mismatch error shown

add box expectation hint
2022-05-16 15:00:36 +00:00
bitgaoshu
e362929fa1 add box expection hint 2022-05-16 21:17:00 +08:00
bors
1dc25e51a0 Auto merge of #12253 - Veykril:bm, r=Veykril
feat: Add binding mode inlay hints

![image](https://user-images.githubusercontent.com/3757771/168427387-2f299438-a0cc-496b-a9a5-d689ef6a2b55.png)
2022-05-16 11:16:22 +00:00
Aleksey Kladov
57cb65bb7a internal: vendor lsp-server 2022-05-14 21:15:43 +01:00
Lukas Wirth
6b696fced8 feat: Add binding mode inlay hints 2022-05-14 14:58:35 +02:00
Jonas Schievink
9bd11459ba Revert "Auto merge of #12149 - jonas-schievink:literally-just-a-literal, r=jonas-schievink"
This reverts commit cc9ae2b89e, reversing
changes made to 7dfd1cb572.
2022-05-13 15:08:14 +02:00
Jonas Schievink
2a755495d0 Add tests 2022-05-05 16:28:59 +02:00
iDawer
970276b559 'inference': collect RPIT obligations
Collect obligations from RPITs (Return Position `impl Trait`) of a function which is being inferred.
This allows inferring {unknown}s from RPIT bounds.
2022-05-03 15:59:12 +05:00
Peh
1f011fa4a3 style: rename crates to kebab case 2022-05-01 10:48:58 +00:00