Commit graph

8253 commits

Author SHA1 Message Date
bors[bot]
a61178d218
Merge #5985
5985: Make MergeBehaviour configurable r=jonas-schievink a=Veykril

This should make the newly implemented `MergeBehaviour` for import insertion configurable as roughly outlined in https://github.com/rust-analyzer/rust-analyzer/pull/5935#issuecomment-685834257. For the config name and the like I just picked what came to mind so that might be up for bikeshedding.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-09-14 10:12:08 +00:00
bors[bot]
0d03fe6ef5
Merge #5971
5971: Implement async blocks r=flodiebold a=oxalica

Fix #4018

@flodiebold already gave a generic guide in the issue. Here's some concern about implementation detail:
- Chalk doesn't support generator type yet.
- Adding generator type as a brand new type (ctor) can be complex and need to *re-introduced* builtin impls. (Like how we implement closures before native closure support of chalk, which is already removed in #5401 )
- The output type of async block should be known after type inference of the whole body.
  - We cannot directly get the type from source like return-positon-impl-trait. But we still need to provide trait bounds when chalk asking for `opaque_ty_data`.
  - During the inference, the output type of async block can be temporary unknown and participate the later inference.
    `let a = async { None }; let _: i32 = a.await.unwrap();`

So in this PR, the type of async blocks is inferred as an opaque type parameterized by the `Future::Output` type it should be, like what we do with closure type.
And it really works now.

Well, I still have some questions:
- The bounds `AsyncBlockImplType<T>: Future<Output = T>` is currently generated in `opaque_ty_data`. I'm not sure if we should put this code here.
- Type of async block is now rendered as `impl Future<Output = OutputType>`. Do we need to special display to hint that it's a async block? Note that closure type has its special format, instead of `impl Fn(..) -> ..` or function type.



Co-authored-by: oxalica <oxalicc@pm.me>
2020-09-13 17:28:22 +00:00
Jonas Schievink
07a704e31c Implement box pattern inference 2020-09-12 21:18:57 +02:00
Jonas Schievink
2de6eb7bc8 Add box pattern test 2020-09-12 21:15:00 +02:00
Lukas Wirth
adc4c6b9d7 Make MergeBehaviour configurable 2020-09-12 12:11:16 +02:00
Kirill Bulatov
779ea2ea0a Properly preserve macro braces 2020-09-11 22:16:22 +03:00
oxalica
529c369c9b
Fix type walking about type of async block 2020-09-12 01:08:50 +08:00
oxalica
cc4e287bb5
Fix and prettify comments 2020-09-12 00:12:42 +08:00
bors[bot]
568dc38b7b
Merge #5955
5955: Remove merge import code duplication r=jonas-schievink a=Veykril

This removes the code duplication caused by #5935, this also allows the assist to merge imports that have equal visibility and prevents merges of unequal visibility. This PR also fixes an iteration mistake in the mentioned PR:

Turns out I made a mistake when writing the `segment_iter` function, I was assuming that the `children` of a path will just be the segments, which is obviously not the case. This also brings insertion order of shorter paths in line with how `rustfmt` orders them.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-09-11 14:01:20 +00:00
bors[bot]
96e988fcc3
Merge #5951 #5975
5951: Rename record_field_pat to record_pat_field r=jonas-schievink a=pksunkara

The token was renamed but not this.

5975: Report better errors in project.json/sysroot r=jonas-schievink a=jonas-schievink

This does a bunch of light refactoring so that the `Sysroot` is loaded later, which makes sure that any errors are reported to the user. I then added a check that reports an error if libcore is missing in the loaded sysroot. Since a sysroot without libcore is very useless, this indicates a configuration error.

Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-09-11 13:47:33 +00:00
bors[bot]
87c8dfcadd
Merge #5970
5970: Use better heuristics for replacement text when removing dbg! r=jonas-schievink a=SomeoneToIgnore

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

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-09-11 13:41:15 +00:00
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
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