Commit Graph

3181 Commits

Author SHA1 Message Date
kjeremy
8d2068cf32 Update insta to 0.9.0 and cargo update 2019-07-31 10:05:00 -04:00
bors[bot]
1af7738c28 Merge #1627
1627: Hide ignored lines in rustdoc r=kjeremy a=rizakrko

This fixes #1620.

Co-authored-by: Roman Stoliar <rizakrko@rambler.ru>
2019-07-31 12:09:22 +00:00
Roman Stoliar
facc7a35a5 Fixed review comments 2019-07-30 21:25:51 +03:00
Evgenii P
06c3de310e rustfmt 2019-07-30 21:02:29 +07:00
Evgenii P
e7cdbe795a Fix flip comma assist 2019-07-30 20:33:58 +07:00
Roman Stoliar
1c11d7b1d8 Hide comments in rust section of doc comments 2019-07-30 03:46:38 +03:00
Phil Ellison
e6113c0998 Add merge_match_arm assist, bump rowan to 0.6.1 2019-07-29 21:59:52 +01:00
bors[bot]
a5fe9f7a87 Merge #1604
1604: Fix failing type interference for floating point literal r=matklad a=theotherphil

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/1592

Co-authored-by: Phil Ellison <phil.j.ellison@gmail.com>
2019-07-29 19:02:39 +00:00
Phil Ellison
d79dc38e99 Move assist test, add literal type inference test 2019-07-29 19:02:03 +01:00
bors[bot]
359b3376b3 Merge #1601
1601: Inline snapshots for tests r=matklad a=theotherphil

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/1127.

The "cargo format" commits are required to get the formatting tests to pass. However, they actually mess up the formatting.

Co-authored-by: Phil Ellison <phil.j.ellison@gmail.com>
2019-07-29 12:54:40 +00:00
bors[bot]
9e2925f340 Merge #1621
1621: Document AssistBuilder r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-07-29 12:44:14 +00:00
Aleksey Kladov
61739b0c17 Document AssistBuilder
closes #1603
2019-07-29 15:43:34 +03:00
bors[bot]
bf1369cdef Merge #1606
1606: Add `if let`, `while let` and match arm inlay hints r=matklad a=SomeoneToIgnore

<img width="693" alt="image" src="https://user-images.githubusercontent.com/2690773/62013363-152f1d80-b19a-11e9-90ea-07568757baa2.png">

Add more inline hints support.
Looks like `while let` type inference support is missing currently, so the corresponding hint tests lack the actual results.

I've also could not find a good way to distinguish between `a` and `b` pats in the following expressions:
`if let Some(Test { a: None, b: y }) = &test {};`

In this case we don't need to add a hint for first pat (`a: None`), since it's matched against the particular enum variant and need a hint for `y`, since it's a new variable.
But both `a` and `b` are `BIND_PAT` with similar contents, so looks like there's nothing I can check for to find any differences.

I don't display any hints for such cases now, to avoid confusion, but would be nice to know if there's a way to fix this behavior.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2019-07-29 12:30:39 +00:00
Alexander Andreev
3629268f71 Fixed request changes. 2019-07-29 15:16:58 +03:00
Alexander Andreev
538ec1122b Added resolve modules inside inline module
#1510
2019-07-29 09:54:40 +03:00
Kirill Bulatov
b8f95f42e1 Support destructuring patterns 2019-07-29 00:33:10 +03:00
Phil Ellison
fab8e9bb8a cargo format 2019-07-28 20:54:37 +01:00
Phil Ellison
4fd7ad908b Add special case for f32 and f43 suffices on Literal.kind 2019-07-28 20:47:44 +01:00
Phil Ellison
578bc05ca4 Add issue link and trailing newline 2019-07-28 20:25:06 +01:00
Phil Ellison
fe1b1dd7d9 More direct failing test 2019-07-28 19:52:30 +01:00
Phil Ellison
8e1a14a098 Add failing test 2019-07-28 18:41:29 +01:00
Phil Ellison
67e75ca126 Rerun cargo format, to make tests pass and formatting incorrect 2019-07-28 12:45:01 +01:00
Phil Ellison
44b2642900 Remove vertical ellipses in references.cs 2019-07-28 12:37:03 +01:00
Phil Ellison
1b74eed8ca Remove vertical ellipses from tests in complete_snippet.rs and presentation.rs 2019-07-28 12:33:21 +01:00
Phil Ellison
46c07ed578 Remove vertical ellipses from tests in complete_scope.rs 2019-07-28 12:28:14 +01:00
Phil Ellison
5c4df97996 cargo format 2019-07-28 12:08:06 +01:00
Phil Ellison
9f6909c0ce Inline snapshot for test_file_structure (less clear that this one is a good idea) 2019-07-28 12:01:28 +01:00
Phil Ellison
a72331f223 Inline snapshots for all tests in runnables.rs 2019-07-28 11:57:56 +01:00
Phil Ellison
8f71614bdd Inline snapshots for all tests in references.rs 2019-07-28 11:52:17 +01:00
Phil Ellison
69244a6e18 Inline snapshots for all tests in complete_snippet, remove now-unused check_completion 2019-07-28 11:45:03 +01:00
Phil Ellison
460423e66c Inline snapshots for all tests in presentation.rs 2019-07-28 11:35:48 +01:00
Phil Ellison
eb7d1b0fee Inline snapshots for all tests in complete_scope.rs 2019-07-28 11:24:29 +01:00
Phil Ellison
164ba6092c Remove unused highlights_code_inside_macro snapshot, inline rename_mod_in_dir snapshot 2019-07-28 10:42:31 +01:00
Aleksey Kladov
e29cbcbedd it's a good idea to build extension before installing it 2019-07-27 23:02:03 +03:00
Aleksey Kladov
ecb1327fed Overhaul installation process
The new commands are

$ cargo install-ra --client-code
$ cargo install-ra --server --jemalloc
2019-07-27 14:35:18 +03:00
Kirill Bulatov
5169a9d498 Improve inlay hinting for types
Add hints for types in for loop expressions.
Resolve types for every tuple parameter.
Refactor the code.
2019-07-26 18:06:31 +03:00
Kirill Bulatov
dbbb0beb3e Make Analysis api cancellable 2019-07-25 20:22:41 +03:00
Aleksey Kladov
459241f272 move syntax tests to unit tests 2019-07-24 12:49:19 +03:00
bors[bot]
bf3030404e Merge #1584
1584: switch to upstream unescape r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-07-24 09:03:26 +00:00
Aleksey Kladov
2473cb6a5c switch to upstream unescape 2019-07-24 11:47:28 +03:00
bors[bot]
a971c6d32d Merge #1583
1583: ⬆️ rowan r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-07-24 08:44:40 +00:00
Aleksey Kladov
c79eea9fc1 ⬆️ rowan 2019-07-24 11:28:53 +03:00
bors[bot]
25921f5a5f Merge #1573
1573: fix: parse box syntax inside parentheses r=matklad a=csmoe

r? @matklad 

Co-authored-by: csmoe <csmoe@msn.com>
2019-07-24 08:27:46 +00:00
Ekaterina Babshukova
8e49bb664a show local variable types in completion 2019-07-23 19:26:27 +03:00
bors[bot]
5f3ff157e3 Merge #1549
1549: Show type lenses for the resolved let bindings r=matklad a=SomeoneToIgnore

Types that are fully unresolved are not displayed:

<img width="279" alt="image" src="https://user-images.githubusercontent.com/2690773/61518122-8e4ba980-aa11-11e9-9249-6d9f9b202e6a.png">

A few concerns that I have about the current implementation:

* I've adjusted the `file_structure` API method to return the information about the `let` bindings.
Although it works fine, I have a feeling that adding a new API method would be the better way.
But this requires some prior discussion, so I've decided to go for an easy way with an MVP. 
Would be nice to hear your suggestions.

* There's a hardcoded `{undersolved}` check that I was forced to use, since the method that resolves types returns a `String`. 
Is there a better typed API I can use? This will help, for instance, to add an action to the type lenses that will allow us to navigate to the type.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2019-07-23 09:51:40 +00:00
Kirill Bulatov
8f3377d9f9 Code review fixes 2019-07-22 23:25:13 +03:00
kjeremy
ce77291ca4 flexi_logger 0.14 2019-07-22 13:13:55 -04:00
Aleksey Kladov
700669bbd0 kill old lexer 2019-07-22 17:56:19 +03:00
Aleksey Kladov
75761c0e47 add rustc_lexer 2019-07-22 17:47:33 +03:00
csmoe
8fe58c3598 fix: parse box syntax inside parentheses 2019-07-22 20:52:10 +08:00
Kirill Bulatov
25398ad30d Use SmolStr for the type text 2019-07-22 00:47:44 +03:00
Kirill Bulatov
d32774b464 Fix the string conversions 2019-07-22 00:16:07 +03:00
Kirill Bulatov
31aef808d9 Merge branch 'master' into add-type-lenses 2019-07-22 00:10:29 +03:00
Kirill Bulatov
ba76017d2e Do not show the lens with type hints 2019-07-21 23:48:54 +03:00
Kirill Bulatov
09c7c86696 Resolve types on the server 2019-07-21 23:44:37 +03:00
Kirill Bulatov
24784c60df Code review fixes 2019-07-21 20:51:27 +03:00
bors[bot]
443061e752 Merge #1570
1570: switch to upstream rowan's API r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-07-21 13:48:46 +00:00
Ekaterina Babshukova
5fe19d2fbd provide completion in struct patterns 2019-07-21 14:41:33 +03:00
Aleksey Kladov
773ad2edb3 simiplify 2019-07-21 13:34:15 +03:00
Aleksey Kladov
d52ee59a71 streamline API 2019-07-21 13:28:58 +03:00
Aleksey Kladov
62be91b82d minor, move type 2019-07-21 13:08:32 +03:00
Kirill Bulatov
201b344f2b Refactor server api 2019-07-20 23:45:26 +03:00
Kirill Bulatov
761fc71083 Fix tuple type lens resolution 2019-07-20 21:39:04 +03:00
Kirill Bulatov
dfa8373766 Do not show a lens when the type is declared explicitly 2019-07-20 21:39:04 +03:00
Kirill Bulatov
1ce864ac62 Fix rebase issue 2019-07-20 21:39:04 +03:00
Kirill Bulatov
b6c662c573 If possible, show type lenses for the let bindings 2019-07-20 21:39:04 +03:00
Aleksey Kladov
c9cfd57eea switch to upstream rowan's API 2019-07-20 20:12:06 +03:00
bors[bot]
3983ccca4a Merge #1566
1566: align SyntaxText API with upstream r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-07-20 13:52:33 +00:00
Aleksey Kladov
f6bcc2d745 align SyntaxText API with upstream 2019-07-20 16:52:11 +03:00
bors[bot]
dac6adbef9 Merge #1562
1562: Continue support for .await r=matklad a=unrealhoang

- add await expr to ast and HIR Expr
- infer type for `.await`

Co-authored-by: Unreal Hoang <unrealhoang@gmail.com>
2019-07-20 11:27:50 +00:00
Unreal Hoang
bacf926a77
infer type for await
by projecting inner_ty to Future::Output alias
2019-07-20 20:12:19 +09:00
Unreal Hoang
5ac9f5cdc7
add await expr to ast 2019-07-20 19:35:49 +09:00
bors[bot]
6b352ffeb3 Merge #1560
1560: move debug_dump to fmt::Debug r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-07-20 09:59:10 +00:00
Aleksey Kladov
f3bdbec1b6 rename range -> text_range 2019-07-20 12:58:27 +03:00
Aleksey Kladov
6d5d82e412 move debug_dump to fmt::Debug 2019-07-20 12:48:24 +03:00
Unreal Hoang
3a7f07c62d
add await to syntax, parser for await_expr 2019-07-20 17:41:31 +09:00
Aleksey Kladov
d92a88bf09 remove lifetime from syntax node text 2019-07-19 21:41:36 +03:00
Aleksey Kladov
0025299370 sane indexing in text 2019-07-19 20:55:32 +03:00
Aleksey Kladov
8467ba8cdb flip syntax text to use internal iteration 2019-07-19 20:29:59 +03:00
Aleksey Kladov
8f032d6a58 drop memory size of subtree
it wasn't too accurate and the new measurement method of dropping the
database completely is better anyway
2019-07-19 19:55:54 +03:00
Aleksey Kladov
191a6ba330 convenience api 2019-07-19 19:05:34 +03:00
Aleksey Kladov
a6df224f7d minor 2019-07-19 18:25:07 +03:00
Aleksey Kladov
5c594bcb48 cleanup casts 2019-07-19 18:22:00 +03:00
Aleksey Kladov
f9d9e0a1f7 several highlighting cleanups
* make stuff more type-safe by using `BindPat` instead of just `Pat`
* don't add `mut` into binding hash
* reset shadow counter when we enter a function
2019-07-19 16:09:32 +03:00
Aleksey Kladov
d4a66166c0 switch to the upstream rowan 2019-07-19 14:15:01 +03:00
Aleksey Kladov
cf932181cf migrate ra_cli to the new rowan 2019-07-19 13:16:30 +03:00
Aleksey Kladov
f1abc7bdc6 migrate ra_ide_api to the new rowan 2019-07-19 13:16:25 +03:00
Aleksey Kladov
0343c4a815 migrate ra_assists to the new AST 2019-07-19 13:16:25 +03:00
Aleksey Kladov
e2b28f5bb8 migrate ra_hir to the new rowan 2019-07-19 13:16:25 +03:00
Aleksey Kladov
7e02aa0eff migrate ra_fmt to new rowan 2019-07-19 13:16:24 +03:00
Aleksey Kladov
08fd402ef2 migrate mbe to the new rowan 2019-07-19 13:16:24 +03:00
Aleksey Kladov
d402974aa0 migrate ra_syntax to the new rowan API 2019-07-19 13:16:24 +03:00
Aleksey Kladov
df33e7685b use Parse in mbe 2019-07-18 23:19:04 +03:00
Aleksey Kladov
a6224f3620 make Parse generic 2019-07-18 22:55:04 +03:00
bors[bot]
abe72424a6 Merge #1547
1547: cleanup imports r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-07-18 17:17:01 +00:00
Aleksey Kladov
1edec77e58 cleanup imports 2019-07-18 20:16:33 +03:00
Aleksey Kladov
2c4c233ba8 prettier colors 2019-07-18 19:57:13 +03:00
bors[bot]
8a6d270ecc Merge #1537
1537: Less magic completions r=matklad a=marcogroppo

Restrict `if`, `not` and `while` postfix magic completions to boolean expressions and expressions of an unknown type.

(this may be controversial, marking as draft for this reason)

See the discussion in #1526.

Co-authored-by: Marco Groppo <marco.groppo@gmail.com>
2019-07-18 16:30:19 +00:00
Ekaterina Babshukova
4abe03879b highlight mutable variables differently 2019-07-18 18:52:50 +03:00
Aleksey Kladov
0fb4b896e2 use more correct phantom types for ptrs 2019-07-18 18:13:32 +03:00
Marco Groppo
d1608538de Restrict some postfix completions to bool and unknown expr.
Restrict `if` and `while` postfix completions to boolean expressions and
expressions of an unknown type.
2019-07-17 21:02:36 +02:00
Jeremy A. Kolb
5e9198f809 jemallocator 0.3 2019-07-17 10:58:17 -04:00
Kirill Bulatov
1037242e6e Add "Run" lens for binary runnables 2019-07-16 15:02:11 +03:00
kjeremy
1fcc002677 cargo update 2019-07-15 15:07:11 -04:00
Florian Diebold
c8284d8424 Switch to Chalk master, without fuel 2019-07-15 08:49:55 +02:00
Florian Diebold
dcb0c02e3a Remove blacklist, instead mark Sized as non-enumerable
This seems to be enough to prevent hanging in rust-analyzer, Chalk and the rustc
repo.
2019-07-15 08:49:55 +02:00
Florian Diebold
e2bce9e7eb Cargo update, including updating Chalk 2019-07-14 18:22:47 +02:00
Florian Diebold
1e60ba8927 Have InferenceContext contain an InferenceResult instead of duplicating all fields 2019-07-14 18:22:47 +02:00
Florian Diebold
0a20770f46 Some renamings for clarity 2019-07-14 18:22:47 +02:00
Alexander Andreev
9c75f30272 Fixed request comments 2019-07-14 09:24:18 +03:00
Alexander Andreev
22b863c534 Fixed comments 2019-07-13 21:51:20 +03:00
Alexander Andreev
1f0e9c149f More resolution modules with attribute path
#1211
2019-07-13 21:26:04 +03:00
Ekaterina Babshukova
2a1e11b36f complete fields in enum variants 2019-07-12 20:31:49 +03:00
Aleksey Kladov
deab4caa7b make Parse fields private
this is in preparation for the new rowan API
2019-07-12 19:41:13 +03:00
bors[bot]
2e466bb365 Merge #1523
1523: account for dependencies when showing memory usage r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-07-12 15:05:28 +00:00
Aleksey Kladov
e40494c6c1 account for dependencies when showing memory usage 2019-07-12 18:04:48 +03:00
bors[bot]
fa3716efe6 Merge #1520
1520: Ignore workspace/didChangeConfiguration notifications. r=matklad a=bolinfest

If the client happens to send a `workspace/didChangeConfiguration`
notification, it is nicer if rust-analyzer can just ignore it rather than
crash with an "unhandled notification" error.

Co-authored-by: Michael Bolin <bolinfest@gmail.com>
2019-07-11 09:13:10 +00:00
Michael Bolin
e81a47b8eb Remove executeCommandProvider: apply_code_action.
This appears to have been introduced ages ago in
be742a5877
but has since been removed.

As it stands, it is problematic if multiple instances of the
rust-analyzer LSP are launched during the same VS Code session because
VS Code complains about multiple LSP servers trying to register the
same command.

Most LSP servers workaround this by parameterizing the command by the
process id. For example, this is where `rls` does this:

ff0b9057c8/rls/src/server/mod.rs (L413-L421)

Though `apply_code_action` does not seems to be used, so it seems better
to delete it than to parameterize it.
2019-07-10 22:49:35 -07:00
Michael Bolin
a814883cd4 Ignore workspace/didChangeConfiguration notifications. 2019-07-10 20:56:16 -07:00
Ekaterina Babshukova
895597d567 move whitespace manipulation inside AstEditor 2019-07-10 22:03:00 +03:00
Pascal Hertleif
6e87065968 Make clippy a bit happier
Random drive-by fix. I honestly blame rust-analyzer itself on this,
because I set its watch mode to use `cargo clippy` 🤷
2019-07-10 17:05:39 +02:00
Pascal Hertleif
d0ff53de2d Resolve a FIXME
Now that we are using a newer smol_str release this can be simplified :)
2019-07-10 17:04:38 +02:00
Aleksey Kladov
61135d4d4d fix profile name 2019-07-09 11:13:15 +03:00
bors[bot]
f59cd1a4a0 Merge #1515
1515: Trait environment r=matklad a=flodiebold

This adds the environment, i.e. the set of `where` clauses in scope, when solving trait goals. That means that e.g. in
```rust
fn foo<T: SomeTrait>(t: T) {}
```
, we are able to complete methods of `SomeTrait` on the `t`. This affects the trait APIs quite a bit (since every method that needs to be able to solve for some trait needs to get this environment somehow), so I thought I'd do it rather sooner than later ;)

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2019-07-09 07:50:18 +00:00
bors[bot]
35f28c538a Merge #1512
1512: Infer ? operator r=unrealhoang a=unrealhoang

Logical continuation of https://github.com/rust-analyzer/rust-analyzer/pull/1501

cc https://github.com/rust-analyzer/rust-analyzer/issues/1426

Co-authored-by: Unreal Hoang <unrealhoang@gmail.com>
2019-07-09 00:41:03 +00:00
Unreal Hoang
9a0d4b16b7
beautify tests 2019-07-09 09:27:03 +09:00
Florian Diebold
9afbf2dff4 Unify normalize and implements to simplify code 2019-07-08 21:47:37 +02:00
Florian Diebold
15862fc041 Use environment for associated type normalization as well 2019-07-08 21:20:17 +02:00
Florian Diebold
b1b12072ed Start handling environment in trait resolution
I.e. if we are inside a function with some where clauses, we assume these where
clauses hold.
2019-07-08 21:20:17 +02:00
Florian Diebold
638100dc8b Refactor a bit & introduce Environment struct 2019-07-08 21:20:17 +02:00
Marco Groppo
95d78a8d8d Look for the fXX_runtime lang items during method resolution. 2019-07-08 20:37:29 +02:00
Unreal Hoang
741fc8fbfc
use namespaced consts for KnownName 2019-07-09 01:00:47 +09:00
Shotaro Yamada
a426de60ad Remove unused dependencies 2019-07-09 00:28:00 +09:00
Unreal Hoang
944f71afc6
projection over std::ops::Try::Ok to infer try/? 2019-07-09 00:19:09 +09:00
Aleksey Kladov
e075e096cf don't send LocationLink unless the client opts-in
closes #1474
2019-07-08 14:09:38 +03:00
Aleksey Kladov
b042faeb64 simplify 2019-07-08 13:47:02 +03:00
Aleksey Kladov
227bc0b6d4 add try_conv_with_to_vec 2019-07-08 13:39:16 +03:00
bors[bot]
5ce2b4819e Merge #1504
1504: Simplify LSP handlers r=matklad a=kjeremy

Takes advantage of protocol inheritance via composition and simplifies some responses via the `From`/`Into` traits.

Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
2019-07-08 09:55:23 +00:00
Muhammad Mominul Huque
09b72489dd
cargo format 2019-07-08 04:09:35 +06:00
Muhammad Mominul Huque
012fec54dc
Constify KnownName's 2019-07-08 03:29:38 +06:00
Jeremy Kolb
9c6e93cd6c Simplify responses by using into() 2019-07-07 17:28:21 -04:00
Jeremy Kolb
3f44aaf363 use flatten branch of lsp-types 2019-07-07 14:13:13 -04:00
bors[bot]
1b38ca3b87 Merge #1501
1501: Infer for loop variable r=flodiebold a=unrealhoang

My take on https://github.com/rust-analyzer/rust-analyzer/issues/1425

Co-authored-by: Unreal Hoang <unrealhoang@gmail.com>
2019-07-07 15:20:09 +00:00
bors[bot]
6c31f5b0a7 Merge #1499
1499: processing attribute #[path] of module  r=matklad a=andreevlex

support two cases
- simple name file `foo.rs`
- declaration in mod.rs

#1211 

Co-authored-by: Alexander Andreev <andreevlex.as@gmail.com>
2019-07-07 13:48:58 +00:00
Unreal Hoang
f7cd40d830
add projection to infer for loop variable 2019-07-07 22:26:51 +09:00
Alexander Andreev
1c582be63b Moved module resolution test in mods.rs 2019-07-07 16:06:54 +03:00
funkill2
ca42f621c6
inline snapshot in complete_postfix 2019-07-07 13:52:25 +03:00
Alexander Andreev
8579a9b834 Added support attribute path in resolusion module fn 2019-07-06 21:54:21 +03:00
Florian Diebold
f854a29c9a Make EnumVariant a GenericDef and simplify some code 2019-07-06 17:43:13 +02:00
Florian Diebold
065d398701 Add trait obligations for where clauses when calling functions/methods
E.g. if we call `foo<T: Into<u32>>(x)`, that adds an obligation that `x:
Into<u32>`, etc.
2019-07-06 17:34:05 +02:00