Commit graph

4875 commits

Author SHA1 Message Date
bors[bot]
834fcecd31
Merge #2994
2994: Small cleanup r=matklad a=SomeoneToIgnore

A follow-up to https://github.com/rust-analyzer/rust-analyzer/pull/2990#discussion_r374044482

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-02-03 13:01:58 +00:00
Kirill Bulatov
4f27155d5c Simplify paths searches 2020-02-03 13:56:03 +02:00
Kirill Bulatov
fcf5bbbbeb Fix inlay hints test snippet compilation 2020-02-03 13:35:14 +02:00
bors[bot]
d400fde66c
Merge #2959
2959: Rework how we send diagnostics to client r=matklad a=kiljacken

The previous way of sending from the thread pool suffered from stale diagnostics due to being canceled before we could clear the old ones.

The key change is moving to sending diagnostics from the main loop thread, but doing all the hard work in the thread pool. This should provide the best of both worlds, with little to no of the downsides.

This should hopefully fix a lot of issues, but we'll need testing in each individual issue to be sure.

Co-authored-by: Emil Lauridsen <mine809@gmail.com>
2020-02-03 11:27:31 +00:00
Emil Lauridsen
9f70f443a3 Update snapshot tests due to removed SuggestedFix 2020-02-03 12:24:57 +01:00
Emil Lauridsen
cde20bf8f0 Remove stray todo 2020-02-03 12:18:06 +01:00
Laurențiu Nicola
e0c7ce8417 Allow add_explicit_type to replace a placeholder type 2020-02-03 13:09:38 +02:00
Emil Lauridsen
790788d5f4 Rework how we send diagnostics to client.
The previous way of sending from the thread pool suffered from stale
diagnostics due to being canceled before we could clear the old ones.

The key change is moving to sending diagnostics from the main loop
thread, but doing all the hard work in the thread pool. This should
provide the best of both worlds, with little to no of the downsides.

This should hopefully fix a lot of issues, but we'll need testing in
each individual issue to be sure.
2020-02-03 11:34:24 +01:00
Kirill Bulatov
01d59f4a32 Use name only when searching for an import candidate 2020-02-02 23:27:20 +02:00
Aleksey Kladov
24ad1cce2c Avoid premature pessimization
The extra allocation for message should not matter here at all, but
using a static string is just as ergonomic, if not more, and there's
no reason to write deliberately slow code
2020-02-02 18:56:37 +01:00
bors[bot]
e24829909a
Merge #2982
2982: Merge imports when auto importing r=flodiebold a=SomeoneToIgnore



Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-02-02 13:06:14 +00:00
zombiefungus
f4f71e361e include requested changes 2020-02-02 08:04:24 -05:00
zombiefungus
7d52715945 add new ImportAlias enum to differentiate no alias from an _ alias 2020-02-02 08:04:24 -05:00
Kirill Bulatov
2ee94e3e24
Remove obsolete rustdoc 2020-02-02 14:59:07 +02:00
Kirill Bulatov
c669b2f489 Code review fixes 2020-02-02 14:27:52 +02:00
Kirill Bulatov
6dae5cbb11 Require ModPath for importing 2020-02-02 14:06:51 +02:00
Kirill Bulatov
a9669a5505 Merge imports when auto importing 2020-02-02 10:28:16 +02:00
Kirill Bulatov
d3188769e4 Auto import functions 2020-02-01 22:13:02 +02:00
Aleksey Kladov
5559d6b8a8 Prevent child cargo process from messing with our stdin
By default, `spawn` inherits stderr/stdout/stderr of the parent
process, and so, if child, for example does fcntl(O_NONBLOCK), weird
stuff happens to us.

Closes https://github.com/rust-analyzer/lsp-server/pull/10
2020-02-01 16:25:44 +01:00
bors[bot]
fc0a8c14dc
Merge #2965
2965: Improve auto import message r=kiljacken a=lnicola



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-02-01 11:10:50 +00:00
Laurențiu Nicola
0fdca457df Improve auto import message 2020-01-31 22:12:18 +02:00
Laurențiu Nicola
0829e26354 Fix extra parentheses warnings 2020-01-31 21:07:21 +02:00
Aleksey Kladov
9d5a5211a4 Small cleanup 2020-01-31 13:34:44 +01:00
Aleksey Kladov
c2e3dba8cb Add a FIXME note 2020-01-30 18:01:38 +01:00
bors[bot]
c7e0baf1a8
Merge #2920
2920: Better handle illformed node id from metadata r=matklad a=edwin0cheng

In some rare cases, deps node-id from cargo-metadata do not match its version-id, which cause a panic in `cargo-workspace.rs`. This PR try to ignore these ill-formed node id from `cargo-metadata`. An alternative is return  `Err` in these cases but I think make it resilience is a better choice here.

Related #2767

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-01-30 16:48:35 +00:00
Aleksey Kladov
c445c72eb3 Simplify fixture parsing 2020-01-30 13:17:56 +01:00
bors[bot]
5dcd9fdf5e
Merge #2895
2895: Rewrite ra_prof's profile printing r=michalt a=michalt

This changes the way we print things to first construct a mapping from
events to the children and uses that mapping to actually print things.
It should not change the actual output that we produce.

The new approach two benefits:

 * It avoids a potential quadratic behavior of the previous approach.
   For instance, for a vector of N elements:
   ```
   [Message{level: (N - 1)}, ..., Message{level: 1}, Message{level: 0}]
   ```
   we would first do a linear scan to find entry with level 0, then
   another scan to find one with level 1, etc.

 * It makes it much easier to improve the output in the future, because
   we now pre-compute the children for each entry and can easily take
   that into account when printing.

Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>

Co-authored-by: Michal Terepeta <michal.terepeta@gmail.com>
2020-01-29 20:09:49 +00:00
Michal Terepeta
644c383f65 A couple of small improvements to ra_prof printing
Based on suggestions from @matklad.

Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>
2020-01-29 20:55:35 +01:00
bors[bot]
d92a15c163
Merge #2943
2943: Re-sync queries for memory usage measurnment r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-01-29 15:11:38 +00:00
Aleksey Kladov
f1720d7983 Re-sync queries for memory usage measurnment 2020-01-29 16:10:46 +01:00
Kirill Bulatov
6d219c9a10 Properly select a target for auto importing 2020-01-29 16:23:18 +02:00
Aleksey Kladov
d2fd252f9d Simplify fixture parsing 2020-01-29 14:06:23 +01:00
Aleksey Kladov
7cc0a86528 Fix long loop timeout 2020-01-29 14:04:10 +01:00
Emil Lauridsen
4ec5f6e258 Change error output to make a bit more sense 2020-01-29 13:51:20 +01:00
Emil Lauridsen
8ffbe86dfd Parse cargo output a line at a time.
We previously used serde's stream deserializer to read json blobs from
the cargo output. It has an issue though: If the deserializer encounters
invalid input, it gets stuck reporting the same error again and again
because it is unable to foward over the input until it reaches a new
valid object.

Reading a line at a time and manually deserializing fixes this issue,
because cargo makes sure to only outpu one json blob per line, so should
we encounter invalid input, we can just skip a line and continue.

The main reason this would happen is stray printf-debugging in
procedural macros, so we still report that an error occured, but we
handle it gracefully now.

Fixes #2935
2020-01-29 13:40:27 +01:00
bors[bot]
6fd29651b4
Merge #2931
2931: Added documentation to test_utils r=matklad a=Veetaha

Added some doc comments to test_utils functions while studying this crate. They should be all stable enough to document them.
Also some minor code relocation in `parse_fixture()` closer to its usage according to the advice of @matklad.

Co-authored-by: Veetaha <gerzoh1@gmail.com>
2020-01-29 11:06:18 +00:00
Aleksey Kladov
9753eb98cc Complain loudly if the main loop is blocked 2020-01-29 11:21:49 +01:00
Aleksey Kladov
aaa4861a0b More uniform naming 2020-01-29 11:15:08 +01:00
Aleksey Kladov
2d2585e03f Don't compute diagnostics on the main thread
closes #2909
2020-01-29 11:03:59 +01:00
Veetaha
5e1ae1d7aa test_utils: move flush!() to its usage as per conversation with @matklad 2020-01-29 03:53:15 +02:00
Veetaha
d3472e8ae4 test_utils: updated documentation and some typos 2020-01-29 03:52:13 +02:00
bors[bot]
3bdf2e0972
Merge #2917
2917: Prefer imports starting with std r=matklad a=SomeoneToIgnore

Closes https://github.com/rust-analyzer/rust-analyzer/issues/2915

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-01-28 16:22:18 +00:00
Kirill Bulatov
713870ee0c Add the tests 2020-01-28 18:03:24 +02:00
Aleksey Kladov
4b9e5d5dd9 Publicize debug printing of CrateDefMap 2020-01-28 16:29:31 +01:00
Kirill Bulatov
762d293581 Apply the proposed refactoring 2020-01-28 17:19:41 +02:00
Aleksey Kladov
6ca19b2188 Standard formatting for array types 2020-01-28 15:32:20 +01:00
bors[bot]
76e17fe7d8
Merge #2924
2924: Modify ordering of drops in check watcher to only ever have one cargo r=matklad a=kiljacken

Due to the way drops are ordered when assigning to a mutable variable we
were launching a new cargo sub-process before letting the old one quite.

By explicitly replacing the original watcher with a dummy first, we
ensure it is dropped and the process is completed, before we start the
new process.

Co-authored-by: Emil Lauridsen <mine809@gmail.com>
2020-01-28 13:54:29 +00:00
Emil Lauridsen
35025f0975 Modify ordering of drops in check watcher to only ever have one cargo
Due to the way drops are ordered when assigning to a mutable variable we
were launching a new cargo sub-process before letting the old one quite.

By explicitly replacing the original watcher with a dummy first, we
ensure it is dropped and the process is completed, before we start the
new process.
2020-01-28 14:48:50 +01:00
Emil Lauridsen
fdc04ef920 Don't do check progress update for fresh crates 2020-01-28 14:33:52 +01:00
Edwin Cheng
c32be4bfe8 Ignore illform node id from metadata 2020-01-28 17:08:17 +08:00
Laurențiu Nicola
c34571c19e Buffer reads from cargo check's stdout 2020-01-28 01:27:43 +02:00
Kirill Bulatov
7a2e449424 Prefer imports starting with std 2020-01-28 01:02:06 +02:00
bors[bot]
5dd8f8e26f
Merge #2810
2810: Improves reference search by StructLiteral r=mikhail-m1 a=mikhail-m1

Hey, I've made some changes to improve search for struct literals, now it works for `struct Foo<|> {`, `struct Foo <|>{`, `struct Foo<|>(`. Unfortunately tuple creation is represented as a call expression, so for tuples it works only is search is started in a tuple declaration.  It leads to incorrect classification of function calls during search phase, but from user perspective it's not visible and works as expected. May be it worth to add a comment or rename it to remove this misleading classification. Issue #2549.

Co-authored-by: Mikhail Modin <mikhailm1@gmail.com>
2020-01-27 21:58:35 +00:00
Mikhail Modin
fbc3ffcee6 Improves reference search by StructLiteral 2020-01-27 21:34:19 +00:00
Florian Diebold
339a11c33c Tweak Chalk settings 2020-01-27 21:52:35 +01:00
Florian Diebold
d3a3e5abdf Ignore failing impl Trait tests 2020-01-27 21:38:10 +01:00
Florian Diebold
96ddf2962c Upgrade Chalk 2020-01-27 21:25:33 +01:00
bors[bot]
1d729033eb
Merge #2883
2883: Implement Syntax Highlight inside macro call r=matklad a=edwin0cheng



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-01-27 13:36:26 +00:00
bors[bot]
4f9506416c
Merge #2887
2887: Initial auto import action implementation r=matklad a=SomeoneToIgnore

Closes https://github.com/rust-analyzer/rust-analyzer/issues/2180

Adds an auto import action implementation.

This implementation is not ideal and has a few limitations:

* The import search functionality should be moved into a separate crate accessible from ra_assists.
This requires a lot of changes and a preliminary design. 
Currently the functionality is provided as a trait impl, more on that here: https://github.com/rust-analyzer/rust-analyzer/issues/2180#issuecomment-575690942

* Due to the design desicion from the previous item, no doctests are run for the new aciton (look for a new FIXME in the PR)

* For the same reason, I have to create the mock trait implementaion to test the assist

* Ideally, I think we should have this feature as a diagnostics (that detects an absense of an import) that has a corresponding quickfix action that gets evaluated on demand.
Curretly we perform the import search every time we resolve the import which looks suboptimal.
This requires `classify_name_ref` to be moved from ra_ide, so not done currently.

A few improvements to the imports mechanism to be considered later:

* Constants like `ra_syntax::SyntaxKind::NAME` are not imported, because they are not present in the database

* Method usages are not imported, they are found in the database, but `find_use_path` does not return any import paths for them

* Some import paths returned by the `find_use_path` method end up in `core::` or `alloc::` instead of `std:`, for example: `core::fmt::Debug` instead of `std::fmt::Debug`.
This is not an error techically, but still looks weird.

* No detection of cases where a trait should be imported in order to be able to call a method

* Improve `auto_import_text_edit` functionality: refactor it and move away from the place it is now, add better logic for merging the new import with already existing imports

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-01-27 13:04:53 +00:00
Kirill Bulatov
9be1ab7ff9 Code review fixes 2020-01-27 14:42:45 +02:00
Kirill Bulatov
9a6b5c6183 Enforce alphabetical import sorting 2020-01-27 01:53:59 +02:00
Kirill Bulatov
1a78991df6 Adjust the tests 2020-01-27 00:57:24 +02:00
Kirill Bulatov
d0a782ef1c Have a better trait interface 2020-01-27 00:17:10 +02:00
Kirill Bulatov
bef5cf0b99 Raise the import search query cap 2020-01-27 00:16:29 +02:00
Kirill Bulatov
f57239729c Remove unnecessary lifetime parameter 2020-01-27 00:16:29 +02:00
Kirill Bulatov
316795e074 Initial auto import action implementation 2020-01-27 00:16:29 +02:00
Jeremy Kolb
6967472703 Move snaps to new naming scheme 2020-01-26 13:29:01 -05:00
Jeremy Kolb
b89991daed Update crates 2020-01-26 10:46:45 -05:00
bors[bot]
d1330a4a65
Merge #2906
2906: Fix thread priority problems on windows r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-01-26 13:17:19 +00:00
Aleksey Kladov
493a903f22 Bump main thread priority on windows 2020-01-26 14:15:57 +01:00
Tomáš
ec6a7f0710 fixed inline_local_variable bug 2020-01-25 21:07:21 +01:00
Aleksey Kladov
40109941db Use default threadpool size 2020-01-25 13:27:36 +01:00
bors[bot]
adda6dbdf8
Merge #2899
2899: Provide more runners for potential tests r=matklad a=SomeoneToIgnore

Based on the https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Runners.20for.20custom.20test.20annotations discussion.

Adds a test runner for every method that has an annotation that contains `test` word in it, allowing to run tests annotated with custom testing annotations such as `#[tokio::test]`, `#[test_case(...)]` and others at costs of potentially emitting some false-positives.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-01-25 11:10:28 +00:00
Aleksey Kladov
6577a7622d Add print_time helper 2020-01-25 11:59:11 +01:00
Aleksey Kladov
f44aee27d3 Disable env_logger humantime feature
We rarely care about timings of events, and, when we care, we need
millisecond precision
2020-01-25 11:53:40 +01:00
Aleksey Kladov
b90ea640e6 Cancel requests during shutdown 2020-01-24 16:35:37 +01:00
Kirill Bulatov
3137215e8d Provide more runners for potential tests 2020-01-23 13:40:21 +02:00
Emil Lauridsen
05aa5b854b Remove RWLock from check watcher.
@matklad mentioned this might be a good idea.

So the general idea is that we don't really need the lock, as we can
just clone the check watcher state when creating a snapshot. We can then
use `Arc::get_mut` to get mutable access to the state from `WorldState`
when needed.

Running with this it seems to improve responsiveness a bit while cargo
is running, but I have no hard numbers to prove it. In any case, a
serialization point less is always better when we're trying to be
responsive.
2020-01-23 09:26:08 +01:00
kjeremy
ee7dd4b9ae Update crates 2020-01-22 15:40:35 -05:00
Michal Terepeta
39cbb6b620 Rewrite ra_prof's profile printing
This changes the way we print things to first construct a mapping from
events to the children and uses that mapping to actually print things.
It should not change the actual output that we produce.

The new approach two benefits:

 * It avoids a potential quadratic behavior of the previous approach.
   For instance, for a vector of N elements:
   ```
   [Message{level: (N - 1)}, ..., Message{level: 1}, Message{level: 0}]
   ```
   we would first do a linear scan to find entry with level 0, then
   another scan to find one with level 1, etc.

 * It makes it much easier to improve the output in the future, because
   we now pre-compute the children for each entry and can easily take
   that into account when printing.

Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>
2020-01-22 20:13:56 +01:00
Kirill Bulatov
4029e44102 Omit default parameters for reference types 2020-01-22 16:55:09 +02:00
Veetaha
fa31841f1f Fixed a typo 2020-01-22 13:02:21 +02:00
Veetaha
1ac105056a Fixed a typo 2020-01-22 13:02:21 +02:00
Veetaha
b6be1b6f61 Preserved a comment on the bug previously present in ast::Literal::kind() 2020-01-22 13:02:21 +02:00
Veetaha
3ec781d4f2 ra_syntax: remove code duplication and token reevaluation from ast::Literal::kind() 2020-01-22 13:02:21 +02:00
Edwin Cheng
f320af4d63 Implement Syntax Highlight inside Macro 2020-01-21 00:06:47 +08:00
bors[bot]
de2409702b
Merge #2877
2877: "Insert explicit type " assist fix #2869, fix typo r=matklad a=TomasKralCZ

So this was quite straightforward. I basically looked at how the other assists work and tried doing something simillar. I also fixed a typo in the other assist.

Co-authored-by: TomasKralCZ <tomas@kral.hk>
2020-01-20 10:16:06 +00:00
TomasKralCZ
72792f6bc5 changed 'descendants()' to 'children()' 2020-01-20 10:19:33 +01:00
TomasKralCZ
f67ee69777 added eq_token() method to LetStmt 2020-01-19 18:55:56 +01:00
Michal Terepeta
e8acf49088 Fix a corner case when printing unaccounted time
Previously `ra_prof` wouldn't actually print the unaccounted time in
some cases.

We would print, for instance, this:
```
    5ms - foo
        2ms - bar
```
instead of:
```
    5ms - foo
        2ms - bar
        3ms - ???
```

The fix is to properly handle the case when an entry has 0 children
instead of using the `last` variable.

Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>
2020-01-19 18:34:40 +01:00
TomasKralCZ
514df15d9e Merge branch 'master' of https://github.com/rust-analyzer/rust-analyzer 2020-01-19 17:51:03 +01:00
TomasKralCZ
c3b9a19eb7 fix 'add_explicit_type' assist range 2020-01-19 17:40:53 +01:00
TomasKralCZ
8dc94a452c fix typo in 'inline_local_variable' 2020-01-19 17:39:53 +01:00
Florian Diebold
18ec4e3403 Improve parameter hints a bit & add emacs support
- just include the name, not e.g. `mut`
 - don't return empty hints (or `_`)
2020-01-18 13:40:32 +01:00
Florian Diebold
33d637f2dd Fix inference for shift operators
Fixes #2602.
2020-01-17 16:59:51 +01:00
Aleksey Kladov
3a859e587f Nest attrs into exprs in function args 2020-01-17 11:47:07 +01:00
Aleksey Kladov
b7c45fba57 Extract expr_with_attrs 2020-01-17 11:44:40 +01:00
Aleksey Kladov
90b8a31b83
Merge pull request #2813 from jyn514/arg_attributes
Allow attributes before function arguments
2020-01-17 11:15:07 +01:00
Joshua Nelson
f077d5c303
move inline function closer to relevant code
also updates generated inline tests
2020-01-16 22:20:17 -05:00
bors[bot]
ea2b27d8b9
Merge #2865
2865: fix(mixed): fixed a couple of typos and added a todo r=kjeremy a=Veetaha

Fixed a couple of typos and added a todo while studying the codebase.

Co-authored-by: Veetaha <gerzoh1@gmail.com>
2020-01-17 02:20:16 +00:00