Commit Graph

12794 Commits

Author SHA1 Message Date
Jonas Schievink
681ac6294a Report better errors in project.json/sysroot 2020-09-11 14:48:56 +02:00
bors[bot]
4f1167d8dd
Merge #5969
5969: Propose module name completion options r=jonas-schievink a=SomeoneToIgnore

<img width="539" alt="image" src="https://user-images.githubusercontent.com/2690773/92663009-cb0aec00-f308-11ea-9ef5-1faa91518031.png">

Currently traverses the whole file set every time we try to complete the module, as discussed in https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/mod.3C.7C.3E.20completion

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-09-11 11:37:04 +00:00
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
bors[bot]
60c8941097
Merge #5965
5965: Update crates r=kjeremy a=kjeremy

Moves past pulled crossbeam-channel crate

Co-authored-by: kjeremy <kjeremy@gmail.com>
2020-09-08 13:02:14 +00:00
kjeremy
b74aba4011 Update crates
Gets passed pulled crossbeam crate
2020-09-08 08:50:03 -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
bors[bot]
8a21b2c96a
Merge #5948
5948: Up proc-macro2 to 1.20 r=matklad a=kjeremy

This changes the way Display is implemented

Co-authored-by: kjeremy <kjeremy@gmail.com>
2020-09-03 21:52:12 +00: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