Commit graph

8290 commits

Author SHA1 Message Date
Kirill Bulatov
ca698a0b8c Adjust the test comment 2020-09-11 14:16:15 +03:00
bors[bot]
eb7136f76d
Merge #5957
5957: Add consuming modifier to lvalues that are passed by value and not Copy r=jonas-schievink a=Nashenas88

Related to #5856 

Co-authored-by: Paul Daniel Faria <Nashenas88@users.noreply.github.com>
2020-09-10 21:59:00 +00:00
Kirill Bulatov
b477f99bd9 One more test 2020-09-11 00:20:13 +03:00
bors[bot]
868f4b5756
Merge #5956
5956: Highlight errors in macros r=jonas-schievink a=popzxc

Resolves #4924 

This PR makes rust-analyzer highlight not only the source place when error originates in macro, but also the exact places in macro which caused an error.

This is done by creating an inverse diagnostic, which points to the macro and cross-references the source place.

![изображение](https://user-images.githubusercontent.com/12111581/92319594-b71e6c00-f022-11ea-94c1-f412905269dd.png)


Co-authored-by: Igor Aleksanov <popzxc@yandex.ru>
2020-09-10 20:55:06 +00:00
Pavan Kumar Sunkara
4d97f5f037 Rename record_field_pat to record_pat_field 2020-09-10 18:56:04 +02:00
oxalica
251ef93ac3
Implement async blocks 2020-09-10 20:01:23 +08:00
Kirill Bulatov
208d4609b0 Use better heuristics for replacement text when removing dbg! 2020-09-10 14:14:24 +03:00
Kirill Bulatov
492e3c40f6 One more test 2020-09-10 01:58:29 +03:00
Kirill Bulatov
9863798480 Rename the method to avoid false promises 2020-09-10 01:45:49 +03:00
Kirill Bulatov
f4ee885b3b Add VirtualPath tests 2020-09-10 01:42:20 +03:00
Kirill Bulatov
a7d75463c7 Fix the tests 2020-09-10 01:42:20 +03:00
Kirill Bulatov
5aebf54fd4 Add tests 2020-09-10 01:42:20 +03:00
Kirill Bulatov
dbf70cd015 Properly handle mod.rs imports 2020-09-10 01:42:20 +03:00
Kirill Bulatov
9fb83211f9 Complete semicolon when needed 2020-09-10 01:42:20 +03:00
Kirill Bulatov
57a260f579 Properly reacto to keywords 2020-09-10 01:42:20 +03:00
Kirill Bulatov
cc43abcde8 Less false positive completion candidates 2020-09-10 01:42:20 +03:00
Kirill Bulatov
3fd6f45141 Properly handle nested submodules in the same file 2020-09-10 01:42:20 +03:00
Kirill Bulatov
f9c14ac720 Move most of the logic into the completion module 2020-09-10 01:42:20 +03:00
Kirill Bulatov
6ba479cd05 Finally cretae the mod completion module 2020-09-10 01:42:20 +03:00
Kirill Bulatov
33179a0ae1 Move rust-related logic from vfs to base_db level 2020-09-10 01:42:20 +03:00
Kirill Bulatov
b2bcc5278d Properly handle special cases (binaries, mod.rs) 2020-09-10 01:42:20 +03:00
Kirill Bulatov
486c5c3285 Exclude special files 2020-09-10 01:42:20 +03:00
Kirill Bulatov
897a4c702e Implement file name & extension retrieval method for VirtualPath 2020-09-10 01:42:20 +03:00
Kirill Bulatov
d163f9f114 Small refactoring 2020-09-10 01:42:20 +03:00
Kirill Bulatov
8aa740dab4 Happy path implemented 2020-09-10 01:42:20 +03:00
Kirill Bulatov
0de71f7bc9 Properly use FileSet API 2020-09-10 01:42:20 +03:00
Kirill Bulatov
17870a3e2c Better API 2020-09-10 01:42:20 +03:00
Kirill Bulatov
4bed588001 First steps for mod<|> completion 2020-09-10 01:42:20 +03:00
bors[bot]
5c336e266f
Merge #5968
5968: Lookup ADT and associated type names for chalk debugging / tweak chalk interner r=flodiebold a=nathanwhit

This PR improves the chalk program writing integration by looking up the names for ADTs and associated types, making the output much more readable.

There are also a few small changes to the interner, which gives some nice performance improvements. We clone `Ty`s and `ProgramClause`s relatively often in chalk, so wrapping them in `Arc`s is a perf win. This takes the time for performing type inference on the rust-analyzer codebase from 40s to 33s on my machine.

Co-authored-by: Nathan Whitaker <nathan.whitaker01@gmail.com>
2020-09-09 17:20:39 +00:00
Nathan Whitaker
bf0b194fed Tweak interner for chalk 2020-09-09 12:55:38 -04:00
Nathan Whitaker
20663a2a8b Lookup ADT and assoc. type names for chalk debug 2020-09-09 12:55:05 -04:00
Paul Daniel Faria
a1a7b07ad3 Fix handling of consuming self, refactor shared logic into a single function 2020-09-06 14:34:01 -04:00
Paul Daniel Faria
7af947a032 Add consuming modifier to lvalues that are passed by value and not Copy 2020-09-06 12:26:53 -04:00
Igor Aleksanov
023e3a1dea Highlight errors in macros 2020-09-06 09:22:01 +03:00
Lukas Wirth
74b755d233 Allow merge_imports assists to merge imports of equal visibility 2020-09-05 16:15:16 +02:00
Lukas Wirth
7ccb198af8 Remove duplicated import merge logic 2020-09-05 15:51:26 +02:00
Lukas Wirth
d201317c67 Fix segment_iter not iterating segments properly 2020-09-05 15:44:54 +02:00
bors[bot]
0275b08d15
Merge #5940
5940: Implement "Replace `impl Trait` function argument with the named generic" assist. r=matklad a=alekseysidorov

Fixes #5085 

Co-authored-by: Aleksei Sidorov <gorthauer87@yandex.ru>
2020-09-04 21:54:42 +00:00
Aleksei Sidorov
e1b8d836a9 Remove unnecessary comma 2020-09-04 22:58:50 +03:00
Aleksei Sidorov
ef0a1b2e58 Fix tests 2020-09-04 17:55:27 +03:00
bors[bot]
9dfa69a44a
Merge #5935
5935: Rewrite import insertion r=matklad a=Veykril

This is my attempt at refactoring the import insertion #3947. I hope what I created here is somewhat in line with what was requested, it wouldn't surprise me .

`common_prefix` is a copy from `merge_imports.rs` so those should be unified somewhere, `try_merge_trees` is also copied from there but slighly modified to take the `MergeBehaviour` enum into account.
`MergeBehaviour` should in the end become a configuration option, and the order if `ImportGroup` probably as well?

I'm not too familiar with the assist stuff and the like which is why I dont know what i have to do with `insert_use_statement` and `find_insert_use_container` for now.

I will most likely add more test cases in the end as well as I currently only tried to hit every path in `find_insert_position`. 
Some of the merge tests also fail atm due to them not sorting what they insert. There is also this test case I'm not sure if we want to support it. I would assume we want to? https://github.com/rust-analyzer/rust-analyzer/pull/5935/files#diff-6923916dd8bdd2f1ab4b984adacd265fR540-R547

The entire module was rewritten so looking at the the file itself is probably better than looking at the diff.

Regarding the sub issues of #3947:
- #3301: This is fixed with the rewrite, what this implementation does is that it scans through the first occurence of groupings and picks the appropriate one out. This means the user can actually rearrange the groupings on a per file basis to their liking. If a group isnt being found it is inserted according to the `ImportGroup` variant order(Would be nice if this was configurable I imagine).
- #3831: This should be fixed with the introduced `MergeBehaviour` enum and it's `Last` variant.
- #3946: This should also be [fixed](https://github.com/rust-analyzer/rust-analyzer/pull/5935/files#diff-6923916dd8bdd2f1ab4b984adacd265fR87)
- #5795: This is fixed in the sense that the grouping search picks the first group that is of the same kind as the import that is being added. So if  there is a random import in the middle of the program it should only be considered if there is no group of the same kind in the file already present.
- the last point in the list I havent checked yet, tho I got the feeling that it's not gonna be too simple as that will require knowledge of whether in this example `ast` is a crate or the module that is already imported.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-09-04 13:28:05 +00:00
Aleksei Sidorov
a1c060c8d0 Update codegen 2020-09-04 15:28:08 +03:00
Aleksei Sidorov
477fa75cfb Fix nitpicks 2020-09-04 15:24:36 +03:00
kjeremy
11758d518a Up proc-macro2 to 1.20
This changes the way Display is implemented
2020-09-03 17:40:12 -04:00
Lukas Wirth
82f61e6629 Add extra insert_use test for pub(crate) re-export handling 2020-09-03 20:26:27 +02:00
Lukas Wirth
d29b69cbe6 Disable insert_import in extract_struct_from_enum_variant until its fixed 2020-09-03 18:36:08 +02:00
Lukas Wirth
7de2a30f40 Fix import insertion breaking nested modules 2020-09-03 18:36:08 +02:00
Lukas Wirth
98e2f674e9 Fix inserting imports in front of inner attributes 2020-09-03 18:36:08 +02:00
Lukas Wirth
c1925df7fc Replace insert_use_statement with the new insert_use 2020-09-03 18:36:08 +02:00
Lukas Wirth
952f385682 Impl make::blank_line 2020-09-03 18:36:07 +02:00
Lukas Wirth
07ff9eeca8 Use mark to check that paths that are too long will not be merged 2020-09-03 18:36:07 +02:00
Lukas Wirth
74186d3ae7 Tidy up tests and apply suggested changes 2020-09-03 18:36:07 +02:00
Lukas Wirth
903c7eb2e5 Add more import insertion tests 2020-09-03 18:36:07 +02:00
Lukas Wirth
ed37335c01 Begin refactor of import insertion 2020-09-03 18:36:07 +02:00
Aleksei Sidorov
7259cc82f3 Resolve most of corner cases 2020-09-03 17:46:04 +03:00
Aleksei Sidorov
fe3170dc34 Initial implementation of the #5085 issue 2020-09-03 14:47:07 +03:00
Aleksey Kladov
9684daa029 Actually assert disjointness 2020-09-03 13:37:36 +02:00
bors[bot]
a000346ab2
Merge #5941
5941: Unify naming
 r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-09-03 10:23:08 +00:00
Aleksey Kladov
75b1f9ee23 Unify naming 2020-09-03 12:18:46 +02:00
bors[bot]
d2c3832a8a
Merge #5937
5937: Chalk 0.25 r=matklad a=kjeremy

Picks up flodiebold's infinite loop fix

Co-authored-by: kjeremy <kjeremy@gmail.com>
2020-09-03 10:13:41 +00:00
Andy Russell
24805d1d80
default checkOnSave.enable to true in server 2020-09-02 17:44:21 -04:00
kjeremy
5e4195bb6a Chalk 0.25
Picks up flodiebold's infinite loop fix
2020-09-02 14:07:06 -04:00
kjeremy
36692bdffa Switch to upstream ENUM_MEMBER 2020-09-02 09:40:59 -04:00
kjeremy
b527257330 Move to vscode-languageclient 7.0.0-next.9
Stabilizes call hierarchy and semantic tokens features.
2020-09-02 09:40:59 -04:00
Aramis Razzaghipour
321108673d Document VS Code setting needed for on-typing assists 2020-09-01 23:40:53 +10:00
Aleksey Kladov
7f54ded71b Bump token expansion limit
We hit this for redis crate, reported at

Reported at
https://www.reddit.com/r/rust/comments/ikfsf8/rustanalyzer_doesnt_work_with_the_redis_crate/
2020-09-01 14:55:41 +02:00
Aleksey Kladov
b1f59ff6c1 Reduce path_from_text usage 2020-08-31 15:47:42 +02:00
Aleksey Kladov
60706fca8e Remove dead code 2020-08-31 15:46:57 +02:00
Kirill Bulatov
3ac9732ca3 Fix some typos 2020-08-28 21:55:24 +03:00
Aleksey Kladov
c692b5d76d ⬆️ expect-test 2020-08-28 14:47:14 +02:00
Aleksey Kladov
07da02fc37 ⬆️ crates 2020-08-27 19:06:00 +02:00
Aleksey Kladov
4b989009e3 CONST LOOPS ARE HERE 2020-08-27 18:12:01 +02:00
Aleksey Kladov
4d0cfc07fd Minor 2020-08-27 15:02:56 +02:00
bors[bot]
e7da5816d6
Merge #5895
5895: Tease apart orthogonal concerns in markdown link rewriting
 r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-08-26 18:26:07 +00:00
Aleksey Kladov
f8a59adf5e Tease apart orthogonal concerns in markdown link rewriting
`hir` should know nothing about URLs, markdown and html. It should
only be able to:

* resolve stringy path from documentation
* generate canonical stringy path for a def

In contrast, link rewriting should not care about semantics of paths
and names resolution, and should be concern only with text mangling
bits.
2020-08-26 20:24:00 +02:00
bors[bot]
7e012ae8b5
Merge #5893
5893: Allow running a test as a binary r=matklad a=jonas-schievink

If a test uses `harness = false`, it just contains an `fn main` that is executed via `cargo test`. This adds support for that.

Note though that Cargo doesn't actually tell us whether `harness = false`, so this hint will always show up when you put an `fn main` into an integration test. Normally people shouldn't be doing that if they do use the harness though.

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-08-26 17:41:45 +00:00
Aleksey Kladov
1c0ac2b9b4 Cleanup hover links tests 2020-08-26 18:36:16 +02:00
Jonas Schievink
964219f0be Allow running a test as a binary 2020-08-26 17:33:03 +02:00
León Orell Valerian Liehr
63caef372a Improve support for code block attributes 2020-08-26 15:55:06 +02:00
Aleksey Kladov
7431ec82c9 Simplify 2020-08-26 13:40:45 +02:00
bors[bot]
868aaf2bc6
Merge #5889
5889: Allow logging to file r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-08-26 11:21:17 +00:00
Aleksey Kladov
ed6304131a Simplify 2020-08-26 13:20:46 +02:00
Aleksey Kladov
bb50614d88 Simplify help 2020-08-26 13:20:46 +02:00
Aleksey Kladov
a53c6f6fee Allow redirecting logs to a specific file
There's a surprising lack of crates which are like env_logger, but
also allow writing to a file. Let's write our own then!
2020-08-26 13:20:46 +02:00
Aleksey Kladov
0fc8fd2bd5 **Inline Variable** works with field shorthand 2020-08-26 13:03:14 +02:00
Aleksey Kladov
189521a4db Add sysroot shortcut to rust-project.json 2020-08-25 19:41:56 +02:00
Aleksey Kladov
c6dffe479b Cleanup heavy tests 2020-08-25 19:26:45 +02:00
Aleksey Kladov
9786a8f2d4 Don't expose indexing details 2020-08-25 18:40:41 +02:00
Aleksey Kladov
4f6ca0e081 Minor 2020-08-25 18:07:25 +02:00
Aleksey Kladov
7239d8ca95 Provide better stack trace for overlapping edits
Overlapping indels are a bug. Checking this *always* is tricky (needs
a sorted data structure to not suffer O(N^2) perf). But
opportunistically checking small indels should give provide 80% of the
benefits.
2020-08-25 17:59:37 +02:00
Aleksey Kladov
7fcda5aa46 Prepare to share sysroot lowering code between Cargo & ProjectJSON 2020-08-25 17:53:24 +02:00
Aleksey Kladov
18b667cfcb Complete pub in fields 2020-08-25 17:22:23 +02:00
Aleksey Kladov
6b8bc132dc Prep work for overriding sysroot
The idea here is to make auto-discovery optional, and to allow to set
the path to sysroot directly. This is handy for JSON projects.
2020-08-25 17:04:24 +02:00
Aleksey Kladov
cd9ecdf467 Remove monomorphisation from doclinks resolving code 2020-08-25 14:58:22 +02:00
Aleksey Kladov
66e5ced894 Remove AttrDef 2020-08-25 14:44:15 +02:00
Aleksey Kladov
7487885309 Simplify 2020-08-25 12:58:00 +02:00
Aleksey Kladov
575fb9ab6a Move attrs from code_module to a separate module 2020-08-25 12:56:01 +02:00
Aleksey Kladov
663749beab Minor 2020-08-25 12:48:00 +02:00
Aleksey Kladov
b45dd9ef54 Use the same abstraction for attrs and docs
Doc comments *are* attributes, so there's no reason to have two crates
here.
2020-08-25 12:13:31 +02:00
bors[bot]
59c77ff062
Merge #5866
5866: Improve logging
 r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-08-25 09:46:21 +00:00