Commit graph

12518 commits

Author SHA1 Message Date
Alexander Gonzalez
743c037a34 chore: Remove unnecessary println! call 2021-07-27 18:31:21 -04:00
Alexander Gonzalez
506db1852c test: Add tests for when hovering fails 2021-07-27 18:29:22 -04:00
Alexander Gonzalez
48f43df7d6 docs: Improve the comments in crates/ide/src/hover.rs 2021-07-27 18:29:22 -04:00
Alexander Gonzalez
6310786ca5 test: Add hover_range tests 2021-07-27 18:29:22 -04:00
Alexander Gonzalez
1a0a5da1a4 refactor: Make handle_hover handle ranges too 2021-07-27 18:29:22 -04:00
Alexander Gonzalez
79860808cb chore: Remove unnecessary log 2021-07-27 18:29:22 -04:00
Alexander Gonzalez
18644720eb feat: Completed the client side implementation of rust-analyzer/hoverRange 2021-07-27 18:29:22 -04:00
Alexander Gonzalez
8ca3bb8fcd feat: Add the hover_range capability 2021-07-27 18:29:22 -04:00
Alexander Gonzalez
20c64cc0e6 feat: Extend the server with the hover_range capability 2021-07-27 18:29:22 -04:00
Laurențiu Nicola
ea0014c500 Remove some redundant clones 2021-07-27 21:32:55 +03:00
bors[bot]
6a2a0b7abb
Merge #9710
9710: fix: Don't qualify self as crate in add_missing_impl_members assist r=Veykril a=Veykril

Fixes #7499

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-27 17:30:37 +00:00
Lukas Wirth
456f5c6d09 Don't qualify self as crate in add_missing_impl_members assist 2021-07-27 19:29:47 +02:00
Aleksey Kladov
7d6c4142b2 fix: add capability for "open cargo.toml" lsp extension 2021-07-27 19:40:19 +03:00
bors[bot]
3a59b56324
Merge #9702
9702: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-26 18:28:32 +00:00
Lukas Wirth
3fab50019c Simplify 2021-07-26 20:26:24 +02:00
Aleksey Kladov
891867b1f1 fix: correctly update diagnostics when files are opened and closed
Basically, this tracks the changes to `subscriptions` we use when
issuing a publish_diagnostics.
2021-07-26 21:22:06 +03:00
Jonas Schievink
18b6327a29 Remove the legacy macro scoping hack 2021-07-26 19:58:14 +02:00
Aleksey Kladov
410679285b internal: prepare to track changes to mem_docs 2021-07-26 20:17:10 +03:00
bors[bot]
f0db648cb6
Merge #9558
9558: Do not erase Cargo diagnostics from the closed documents r=matklad a=SomeoneToIgnore

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

The LSP specification at https://microsoft.github.io/language-server-protocol/specifications/specification-3-14/#textDocument_publishDiagnostics states that


> Diagnostics notification are sent from the server to the client to signal results of validation runs.
> 
> Diagnostics are “owned” by the server so it is the server’s responsibility to clear them if necessary. The following rule is used for VS Code servers that generate diagnostics:
> 
>  *  if a language is single file only (for example HTML) then diagnostics are cleared by the server when the file is closed.
>  *  if a language has a project system (for example C#) diagnostics are not cleared when a file closes. When a project is opened all diagnostics for all files are recomputed (or read from a cache).
> 
> When a file changes it is the server’s responsibility to re-compute diagnostics and push them to the client. If the computed set is empty it has to push the empty array to clear former diagnostics. Newly pushed diagnostics always replace previously pushed diagnostics. There is no merging that happens on the client side.


So for projects we should not clear any diagnostics from cargo/json projects.
Our "standalone file" mode is in a way a project too, with sysroot attached and a potential support for dynamic standalone files.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2021-07-26 14:53:05 +00:00
Lukas Wirth
f43cd562bc Fix generic_arg not parsing opt_generic_arg_list properly in arg lists 2021-07-26 15:21:19 +02:00
bors[bot]
d571ca814e
Merge #9593
9593: fix: Adding remove_unused_param for method and fixing same for assoc func r=matklad a=feniljain

Solves #9571 

Co-authored-by: vi_mi <fenil.jain2018@vitstudent.ac.in>
2021-07-26 10:36:31 +00:00
Jonas Platte
c0107d2ea6
Fix some grammar / spelling mistakes 2021-07-26 10:12:41 +02:00
Lukas Wirth
0a13259fc6 Kepp catch-all arm in fill_match_arms if it has a non-empty expression 2021-07-25 15:51:47 +02:00
bors[bot]
2fe586a8a7
Merge #9688
9688: feat: Resolve derive attribute input macro paths in ide layer r=Veykril a=Veykril

Enables goto def, syntax highlighting and hover for `Foo` in `#[derive(Foo)]`.
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/4413
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-24 18:37:13 +00:00
Lukas Wirth
bfe0fa009e Resolve derive attribute input macro paths in ide layer 2021-07-24 20:35:43 +02:00
Laurențiu Nicola
1da21b797a Fix typo 2021-07-24 11:20:40 +03:00
Laurențiu Nicola
d9ec9d95c5 Bump deps 2021-07-24 11:16:32 +03:00
Jonas Schievink
c495a7374f Resolve tuple field visibility FIXME 2021-07-23 20:20:41 +02:00
Jonas Schievink
4267c38db1 Add tests for tuple struct field completion 2021-07-23 20:20:23 +02:00
Jonas Schievink
3efdf6861f Complete editable private items 2021-07-23 19:57:16 +02:00
bors[bot]
75d7da196f
Merge #9683
9683: internal: Move out expression based `unqualified_path` completion tests r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-23 15:07:10 +00:00
Lukas Wirth
189440c7b5 Add a Union to the base item completion test fixture 2021-07-23 17:02:39 +02:00
bors[bot]
6494193adb
Merge #9681
9681: Respect `#[doc(hidden)]` in dot-completion r=jonas-schievink a=jonas-schievink

This adds `CompletionContext::is_visible` as a convenience method that checks visibility, presence of `doc(hidden)`, and whether the completed item is in the same crate as the completion site or not. We only complete `doc(hidden)` items from the same crate.

This doesn't yet work for *all* completions: `qualified_path` completions use `Module::scope` and `ScopeDef`, which doesn't work with this.

Part of https://github.com/rust-analyzer/rust-analyzer/issues/7718

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-07-23 14:59:26 +00:00
Jonas Schievink
c8d915e2ea Fix formatting and use Iterator::any 2021-07-23 16:45:14 +02:00
Lukas Wirth
8de3f7ee53 Move out unqualified_path completion tests 2021-07-23 16:37:19 +02:00
Lukas Wirth
ea72a5136c Add functions to base items completion test fixture 2021-07-23 16:12:09 +02:00
Jonas Schievink
b0f7aac72f Respect #[doc(hidden)] in dot-completion 2021-07-23 15:36:43 +02:00
Kevin DeLorey
7797c59f18 Updated docs. 2021-07-22 19:35:47 -06:00
Kevin DeLorey
efb6587664 Added tests to ensure config behavior. 2021-07-22 19:35:47 -06:00
Kevin DeLorey
b75e0e7bb1 Initial commit of highlight related configuration w/ implementation. 2021-07-22 19:35:47 -06:00
Lukas Wirth
ef6fed052c Correctly classify Rename Names 2021-07-23 02:14:59 +02:00
Lukas Wirth
1f558faa8d Describe the current lifetime/label completion specifics 2021-07-22 20:18:46 +02:00
Lukas Wirth
d5947d9d48 Clarify what the outline test module is for 2021-07-22 20:03:29 +02:00
Lukas Wirth
2d696b9c9e Move out record completion tests 2021-07-22 19:38:49 +02:00
bors[bot]
444679f202
Merge #9674
9674: fix: Fix pattern name resolution when name is also occupied in type namespace r=flodiebold a=jonas-schievink

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

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-07-22 11:49:18 +00:00
bors[bot]
2fbecccc71
Merge #9634
9634: minor update to excludeDirs doc r=lnicola a=dae

I saw reference to globs in #7755, but it doesn't look like they're
actually supported, and I had to dig through the source to discover
that the folders are relative to the workspace root. Further digging
was required to get VS Code from hanging for long periods trying to
watch giant Bazel folders that had already been excluded from Rust
Analyzer. Hopefully this tweak will save others the confusion :-)

Co-authored-by: Damien Elmes <gpg@ankiweb.net>
Co-authored-by: Damien Elmes <dae@users.noreply.github.com>
2021-07-22 11:43:05 +00:00
Jonas Schievink
b596c32a41 Resolve tuple variants in value namespace 2021-07-22 13:40:18 +02:00
Damien Elmes
d22b830ed1 mention files.watcherExclude
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2021-07-22 21:25:23 +10: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
Laurențiu Nicola
efcc487dff Fix a couple of clippy nits 2021-07-22 09:03:54 +03:00
bors[bot]
a36c9d8b5c
Merge #9669
9669: minor: Move out fn_param tests r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-21 19:41:59 +00:00
Lukas Wirth
03efb50ae8 Move out fn_param tests 2021-07-21 21:39:40 +02:00
bors[bot]
b7e80d14f5
Merge #9668
9668: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-21 18:52:49 +00:00
Lukas Wirth
dfdf6fd9f8 Fix some more basic clippy lints 2021-07-21 20:52:08 +02:00
bors[bot]
1864147d92
Merge #9666
9666: minor: Fix some clippy lints in ide_completion r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-21 17:52:57 +00:00
Lukas Wirth
9485d6efba Fix some clippy lints in ide_completion 2021-07-21 19:52:10 +02:00
bors[bot]
4d457e26e1
Merge #9665
9665: Only complete ancestors and self in visibility path completions r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-21 17:05:44 +00:00
Lukas Wirth
ccde0bcd1f Only complete ancestors and self in visibility path completions 2021-07-21 18:54:12 +02:00
bors[bot]
99451a5fc2
Merge #9664
9664: Minor completions cleanup r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-21 16:47:41 +00:00
Lukas Wirth
3956a5b757 Simplify 2021-07-21 18:34:43 +02:00
bors[bot]
f2736c969c
Merge #9663
9663: fix: Don't offer extract_variable assist when there is no surrounding block r=Veykril a=Veykril

Fixes #9143
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-21 16:00:08 +00:00
Lukas Wirth
9279c1c939 Don't offer extract_variable assist when there is no surrounding block 2021-07-21 17:52:54 +02:00
Jonas Schievink
837eec8dab filter visiblities when resolving in extern crate 2021-07-21 17:51:56 +02:00
Tom Dohrmann
7b20904e8b hide keyword suggestions in non trivial paths 2021-07-21 12:53:50 +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
bors[bot]
8c8c6fb73d
Merge #9655
9655: fix: Determine expected parameters from expected return in calls r=flodiebold a=flodiebold

Fixes #9560


Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2021-07-20 20:17:03 +00:00
bors[bot]
ec7b4cbf8f
Merge #9654
9654: minor: remove dead code r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-07-20 17:23:18 +00:00
Aleksey Kladov
08caf36d9a minor: remove dead code
It has been living in RootDatabase::apply_change almost a year by now.
2021-07-20 20:22:56 +03:00
bors[bot]
92877d37c3
Merge #9653
9653: minor: cov-mark r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-20 17:04:56 +00:00
Lukas Wirth
c83e37c001 cov-mark 2021-07-20 19:00:52 +02:00
bors[bot]
1c8cfa4310
Merge #9652
9652: Don't concat path in replace_qualified assist when they start with a keyword r=Veykril a=Veykril

Also keep the path if we can't find a path to the item instead of becoming non applicable.
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-20 16:58:30 +00:00
Lukas Wirth
4f99c6467b Don't concat path in replace_qualified assist when they start with a keyword 2021-07-20 18:57:12 +02:00
bors[bot]
33972da625
Merge #9651
9651: Restrict completions inside visibility modifiers r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-20 16:38:40 +00:00
Lukas Wirth
f6cb42fdb8 Restrict completions inside visibility modifiers 2021-07-20 18:37:52 +02:00
bors[bot]
4705df44c7
Merge #9637
9637: Overhaul doc_links testing infra r=Veykril a=Veykril

and fix several issues with current implementation.

Fixes #9617

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-20 16:06:37 +00:00
Lukas Wirth
2e39d4757b More tests 2021-07-20 18:05:25 +02:00
Lukas Wirth
bb71ebb985 Move doc_links tests from hover to doc_links 2021-07-20 17:57:47 +02:00
Lukas Wirth
a35687fe1f Minor cleanups 2021-07-20 17:41:10 +02:00
Lukas Wirth
cb7b4a5d5b Some more fragment fixes 2021-07-20 17:03:39 +02:00
bors[bot]
ea71e57705
Merge #9648
9648: minor: address review comments r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-07-20 14:50:43 +00:00
Aleksey Kladov
60e7c1de83 minor: address review comments 2021-07-20 17:49:33 +03:00
bors[bot]
c7c2144fa3
Merge #9647
9647: internal: remove potentially slow method r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-07-20 14:20:31 +00:00
Aleksey Kladov
7ec8434674 internal: remove potentially slow method 2021-07-20 17:19:58 +03:00
Aleksey Kladov
3c5827cc18 internal: remove one usage of a slow method 2021-07-20 17:11:09 +03:00
bors[bot]
a646ddf230
Merge #9646
9646: add 'use' prefix for any auto-import r=Veykril a=mahdi-frms

Fixes #9643

looks like there was an if condition that had to be removed.

Co-authored-by: mahdi-frms <mahdif1380@outlook.com>
2021-07-20 14:09:24 +00:00
mahdi-frms
65839f4069 add 'use' prefix for any auto-import 2021-07-20 18:35:19 +04:30
Aleksey Kladov
8e0630e728 internal: remove one usage of a slow method 2021-07-20 17:02:37 +03:00
Lukas Wirth
e8f1abf5f7 Correctly generate link fragments for associated items 2021-07-20 16:01:27 +02:00
Lukas Wirth
113beab473 Cleanup runnables canonical path impl 2021-07-20 16:00:44 +02:00
Aleksey Kladov
b0c4b776b5 internal: add simple smoke test for project model
Our project model code is rather complicated -- the logic for lowering
from `cargo metadata` to `CrateGraph` is fiddly and special-case. So
far, we survived without testing this at all, but this increasingly
seems like a poor option.

So this PR introduces a simple tests just to detect the most obvious
failures. The idea here is that, although we rely on external processes
(cargo & rustc), we are actually using their stable interfaces, so we
might just mock out the outputs.

Long term, I would like to try to virtualize IO here, so as to do such
mocking in a more principled way, but lets start simple.

Should we forgo the mocking and just call `cargo metadata` directly
perhaps? Touch question -- I personally feel that fast, in-process tests
are more important in this case than any extra assurance we get from
running the real thing.

Super-long term, we would probably want to extend our heavy tests to
cover more use-cases, but we should figure a way to do that without
slowing the tests down for everyone.

Perhaps we need two-tiered bors system, where we pull from `master` into
`release` branch only when an additional set of tests passes?
2021-07-20 16:23:57 +03:00
Aleksey Kladov
efa4a36a50 docs: publish Explaining Rust Analyzer series 2021-07-19 23:41:15 +03:00
Lukas Wirth
97d63d67cd Resolve paths to assoc items for traits 2021-07-19 20:51:57 +02:00
Aleksey Kladov
52a70c392e minor: simplify 2021-07-19 21:21:41 +03:00
Aleksey Kladov
493ed2c17b internal: use types to remove some unwraps 2021-07-19 21:20:10 +03:00
Lukas Wirth
7a17206646 Add doc-link resolution test infra 2021-07-19 19:58:26 +02:00
bors[bot]
c595676f7e
Merge #9625
9625: internal: simplify handling of the build scripts r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-07-19 15:28:36 +00:00
Aleksey Kladov
6a0f7f0852 internal: explain why we avoid serializing everything 2021-07-19 17:47:56 +03:00
Aleksey Kladov
700210d8b4 remove debug prints 2021-07-19 16:38:36 +03:00
Aleksey Kladov
b97eec8c0e fix tests 2021-07-19 16:38:36 +03:00
KOLANICH
f00206331a Added some metadata for rust-analyser package sufficient to build it using cargo deb
Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2021-07-19 16:35:16 +03:00
Damien Elmes
106ea7ad85 minor update to excludeDirs doc
I saw reference to globs in #7755, but it doesn't look like they're
actually supported, and I had to dig through the source to discover
that the folders are relative to the workspace root. Further digging
was required to get VS Code from hanging for long periods trying to
watch giant Bazel folders that had already been excluded from Rust
Analyzer. Hopefully this tweak will save others the confusion :-)
2021-07-19 23:30:00 +10:00
Jonas Schievink
66311e1262 Add TreeId to identify ItemTrees
With per-block `ItemTree`s, the file ID is not enough to identify an
`ItemTree`.
2021-07-19 14:53:18 +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
Aleksey Kladov
b8b166e674 fix: potential bugs when build scripts do not match the current project 2021-07-18 13:13:03 +03:00
bors[bot]
ea105f9396
Merge #9619
9619: Support GATs for associated type arg parsing r=Veykril a=Veykril

Fixes #9602

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-18 09:10:56 +00:00
Lukas Wirth
e7aa37c20a Support GATs for associated type arg parsing 2021-07-18 11:08:43 +02:00
Aleksey Kladov
f4de2ece0d internal: simplify handling of the build scripts 2021-07-18 11:29:22 +03:00
Laurențiu Nicola
a9df3f858a Fix AbsPath::ends_with 2021-07-18 10:25:14 +03:00
vi_mi
0898d3b637 add: fix: Adding remove_unused_param for method and fixing same for associative func 2021-07-18 12:06:21 +05:30
Aleksey Kladov
8f3335f5fb internal: make it clearer where IO happens 2021-07-17 23:56:50 +03:00
bors[bot]
398ae3e67f
Merge #9622
9622: feat: improve parser error recovery for function parameters r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-07-17 19:41:42 +00:00
Aleksey Kladov
15f11dce4a feat: improve parser error recovery for function parameters 2021-07-17 22:41:04 +03:00
Aleksey Kladov
8d8c26e6f5 internal: a bit more of cwd safety for flycheck 2021-07-17 18:13:35 +03:00
Aleksey Kladov
8df38aa797 internal: make sure that proc macro machinery doesn't depend on cwd 2021-07-17 17:55:16 +03:00
Aleksey Kladov
9318c643f1 internal: make it easier to isolate IO 2021-07-17 17:55:16 +03:00
bors[bot]
a2f83c956e
Merge #9614
9614: Parse input expressions for dbg! invocations in remove_dbg r=Veykril a=Veykril

Instead of inspecting the input tokentree manually, parse the input as `,` delimited expressions instead and act on that. This simplifies the assist quite a bit.

Fixes #8455

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-16 13:48:23 +00:00
Lukas Wirth
c5bcd56433 Cleanup tests 2021-07-16 15:47:59 +02:00
Lukas Wirth
da00208ab9 Parse input expressions in for dbg! in remove_dbg 2021-07-16 15:20:50 +02:00
Kirill Bulatov
8a5b24eb7e Explicitly connect an ambiguous import path case logic with the test on it 2021-07-16 00:41:00 +03:00
Lukas Wirth
efc96b2c60 Add regression test fo #7222 2021-07-15 22:23:34 +02:00
bors[bot]
f39a250df6
Merge #9607
9607: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-15 19:29:28 +00:00
Lukas Wirth
4450365ec8 Simplify 2021-07-15 21:28:30 +02:00
Florian Diebold
eb2cc1036a Adapt tests for correct behavior 2021-07-15 20:02:48 +02:00
bors[bot]
c18cba78c8
Merge #9605
9605: internal: Folding ranges respect item visibilities r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-15 15:54:55 +00:00
Lukas Wirth
ed73460971 Folding ranges respect item visibilities 2021-07-15 17:44:23 +02:00
Lukas Wirth
efea07f31c Add nested region folding test 2021-07-15 17:02:45 +02:00
bors[bot]
e67cd766f7
Merge #9604
9604: fix: Don't fold consecutive modules with item lists r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-15 14:36:22 +00:00
Lukas Wirth
658514d378 Don't fold consecutive modules with item lists 2021-07-15 16:35:31 +02:00
Lukas Wirth
317b0c2e6d Move attribute completion tests 2021-07-15 16:27:01 +02:00
bors[bot]
190f37afab
Merge #9600
9600: fix: Single-line and nested blocks in the `unwrap_block` assist r=Veykril a=patrick-gu

Fixes #8411

Rework the system for stripping whitespace and braces in the unwrap_block assist to allow correct unwrapping of blocks such as:
```rust
{ $0 0 }
```
into
```rust
0
```

and nested blocks, such as:
```rust
$0{
    {
        3
    }
}
```
into
```rust
{
    3
}
```

This is done by creating the `update_expr_string_with_pat` function (along with `update_expr_string` and `update_expr_string_without_newline`), which strips whitespace and braces in a way that ensures that only whitespace and a maximum of one brace are removed from the start and end of the expression string.

I have also created several tests to ensure that this functionality works correctly.

Co-authored-by: patrick-gu <55641350+patrick-gu@users.noreply.github.com>
2021-07-15 00:45:55 +00:00
bors[bot]
95d85336df
Merge #9595
9595: Show test mod runnable in outline modules r=Veykril a=Veykril

This shows a runnable inside outline test modules at the top of its file:
![image](https://user-images.githubusercontent.com/3757771/125494747-169c9238-3faa-4eed-9700-90bd730b4e3c.png)


Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-15 00:20:44 +00:00
patrick-gu
6c591a9275 fix: Single-line and nested blocks in unwrap_block
Rework the system for stripping whitespace and braces in the
unwrap_block assist to allow correct unwrapping of `{$0 { 0 } }`
2021-07-14 12:02:38 -07:00
Levente Gyozo Lenart
a3f0197454 Update tests 2021-07-14 18:20:01 +02:00
Levente Gyozo Lenart
a0bc236adf Add true and false as completion suggestions when expecting an expression 2021-07-14 18:19:47 +02:00
Lukas Wirth
d837a5d5a7 Show test mod runnable in outline modules 2021-07-14 11:30:51 +02:00
Lukas Wirth
12fe48c04d Use Type::walk for goto_type_definition 2021-07-14 01:42:30 +02:00
bors[bot]
9bd6836513
Merge #9596
9596: Return type arguments in goto_type_definition result  r=Veykril a=Veykril

Fixes #9586
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-13 17:25:00 +00:00
Lukas Wirth
796988a269 Return type arguments in goto_type_definition result 2021-07-13 19:24:29 +02:00
Lukas Wirth
d1256a3709 Assign mutable semantic token modifier to assignment operators 2021-07-13 18:32:02 +02:00
Lukas Wirth
b3337c26db Split main highlighting function up into a few subfunctions 2021-07-13 18:29:57 +02:00
Aleksey Kladov
cd6df6935f minor: make sure that project_root works correctly 2021-07-13 15:02:29 +03:00
bors[bot]
62622c6940
Merge #9550
9550: Proc macro multi abi proof of concept r=matklad a=alexjg

#8925 was irritating me so I thought I would have a bash at fixing it. What I've done here is copy the `crates/proc_macro_srv/src/proc_macro` code (which is copied from `<RUST>/library/proc_macro`) to `crates/proc_macro_srv/src/proc_macro_nightly` and the modified the nightly version to include the changes from https://github.com/rust-analyzer/rust-analyzer/pull/9047 and aeb7b183a2

This gives us the code to support both stable and nightly ABIs. Then we use the `proc_macro_api::version::read_dylib_info` to determine which version of the ABI to load when creating a `ProcMacroLibraryLibLoading` (which is now an enum). 

This seems to work for me.  The code could be cleaned up but I wanted to see if the approach makes sense before I spend more time on it.

I've split the change into two commits, the first is just copying and modifying the `proc_macro` crate, the second contains most of the interesting work around figuring out which ABI to use.

Co-authored-by: Alex Good <alex@memoryandthought.me>
Co-authored-by: alexjg <alex@memoryandthought.me>
2021-07-13 10:35:20 +00:00
Aleksey Kladov
6f269708e8 internal: get rid of a call to slow O(N) visibility_of function
Instead of inferring module's declared visibility by looking at the
scope of its parent, let's just remeber the declared visibility in the
DefMap.
2021-07-12 21:13:43 +03:00
Aleksey Kladov
a9d0d1414a internal: remove erroneous default impl 2021-07-12 20:18:07 +03:00
Aleksey Kladov
67a7dfda43 internal: remove deprecated fn 2021-07-12 20:05:09 +03:00
Aleksey Kladov
d40cf52e6d internal: perpare to remove ModuleData::default 2021-07-12 20:02:56 +03:00
Aleksey Kladov
107e07458c internal: remove erroneous Default impl for ModuleOrigin
In rust-analyzer, we avoid defualt impls for types which don't have
sensible, "empty" defaults. In particular, we avoid using invalid
indices for defaults and similar hacks.
2021-07-12 20:00:17 +03:00
Alex Good
e240eb67a8 Introduce proc_macro_srv::abis, impl 1.47 and 1.55
Rather than a "Stable" and "Nightly" ABI we instead name ABIs based on
the version of the rust compiler in which they were introduced. We place
these ABIs in a new module - `proc_macro_srv::abis` - where we also add
some mchinery to abstract over ABIs. This should make it easy to add new
ABIs at a later date as the rust compiler evolves.
2021-07-12 16:05:45 +01:00
alexjg
14a51d28b5 check rustc major version == 1 not < 1
Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2021-07-12 16:05:45 +01:00
Alex Good
39b8d10b93 Use rustc version of dylib to choose which proc macro ABI to use 2021-07-12 16:05:45 +01:00
Alex Good
a8b0a91011 copy proc_maco to proc_macro_nightly and modify for nightly ABI compatibility 2021-07-12 16:05:45 +01:00
Jonas Schievink
7c2b9fb660 Set more CARGO_ env vars 2021-07-12 15:34:49 +02:00
bors[bot]
091dbfe637
Merge #9535
9535: internal: remove proc macro management thread r=jonas-schievink a=jonas-schievink

Communication with the proc macro server process has always happened one request at a time, so the additional thread isn't really needed (it just forwarded each request, and sent back the response). This removes some indirection that was a bit hard to understand (a channel was allocated and sent over another channel to return the response).

Hope I'm not missing anything here

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-07-12 13:23:26 +00:00
Jonas Schievink
29db33ce76 Address review comments 2021-07-12 15:19:53 +02:00
bors[bot]
fe00358888
Merge #9569
9569: internal: Explicitly check for reference locals or fields in Name classification r=Veykril a=Veykril

Closes #7524
Inlines all the calls to reference related name classification as well as emits both goto definition targets for field shorthands.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-11 14:28:08 +00:00
Lukas Wirth
ab2647769c Return both field and local references for shorthands in goto_def 2021-07-11 16:16:16 +02:00
Florian Diebold
44d3c32922 Add test for #9560 2021-07-11 16:14:39 +02:00
Florian Diebold
b7bd45574a Add workaround for #9562
This treats the consts generated by older synstructure versions like
unnamed consts. We should remove this at some point (at least after
Chalk has switched).
2021-07-11 16:14:39 +02:00
Lukas Wirth
c41f1279a3 Inline name classification reference calls 2021-07-11 15:39:09 +02:00
Lukas Wirth
c65bb7f8b9 Explicitly check for reference locals or fields in Name classification 2021-07-11 15:04:40 +02:00
bors[bot]
87621de2b9
Merge #9567 #9568
9567: remove unneded special case r=matklad a=matklad

bors r+
🤖

9568: feat: add 'for' postfix completion r=lnicola a=mahdi-frms


![Peek 2021-07-11 16-45](https://user-images.githubusercontent.com/62165556/125194692-a0aaf780-e267-11eb-952a-81de7955d9a1.gif)


adds #9561

used ```ele``` as identifier for each element in the iteration

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
Co-authored-by: mahdi-frms <mahdif1380@outlook.com>
2021-07-11 12:51:33 +00:00
Aleksey Kladov
bbb053532e internal: remove one more needless extern crate 2021-07-11 15:48:49 +03:00
Lukas Wirth
c6b6f18520 Simplify Semantics::type_of_expr_with_coercion 2021-07-11 14:44:10 +02:00
mahdi-frms
7bae9c9187 add 'for' postfix completion 2021-07-11 17:10:57 +04:30
Aleksey Kladov
dbf11b16da typo 2021-07-11 15:13:42 +03:00
Aleksey Kladov
1171dc74e0 internal: remove unused param 2021-07-11 15:08:00 +03:00
Aleksey Kladov
5021f10660 internal: add a test for broken refactor 2021-07-11 15:05:16 +03:00
Aleksey Kladov
f42648e305 internal: remove needless distinction between a carte and its root mod 2021-07-11 14:55:24 +03:00
bors[bot]
0fbeacc1d3
Merge #9565
9565: internal: document NameClass and NameRefClass r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-07-11 11:41:51 +00:00
Aleksey Kladov
dedf0ff7c5 internal: document NameClass and NameRefClass 2021-07-11 14:41:21 +03:00
Aleksey Kladov
92059ea438 update tests 2021-07-11 13:55:00 +03:00
Aleksey Kladov
5c26523e94 drop unused fields 2021-07-11 13:51:52 +03:00
Aleksey Kladov
a04775060c simplify 2021-07-11 13:49:38 +03:00
Aleksey Kladov
ddce16a126 drop unused field 2021-07-11 13:48:26 +03:00
Aleksey Kladov
beb81a40eb simplify 2021-07-11 13:45:58 +03:00
Aleksey Kladov
96d85a9efb be explicit about what we *can't* debug 2021-07-11 13:44:28 +03:00
Aleksey Kladov
fa6f78c95b better name 2021-07-11 13:43:43 +03:00
Aleksey Kladov
0dc186f612 Let the client care about presentation 2021-07-11 13:42:19 +03:00
Aleksey Kladov
148e11aa9e prepare to move run/debug splitting to handlers 2021-07-11 13:34:22 +03:00
bors[bot]
325140a165
Merge #9449
9449: feat: Emit test names in `Run test` runnables if they come from a macro expansion r=matklad a=Veykril

Fixes #8964
Before:
![Code_D1Tu5Iuh5I](https://user-images.githubusercontent.com/3757771/124174685-f552b380-daac-11eb-9086-c97db014b77c.png)
After:
![image](https://user-images.githubusercontent.com/3757771/124174493-bb81ad00-daac-11eb-96c7-3de6545a62e1.png)

Basically when a macro emits more than one test we name the test functions/modules name in the runnable instead to not emit a bunch of equally named `Run Test` annotations which don't really tell much.

Note that the `Run fibonacci_test Tests` line is below the attributes due to the fact that the function name span is being reused for the generated module in rstest's expansion.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-11 09:37:33 +00:00
Kirill Bulatov
8ed9724413 Do not erase Cargo diagnostics from the closed documents 2021-07-11 00:04:11 +03:00
bors[bot]
2e52d6ea93
Merge #9557
9557: fix: Respect coercions in `inline_call` r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-10 17:25:16 +00:00
Lukas Wirth
9e1eb77f6b Respect coercions in inline_call 2021-07-10 19:24:49 +02:00
Lukas Wirth
7e6f40b6f1 Expose coercions for patterns and expressions in semantics 2021-07-10 19:03:46 +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
bors[bot]
2d7727fe31
Merge #9553
9553: minor: Disambiguate replace with if let assist labels r=Veykril a=Veykril

Turns out we have two assists for replacing something with `if let` constructs, so having the cursor on a `let` keyword inside a match gave you two identical assist labels which is rather confusing.
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-10 16:07:01 +00:00
Lukas Wirth
0796288ed2 Disambiguate replace with if let assist labels 2021-07-10 18:00:22 +02:00
bors[bot]
4337f5e456
Merge #9555 #9556
9555: feat: Enable `auto_import` on ident patterns r=Veykril a=Veykril

Helpful for when you want to import a type in a pattern right before destructuring it.

9556: Bump deps r=lnicola a=lnicola

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-07-10 15:59:26 +00:00
Laurențiu Nicola
df729eda69 Bump chalk 2021-07-10 18:58:14 +03:00
Laurențiu Nicola
861f1e2a86 Bump rustc_lexer a little 2021-07-10 18:57:59 +03:00
Lukas Wirth
79614c486b Enable auto_import on ident patterns 2021-07-10 17:57:33 +02:00
bors[bot]
6f3a3bdde4
Merge #9551
9551: fix: `replace_qualified_name_with_use` keeps qualifier for import r=Veykril a=Veykril

Fixes #9537, #9540
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-10 15:04:15 +00:00
Lukas Wirth
0db5992311 replace_qualified_name_with_use keeps qualifier for import 2021-07-10 17:03:24 +02:00
bors[bot]
637dbb26a7
Merge #9548
9548: add: Adding self keyword completion in complete_fn_param r=lnicola a=feniljain

Solves #9522

I haven't added Arc<self> for now as there were some conflicting opinions on it

Co-authored-by: vi_mi <fenil.jain2018@vitstudent.ac.in>
2021-07-10 11:39:13 +00:00
vi_mi
1338ddbe80 add: Adding self keyword completion in complete_fn_param 2021-07-10 16:11:15 +05:30
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