Commit graph

6435 commits

Author SHA1 Message Date
Craig Disselkoen
5aa1bba107 more generic, find rustc as well 2020-05-05 16:12:56 -07:00
Craig Disselkoen
ffaef1b7ae ra_project_model: look for Cargo in more places
See #3118
2020-05-05 16:12:56 -07:00
bors[bot]
30eb458b4f
Merge #4332
4332: Refactor TextEdit r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-05-05 21:50:47 +00:00
Aleksey Kladov
ca9e0f5fe9 Fixup tests 2020-05-05 23:48:26 +02:00
Aleksey Kladov
27c7ef6d65 Use more natural signature for Edit::apply 2020-05-05 23:23:29 +02:00
Aleksey Kladov
4a6fa8f0df Rename AtomTextEdit -> Indel 2020-05-05 23:15:49 +02:00
guigui64
c22660179c
add the allFeatures flag (true by default) 2020-05-05 22:46:42 +02:00
Aleksey Kladov
381cbc6088 Minor cleanups 2020-05-05 22:14:01 +02:00
bors[bot]
d38741f681
Merge #4327
4327: Refactor assists r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-05-05 19:36:53 +00:00
Aleksey Kladov
3908fad1fe Normalize naming of diagnostics 2020-05-05 21:35:30 +02:00
Aleksey Kladov
df00da15c4 Fix compilation 2020-05-05 20:45:44 +02:00
Aleksey Kladov
aee22c73c3 Move group_label where it belongs 2020-05-05 20:42:52 +02:00
Aleksey Kladov
6c2414430a use GroupLabel for type safety 2020-05-05 20:34:45 +02:00
Aleksey Kladov
d5b9282ede Minor rename 2020-05-05 20:33:10 +02:00
Aleksey Kladov
13c078db9c Flip Assist::new arguments 2020-05-05 20:30:33 +02:00
bors[bot]
a4778ddb7a
Merge #4325
4325: Fix column conversion for supplementary plane characters r=matklad a=lnicola

Fixes https://github.com/rust-analyzer/rust-analyzer/pull/4276#issuecomment-623079855.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-05-05 18:10:39 +00:00
Laurențiu Nicola
1d794e8590 Fix column conversion for supplementary plane characters 2020-05-05 20:30:52 +03:00
bors[bot]
8803e748a6
Merge #4166
4166: Defining a default target to support cross-compilation targets  r=matklad a=FuriouZz

Related to #4163 

Co-authored-by: Christophe MASSOLIN <christophe.massolin@gmail.com>
2020-05-05 17:25:52 +00:00
bors[bot]
df7b59081f
Merge #4323
4323: Add tests for #4306 r=kjeremy a=lnicola

CC @kjeremy 

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-05-05 17:01:46 +00:00
Laurențiu Nicola
7ec1b63f81 Add tests for #4306 2020-05-05 19:39:45 +03:00
Christophe MASSOLIN
04e32fbffc Remove code duplicates 2020-05-05 18:23:47 +02:00
bors[bot]
f0411ff9e0
Merge #4320
4320: add doctest support r=matklad a=bnjjj

close #4317

preview:

<img width="253" alt="Capture d’écran 2020-05-05 à 17 39 58" src="https://user-images.githubusercontent.com/5719034/81086040-45110b80-8ef8-11ea-9c05-79c6fe400fc3.png">


Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-05 16:22:31 +00:00
Christophe MASSOLIN
14dde99627 Pass cargo.target to rustc 2020-05-05 18:15:13 +02:00
Christophe MASSOLIN
0ab4340cdb Rename defaultTarget to target 2020-05-05 18:01:54 +02:00
Edwin Cheng
92665358cd Rename ImplItem to AssocItem 2020-05-05 23:56:10 +08:00
Benjamin Coenen
fe52f8f028 add doctest support #4317
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-05 17:44:27 +02:00
bors[bot]
756e91732b
Merge #4305
4305: Favor types for record type struct in name resolution r=matklad a=edwin0cheng

Fixed #4235

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-05-05 15:06:41 +00:00
Edwin Cheng
07de8ea165 invert if 2020-05-05 23:01:07 +08:00
bors[bot]
f68e099777
Merge #4265
4265: Make `change_visibility` assist work for tuple struct fields r=matklad a=Jesse-Bakker

Fixes #4206 

Co-authored-by: Jesse Bakker <git@jessebakker.com>
2020-05-05 14:42:33 +00:00
robojumper
f2dd233ddc Assume cargo_metadata uses String for cfgs soon 2020-05-05 14:53:52 +02:00
robojumper
059fc86963 Merge heavy tests 2020-05-05 14:53:18 +02:00
Benjamin Coenen
0bf02f5cca do not truncate display for hover #4311
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-05 14:29:25 +02:00
bors[bot]
d1c1c01309
Merge #4306 #4308
4306: Make incremental sync opt-out and fix line index rebuild r=matklad a=lnicola



4308: Update server binary paths in docs r=matklad a=Coder-256

Fixed incorrect macOS path and converted to a list. Also, should the Windows path include `matklad.rust-analyzer`? (I can't check)

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
Co-authored-by: Jacob Greenfield <jacob@jacobgreenfield.me>
2020-05-05 10:02:56 +00:00
Benjamin Coenen
831bb1cf91 refactor: use attrsOwner directly in is_cfg_enabled
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-05 09:34:07 +02:00
Edwin Cheng
cf821cc332 Change union resolve types only 2020-05-05 01:19:54 +08:00
Edwin Cheng
e921195d93 Change favor_types to has_constructor 2020-05-05 01:15:27 +08:00
Laurențiu Nicola
7c1d5f286a Fix line index rebuild during incremental changes 2020-05-04 20:04:30 +03:00
Laurențiu Nicola
191abf3685 Make incremental sync opt-out 2020-05-04 19:54:39 +03:00
Edwin Cheng
5ae18f4f81 Remove unused import 2020-05-05 00:34:54 +08:00
Edwin Cheng
204c8de3bf Add test for issue 2020-05-05 00:29:47 +08:00
Edwin Cheng
af001677d1 Fix test 2020-05-05 00:17:30 +08:00
Edwin Cheng
8d96db3417 Favor types for Record in name resolution 2020-05-05 00:17:22 +08:00
Aleksey Kladov
b211c5814e Remove false positive attr compleitons 2020-05-04 16:48:50 +02:00
Aleksey Kladov
8f4478390e Qualify ast types 2020-05-04 15:33:08 +02:00
Aleksey Kladov
e9643ab74c Cleanup imports 2020-05-04 15:33:08 +02:00
Aleksey Kladov
71f6d58e31 Remove unnecessary condition
No tests fail, and quick manual testing shows that there are no
false-positives. In general, each completion contributor should be
independent from the others.
2020-05-04 15:32:23 +02:00
Aleksey Kladov
d7450222a9 Simplify 2020-05-04 14:55:24 +02:00
bors[bot]
580c5a969d
Merge #4297
4297: refactor: use parent instead ancestors for use alias r=matklad a=bnjjj

Linked to this comment https://github.com/rust-analyzer/rust-analyzer/pull/4269/files#r419343670

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-04 12:37:41 +00:00
Aleksey Kladov
802617ccc2 Simplify 2020-05-04 14:16:10 +02:00
Benjamin Coenen
e88c3e4fcd refactor: use parent instead ancestors for use alias
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-04 13:42:30 +02:00
robojumper
2980ba1fde Support build.rs cargo:rustc-cfg 2020-05-04 13:29:09 +02:00
bors[bot]
57f285d0eb
Merge #4283
4283: Support macro for trait items r=matklad a=edwin0cheng

Fixed  #4039

r? @flodiebold 

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
Co-authored-by: Edwin Cheng <edwin@m-inverse.com>
2020-05-04 10:49:24 +00:00
Edwin Cheng
5899c8eaa9 Fixes names for collect_item funtions 2020-05-04 18:34:32 +08:00
bors[bot]
b1a5dc8c8b
Merge #4269 #4293
4269: add support of use alias semantic in definition r=matklad a=bnjjj

close #4202 

4293: no doctests for flycheck r=matklad a=matklad



bors r+
🤖

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-05-04 10:34:06 +00:00
Aleksey Kladov
6af464d185 no doctests for flycheck 2020-05-04 12:26:52 +02:00
Aleksey Kladov
710e430dbb Fix focus range for TypeParam
closes #4274
2020-05-04 12:25:32 +02:00
Aleksey Kladov
13bce1a164 Add test marks 2020-05-04 12:10:26 +02:00
bors[bot]
3b1d983085
Merge #4282
4282: More name hints omitting heuristics r=matklad a=SomeoneToIgnore

Omit parameter name hints for cases like the first two parameters from the screenshot:

<img width="394" alt="Screenshot 2020-05-03 at 15 06 34" src="https://user-images.githubusercontent.com/2690773/80914717-165b2f80-8d56-11ea-8675-040972f70d98.png">


Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-05-04 08:36:48 +00:00
Kirill Bulatov
30817de3af Code review fixes
Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-05-04 11:04:02 +03:00
bors[bot]
d855280818
Merge #4285
4285: add support of cfg attributes on enum variants r=edwin0cheng a=bnjjj

close #4279

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-04 03:18:48 +00:00
bors[bot]
57ec813294
Merge #4286
4286: Make incremental sync opt-in r=matklad a=lnicola

@matklad do you want to merge this? I'd make it opt-out, but it's fine to test it more.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-05-04 03:03:52 +00:00
bors[bot]
6a48a94d47
Merge #4268
4268: Support auto-import in macro r=SomeoneToIgnore a=edwin0cheng

Fixed: #3854

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-05-03 22:52:10 +00:00
Kirill Bulatov
66882f1a24 Move snake case method to heck 2020-05-03 21:35:21 +03:00
Laurențiu Nicola
87a18b18ea Make incremental sync opt-in 2020-05-03 20:58:07 +03:00
Benjamin Coenen
bed115d6e1 add support of cfg attributes on enum variants #4279
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-03 17:56:45 +02:00
Edwin Cheng
73ed2f2e90 Remove whitespaces 2020-05-03 22:15:07 +08:00
Edwin Cheng
8b6216df05 Support macro for trait items 2020-05-03 22:08:39 +08:00
Kirill Bulatov
ba8ffab644 Omit name hints for enum names similar to parameter names 2020-05-03 15:55:08 +03:00
Kirill Bulatov
8eb820f460 Omit name hints for method names similar to parameter names 2020-05-03 15:55:08 +03:00
bors[bot]
baa35b02b2
Merge #4280
4280: Add documents owner for ImplDef and SourceFile r=matklad a=edwin0cheng

When working on #3182, I found that `ImplDef` and `SourceFile` do not implemet `DocCommentsOwer` trait, and I tested it in `cargo doc` that `impl` could has some doc-comments.

I am not so sure about `SourceFile` case, but in theory if that file is a crate root, the doc comment of it should represent the whole crate documentation, right ?

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-05-03 10:46:07 +00:00
Edwin Cheng
f90fbaf6a6 Add documents owner for ImplDef and SourceFile 2020-05-03 18:00:27 +08:00
bors[bot]
76c2f4ef49
Merge #4278
4278: Log panics in apply_document_changes r=matklad a=lnicola

This doesn't necessarily help (because of https://github.com/rust-analyzer/rust-analyzer/issues/4263#issuecomment-623078531), but maybe we could leave it in there for a while in case it catches something.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-05-03 09:48:44 +00:00
Laurențiu Nicola
074d1ac2f7 Log panics in apply_document_changes 2020-05-03 12:46:20 +03:00
bors[bot]
682c079043
Merge #4276
4276: Don't count start of non-ASCII characters as being inside of them r=matklad a=lnicola

I'm still not sure that `utf16_to_utf8_col` is correct for code points from Supplementary Planes. These have two UTF-16 code units, and I feel we're not going to count them correctly.

Fixes the crash in https://github.com/rust-analyzer/rust-analyzer/issues/4263#issuecomment-622988258.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-05-03 08:57:02 +00:00
Laurențiu Nicola
16d3bb9106 Don't count start of non-ASCII characters as being inside of them 2020-05-03 09:54:39 +03:00
Kirill Bulatov
2fd054f276 Fix derive argument parsing 2020-05-02 23:47:51 +03:00
Benjamin Coenen
99c2ca8494 add support of use alias semantic in definition #4202
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-02 21:42:27 +02:00
Kirill Bulatov
9f0ed7ed92 Separate macros completion from other 2020-05-02 22:33:23 +03:00
Edwin Cheng
2034002413 Support auto-import in macro 2020-05-03 03:24:55 +08:00
Kirill Bulatov
fee74851b0 Propose custom derives in completion 2020-05-02 22:24:27 +03:00
Kirill Bulatov
767bff89ed Complete standard derives 2020-05-02 21:41:02 +03:00
Kirill Bulatov
c4b32d1534 Fix the extension method 2020-05-02 21:41:02 +03:00
Benjamin Coenen
4613497a77 Merge branch 'master' of github.com:rust-analyzer/rust-analyzer into fix_4202 2020-05-02 20:27:02 +02:00
Jesse Bakker
b5c330bf5a Make change_visibility assist work for tuple struct field visibility 2020-05-02 18:25:38 +02:00
bors[bot]
89e1f97515
Merge #4207 #4253
4207: Add unwrap block assist #4156 r=matklad a=bnjjj

close issue #4156 

4253: Remove `workspaceLoaded` setting r=matklad a=eminence

The `workspaceLoaded` notification setting was originally designed to
control the display of a popup message that said:

    "workspace loaded, {} rust packages"

This popup was removed and replaced by a much sleeker message in the
VSCode status bar that provides a real-time status while loading:

    rust-analyzer: {}/{} packages

This was done as part of #3587

The change in this PR simply renames this setting from `workspaceLoaded` to
`progress` to better describe what it actually controls.  At the moment,
the only type of progress message that is controlled by this setting is
the initial load messages, but in theory other messages could also be
controlled by this setting.


Reviewer notes:

* If we didn't like the idea of causing minor breaking to user's config, we could keep the setting name as `workspaceLoaded`
* I think we can now close both #2719 and #3176 since the notification dialog in question no longer exists (actually I think you can close those issues even if you reject this PR 😄 )

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Co-authored-by: Andrew Chin <achin@eminence32.net>
2020-05-02 12:44:55 +00:00
Aleksey Kladov
359d3be308 Fix parsing of blocks without { 2020-05-02 14:35:17 +02:00
Benjamin Coenen
fdf86637bf Merge branch 'master' of github.com:rust-analyzer/rust-analyzer 2020-05-02 13:39:05 +02:00
Benjamin Coenen
6d5f3922f7 Add unwrap block assist #4156
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-02 12:31:11 +02:00
bors[bot]
fb8fb65131
Merge #4234
4234: Support local_inner_macros r=jonas-schievink a=edwin0cheng

This PR implements `#[macro_export(local_inner_macros)]` support. 

Note that the rustc implementation is quite [hacky][1] too. :)

[1]: 614f273e93/src/librustc_resolve/macros.rs (L456)

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-05-02 10:30:49 +00:00
Benjamin Coenen
0b40876b99 Merge branch 'master' of github.com:rust-analyzer/rust-analyzer 2020-05-02 12:25:04 +02:00
Benjamin Coenen
eea21738ab Add unwrap block assist #4156
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-02 12:20:39 +02:00
bors[bot]
75bc024946
Merge #4257
4257: ast::EffectExpr r=matklad a=matklad

closes #4230 

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-05-02 09:57:45 +00:00
Aleksey Kladov
b73dbbfbf2 Add missing members generates indented blocks 2020-05-02 11:53:07 +02:00
bors[bot]
235728319f
Merge #4256
4256: Improve formatting of analyzer status text r=flodiebold a=eminence

The old formatting had everything on 1 line, making it quite hard to read:

    requests:    1 textDocument/documentSymbol         2ms    2 textDocument/codeAction             2ms    3 rust-analyzer/inlayHints            20ms    4 textDocument/foldingRange           108ms    6 textDocument/codeLens               66ms    5 textDocument/semanticTokens/range   76ms    8 rust-analyzer/inlayHints            195ms    7 textDocument/semanticTokens         250ms    9 textDocument/semanticTokens/range   108ms


It now looks like this:

```
requests:
*   1 textDocument/documentSymbol         11ms
    2 textDocument/codeAction             15ms
    3 rust-analyzer/inlayHints            4ms
    5 textDocument/foldingRange           3ms
    4 textDocument/semanticTokens/range   45ms
    6 textDocument/codeLens               182ms
    8 rust-analyzer/inlayHints            124ms
    7 textDocument/semanticTokens         127ms
    9 textDocument/documentHighlight      2ms
   10 textDocument/codeAction             3ms
```

Co-authored-by: Andrew Chin <achin@eminence32.net>
2020-05-02 09:45:37 +00:00
Aleksey Kladov
b58dfd24f1 Add smoke test for decorated blocks 2020-05-02 11:27:28 +02:00
Aleksey Kladov
623faefcda Cleanup inline tests 2020-05-02 11:21:39 +02:00
Aleksey Kladov
642a3392d9 Update test data 2020-05-02 11:21:39 +02:00
Aleksey Kladov
4f2134cc33 Introduce EffectExpr 2020-05-02 11:21:39 +02:00
Aleksey Kladov
247d32cbfd Test/check the whole package
Closes #4255
2020-05-02 10:57:37 +02:00
Edwin Cheng
edf0b4c152 Test whether it is bang macro properly 2020-05-02 10:16:26 +08:00
Edwin Cheng
291d03949b Add test in name resolutions 2020-05-02 10:06:17 +08:00
Edwin Cheng
443762cda9
Update crates/ra_hir_expand/src/builtin_derive.rs
Fix spacing

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-05-02 09:56:38 +08:00
Andrew Chin
65234e8828 Remove workspaceLoaded setting
The `workspaceLoaded` notification setting was originally designed to
control the display of a popup message that said:

  "workspace loaded, {} rust packages"

This popup was removed and replaced by a much sleeker message in the
VSCode status bar that provides a real-time status while loading:

  rust-analyzer: {}/{} packages

This was done as part of #3587

The new status-bar indicator is unobtrusive and shouldn't need to be
disabled.  So this setting is removed.
2020-05-01 21:04:41 -04:00
Andrew Chin
76f34a15e6 Improve formatting of analyzer status text 2020-05-01 19:13:52 -04:00
Aleksey Kladov
fd030f9450 Revert "Merge #4233"
This reverts commit a5f2b16366, reversing
changes made to c96b2180c1.
2020-05-02 01:12:37 +02:00
kjeremy
810c961961 Update crates 2020-05-01 18:26:42 -04:00
bors[bot]
3232fd5179
Merge #4220 #4240
4220: Introduce LowerCtx r=matklad a=edwin0cheng

This PR introduces `LowerCtx` for path lowering. 

After this PR, there are only 2 places remains for using deprecated `Path::from_ast`, which is related to `AstTransform` I am not familiar. I would like to change these in another PR by others ;)

related disscusiion:  https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Path.3A.3Afrom_src

And also fixed part of https://github.com/rust-analyzer/rust-analyzer/issues/4176#issuecomment-620672930

4240: Bump deps r=matklad a=lnicola



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-05-01 20:16:25 +00:00
bors[bot]
8d02b24b25
Merge #4244
4244: Show unsafe trait in hover r=matklad a=DianaNites

Following on #2450 and #4210, for traits.
`unsafe` is the only qualifier they can have, though.

Co-authored-by: Diana <5275194+DianaNites@users.noreply.github.com>
2020-05-01 19:45:48 +00:00
bors[bot]
21588e15df
Merge #4246
4246: Validate uses of self and super r=matklad a=djrenren

This change follows on the validation of the `crate` keyword in paths. It verifies the following things:

`super`:
 - May only be preceded by other `super` segments
 - If in a `UseItem` then all semantically preceding paths also consist only of `super`

`self`
 - May only be the start of a path


Just a note, a couple times while working on this I found myself really wanting a Visitor of some sort so that I could traverse descendants while skipping sub-trees that are unimportant. Iterators don't really work for this, so as you can see I reached for recursion. Considering paths are generally small a fancy debounced visitor probably isn't important but figured I'd say something in case we had something like this lying around and I wasn't using it.

Co-authored-by: John Renner <john@jrenner.net>
2020-05-01 19:24:25 +00:00
kjeremy
99826dab15 Address comments 2020-05-01 14:12:31 -04:00
kjeremy
ee1628dba0 Mark most assists as the base "refactor" type
Most of them area. We will separate them out later but this gets them to
show up in the "refactor" menu of vscode.
2020-05-01 13:44:32 -04:00
kjeremy
e75565c73f Advertise support for all the builtin CodeActionKinds
Even thought we don't return all of these we eventually will so might as
well advertise now.
2020-05-01 13:44:32 -04:00
kjeremy
e3ee61f5e8 Filter out CodeActions if a server only support commands. 2020-05-01 13:44:32 -04:00
Diana
375dd18dc0 Fix pub(self) visibility?
Clippy complained about it and it seems wrong
2020-05-01 12:09:47 -04:00
John Renner
3bb46042fb Validate uses of self and super 2020-05-01 08:59:24 -07:00
Diana
ebff5762e9 Test for unsafe trait 2020-05-01 11:49:51 -04:00
Diana
6833183ab4 Unsafe traits 2020-05-01 11:49:41 -04:00
Benjamin Coenen
df7899e47a Add unwrap block assist #4156
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-01 16:41:29 +02:00
Benjamin Coenen
dc34162450 Merge branch 'master' of github.com:rust-analyzer/rust-analyzer 2020-05-01 16:26:30 +02:00
Benjamin Coenen
19e28888aa wip
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-01 16:26:22 +02:00
Edwin Cheng
7bbdeb43a4 Make AttrQuery copyable 2020-05-01 20:58:24 +08:00
Laurențiu Nicola
1e20467c3a Bump deps 2020-05-01 15:29:03 +03:00
Edwin Cheng
44f5e2048c Remove lower_path from AssistCtx to Semantic 2020-05-01 20:05:12 +08:00
Edwin Cheng
bdcf6f5658 Introduce LowerCtx for path lowering 2020-05-01 20:01:17 +08:00
Edwin Cheng
1635d22a35 Add test 2020-05-01 20:01:17 +08:00
Edwin Cheng
e4267967a8 Support local_inner_macros 2020-05-01 11:23:03 +08:00
Aleksey Kladov
14126349be Kill more zombies 2020-04-30 22:58:26 +02:00
Aleksey Kladov
1865dedadf Introduce BlockModifier 2020-04-30 22:58:26 +02:00
Aleksey Kladov
292ba6a1f8 Remove dead code, which elaborately pretends to be alive 2020-04-30 22:41:14 +02:00
Aleksey Kladov
15cfa9a808 Fix a bunch of false-positives in join-lines 2020-04-30 22:08:50 +02:00
bors[bot]
23c889694e
Merge #4153
4153: Add support for incremental text synchronization r=matklad a=lnicola

Fixes #3762.

This still needs a `ra_vfs` PR, but I want to know I'm on the right track. I tested the change and it didn't crash horribly, but YMMV.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-04-30 19:00:30 +00:00
bors[bot]
745bd45ddb
Merge #4227
4227: Report invalid, nested, multi-segment crate-paths r=matklad a=djrenren

There was a bug in the previous path-validating code that didn't detect multi-segment paths that started with `crate`.

```rust
// Successfully reported
use foo::{crate};

// BUG: was not being reported
use foo::{crate::bar};
```

This was due to my confusion about path-associativity. That is, the path with no qualifier is the innermost path, not the outermost. I've updated the code with a lot of comments to explain what's going on. 

This bug was discovered when I found an erroneous `ok` test which I reported here: 
https://github.com/rust-analyzer/rust-analyzer/issues/4226

This test now fails and has been modified, hopefully in the spirit of the original test, to be correct.  Sorry about submitting the bug in the first place!

Co-authored-by: John Renner <john@jrenner.net>
2020-04-30 18:37:35 +00:00
Laurențiu Nicola
1a2d4e2921 Add support for incremental text synchronization 2020-04-30 21:26:57 +03:00
John Renner
513a3615f6 Report invalid, nested, multi-segment crate-paths
Specifically, things like:

use foo::{crate::bar};

Are now being caught, when before we only caught:

use foo::{crate};
2020-04-30 11:16:09 -07:00
Edwin Cheng
45c4f620b1 Special-case try macro_rules 2020-04-30 22:07:46 +08:00
Aleksey Kladov
c51c8bfb84 Special-case try macro to better support 2015 edition 2020-04-30 14:17:14 +02:00
bors[bot]
fdaddb98b5
Merge #4210
4210: Include function qualifiers in signature r=matklad a=oxalica

Fixes #2450

It seems there's no test for `ra_ide/display/{short_label,function_signature}`. I'm not sure how to setup it.

Manually tested:
<img width="428" alt="Screenshot_20200430_004434" src="https://user-images.githubusercontent.com/14816024/80622769-d6f1c200-8a7b-11ea-91f3-e94bfb2703c5.png">


Co-authored-by: oxalica <oxalicc@pm.me>
2020-04-30 11:09:57 +00:00
bors[bot]
95e8766db6
Merge #4178
4178: Validate the location of `crate` in paths r=matklad a=djrenren

**This solution does not fully handle `use` statements. See below**

This pull requests implements simple validation of usages of the `crate` keyword in `Path`s. Specifically it validates that:

- If a `PathSegment` is starts with the `crate` keyword, it is also the first segment of the `Path`
- All other usages of `crate` in `Path`s are considered errors.

This aligns with `rustc`'s rules. Unlike rustc this implementation does not issue a special error message in the case of `::crate` but it does catch the error.

Furthermore, this change does not cover all error cases. Specifically the following is not caught:

```rust
use foo::{crate}
```

This is because this check is context sensitive. From an AST perspective, `crate` is the root of the `Path`. Only by inspecting the full `UseItem` do we see that it is not in fact the root. This problem becomes worse because `UseTree`s are allowed to be arbitrarily nested:

```rust
use {crate, {{crate, foo::{crate}}}
```

So this is a hard problem to solve without essentially a breadth-first search. In a traditional compiler, I'd say this error is most easily found during the AST -> HIR conversion pass but within rust-analyzer I'm not sure where it belongs.  

Under the implementation in this PR, such errors are ignored so we're *more correct* just not *entirely correct*. 

Co-authored-by: John Renner <john@jrenner.net>
2020-04-30 10:17:40 +00:00
oxalica
b9b342ff93
Add tests of showing function qualifiers 2020-04-30 12:54:16 +08:00
Jonas Schievink
0cd6a88cf6 if let -> match 2020-04-30 00:10:30 +02:00
Jonas Schievink
15233a467d ? 2020-04-30 00:10:30 +02:00
Jonas Schievink
cafa7a780a Use or-patterns more 2020-04-30 00:10:30 +02:00
Jonas Schievink
3e41483932 Remove .clone() 2020-04-30 00:10:30 +02:00
Jonas Schievink
3cb73da949 Rename to associated_type_shorthand_candidates 2020-04-30 00:10:30 +02:00
Jonas Schievink
8c2670026a Complete assoc. items on type parameters 2020-04-30 00:10:30 +02:00
John Renner
0af727da91 Validate the location of crate in paths 2020-04-29 11:06:51 -07:00
oxalica
414d8d9c38
Include function qualifiers in signature 2020-04-30 00:34:46 +08:00
bors[bot]
1cde354c35
Merge #4119
4119: Cache proc-macro dlls r=matklad a=edwin0cheng

This PR try to fix a deadlock in proc-macro srv by not unloading dlls.

Currently we load and unload dlls for each request, however rustc TLS is leaky , such that if we do it a lot of times, all TLS index will be consumed and it will be deadlocked inside panic (it is because panic itself is using TLS too).


Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-04-29 13:28:57 +00:00
Benjamin Coenen
bbe22640b8 Add unwrap block assist #4156
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-04-29 14:53:47 +02:00
Aleksey Kladov
b4dd475257 More principled approach for finding From trait 2020-04-29 14:51:44 +02:00
Benjamin Coenen
76733f0cd4 Add unwrap block assist #4156
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-04-29 14:08:30 +02:00
bors[bot]
c3dfeba165
Merge #4204
4204: Use specific pattern when translating if-let-else to match r=matklad a=matklad

We *probably* should actually use the same machinery here, as we do
for fill match arms, but just special-casing options and results seems
to be a good first step.



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-29 10:01:26 +00:00
Aleksey Kladov
7c3c289dab Use specific pattern when translating if-let-else to match
We *probably* should actually use the same machinery here, as we do
for fill match arms, but just special-casing options and results seems
to be a good first step.
2020-04-29 11:59:11 +02:00
Aleksey Kladov
041aea2263 Better filtering of qualified enum variants in completion 2020-04-29 11:26:21 +02:00
Aleksey Kladov
73bef854ab Move shared assist code to utils 2020-04-29 10:38:51 +02:00
Jonas Schievink
8cb139090f Complete union fields after dot 2020-04-28 22:45:46 +02:00
bors[bot]
07f690ddf6
Merge #4161
4161: lsp-types 0.74 r=kjeremy a=kjeremy

* Fixes a bunch of param types to take partial progress into account.
* Will allow us to support insert/replace text in completions

Co-authored-by: kjeremy <kjeremy@gmail.com>
2020-04-28 20:12:44 +00:00
bors[bot]
db441de0a8
Merge #4193
4193: Make it impossible to forget to add a semantic token type / modifier r=kjeremy a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-28 20:05:08 +00:00
bors[bot]
2096db90b4
Merge #4184
4184: Treat comments beginning with four slashes as regular line comments r=kjeremy a=adamrk

Addresses https://github.com/rust-analyzer/rust-analyzer/issues/4040

Co-authored-by: adamrk <ark.email@gmail.com>
2020-04-28 19:57:23 +00:00
adamrk
0bd7d81805 Fix comment prefix method for four slash comments 2020-04-28 21:13:37 +02:00
bors[bot]
9230ae5492
Merge #4148
4148: Simplify profiler impl (bubble up Option) r=matklad a=Veetaha



Co-authored-by: veetaha <veetaha2@gmail.com>
2020-04-28 18:44:34 +00:00
Aleksey Kladov
890938a48c Make it impossible to forget to add a semantic token type / modifier 2020-04-28 17:14:05 +02:00
Leander Tentrup
052e9faa90 Introduce new semantic highlight token for format specifier 2020-04-28 11:13:12 +02:00
adamrk
b6560e3ebb Treat comments beginning with four slashes as regular line comments 2020-04-28 10:23:45 +02:00
Christophe MASSOLIN
e7523511ce [config] remove RustcConfig 2020-04-28 00:17:23 +02:00
Christophe MASSOLIN
ed5af989f4 [config] rename cargo.defaultTarget 2020-04-28 00:15:54 +02:00
bors[bot]
da1f316b02
Merge #4173
4173: Use core instead of std for builtin derive macros r=edwin0cheng a=edwin0cheng

Fixed #4087.

We can't use `$crate` here right now because : 

1. We have to able to detect `macro` 2.0 in collecting phase for finding `rustc_builtin_macro` attrs.
2. And we have to make hygiene works for builtin derive macro.

r= @flodiebold 

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-04-27 20:12:27 +00:00
Edwin Cheng
c69f9c1b0a Check dep name to detect it is core 2020-04-28 04:11:24 +08:00
Edwin Cheng
6d3b0af900 Use empty-deps tricks to detect it is core 2020-04-28 03:32:47 +08:00
Edwin Cheng
213d208e2d Add test 2020-04-28 02:10:17 +08:00
Edwin Cheng
6a5014329a Use core instead of std for builtin derive macros 2020-04-28 01:48:55 +08:00
Christophe MASSOLIN
b7edffe244 Started rust-analyzer.cargo.defaultTarget implementation 2020-04-27 00:11:04 +02:00
kjeremy
61f1c0a990 lsp-types 0.74
* Fixes a bunch of param types to take partial progress into account.
* Will allow us to support insert/replace text in completions
2020-04-26 16:05:22 -04:00
Florian Diebold
497073abc6 For associated type shorthand (T::Item), use the substs from the where clause
So e.g. if we have `fn foo<T: SomeTrait<u32>>() -> T::Item`, we want to lower
that to `<T as SomeTrait<u32>>::Item` and not `<T as SomeTrait<_>>::Item`.
2020-04-26 16:58:08 +02:00
Edwin Cheng
bfce657377 Generate uniq name 2020-04-26 18:59:09 +08:00
Edwin Cheng
183673655f Simpify code 2020-04-26 17:58:56 +08:00
Edwin Cheng
fb996cae6b Fix 2020-04-26 17:17:37 +08:00
Edwin Cheng
3bad5587c8 Compare timestamp 2020-04-26 17:17:37 +08:00
Edwin Cheng
5a5bba5a46 Copy dylib to temp directory 2020-04-26 17:17:37 +08:00
Edwin Cheng
3e24444aee Cacheproc-macro dlls 2020-04-26 17:17:37 +08:00
bors[bot]
ef67e0a497
Merge #4155
4155: Precompute expected type during completion r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-26 08:54:42 +00:00
Aleksey Kladov
05cdc87158 Precompute expected type during completion 2020-04-26 10:54:08 +02:00
Aleksey Kladov
5ef0f44499 Add cargo test to the list of Run commands 2020-04-26 10:40:34 +02:00
veetaha
24d18d92f6 Simplify profiler impl (bubble up Option and shorten code 2020-04-26 00:55:49 +03:00
Jonas Schievink
5a355ff52b Fix broken test 2020-04-25 22:23:56 +02:00
Jonas Schievink
76d6f54471 Don't add call parens when an fn type is expected 2020-04-25 22:18:57 +02:00
bors[bot]
45832b990c
Merge #4145
4145: Remove dead code r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-25 19:30:04 +00:00
bors[bot]
7021352dc2
Merge #4113 #4136 #4141 #4142
4113: Support returning non-hierarchical symbols r=matklad a=kjeremy

If `hierarchicalDocumentSymbolSupport` is not true in the client capabilites
then it does not support the `DocumentSymbol[]` return type from the
`textDocument/documentSymbol` request and we must fall back to `SymbolInformation[]`.

This is one of the few requests that use the client capabilities to
differentiate between return types and could cause problems for clients.

See https://github.com/microsoft/language-server-protocol/pull/538#issuecomment-442510767 for more context.

Found while looking at #144

4136: add support for cfg feature attributes on expression #4063 r=matklad a=bnjjj

close issue #4063

4141: Fix typo r=matklad a=Veetaha



4142: Remove unnecessary async from vscode language client creation r=matklad a=Veetaha



Co-authored-by: kjeremy <kjeremy@gmail.com>
Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Co-authored-by: veetaha <veetaha2@gmail.com>
2020-04-25 19:23:15 +00:00
Aleksey Kladov
bd9ede0ec9 Extract messy tree handling out of profiling code 2020-04-25 21:22:40 +02:00
Aleksey Kladov
0f099ead88 Fix panic in NoSuchField diagnostic 2020-04-25 21:09:33 +02:00
Aleksey Kladov
95b989ec30 Simplify 2020-04-25 19:50:42 +02:00
veetaha
f52e2f6840 Fix typo 2020-04-25 20:49:51 +03:00
Aleksey Kladov
726938f598 Simplify hprof 2020-04-25 19:30:00 +02:00
Aleksey Kladov
b3e9f3d143 Move hprof to a separate file 2020-04-25 19:30:00 +02:00
Aleksey Kladov
7623db1106 minor clenup 2020-04-25 19:30:00 +02:00
bors[bot]
5671bacfa6
Merge #4139
4139: Add check for rules that no repetition which could match an empty token r=matklad a=edwin0cheng

Fix #4103

for `/ui/issues/issue-57597.rs`

This is `ParseError` of the macro rules , because it is how rustc handle it : 

a58b1ed44f/src/librustc_expand/mbe/macro_rules.rs (L558)


Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-04-25 16:26:51 +00:00
bors[bot]
67afeebaf5
Merge #4137
4137: Prefer core/alloc paths on #![no_std] r=matklad a=jonas-schievink



Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-04-25 16:19:21 +00:00
Edwin Cheng
d5eb43f246 Checks no repetition for an empty token 2020-04-25 23:30:10 +08:00
bors[bot]
fc57358efd
Merge #4133
4133: main: eagerly prime goto-definition caches r=matklad a=BurntSushi

This commit eagerly primes the caches used by goto-definition by
submitting a "phantom" goto-definition request. This is perhaps a bit
circuitous, but it does actually get the job done. The result of this
change is that once RA is finished its initial loading of a project,
goto-definition requests are instant. There don't appear to be any more
surprise latency spikes.

This _partially_ addresses #1650 in that it front-loads the latency of the
first goto-definition request, which in turn makes it more predictable and
less surprising. In particular, this addresses the use case where one opens
the text editor, starts reading code for a while, and only later issues the
first goto-definition request. Before this PR, that first goto-definition request
is guaranteed to have high latency in any reasonably sized project. But
after this PR, there's a good chance that it will now be instant.

What this _doesn't_ address is that initial loading time. In fact, it makes it
longer by adding a phantom goto-definition request to the initial startup
sequence. However, I observed that while this did make initial loading
slower, it was overall a somewhat small (but not insignificant) fraction
of initial loading time.

-----

At least, the above is what I _want_ to do. The actual change in this PR is just a proof-of-concept. I came up with after an evening of printf-debugging. Once I found the spot where this cache priming should go, I was unsure of how to generate a phantom input. So I just took an input I knew worked from my printf-debugging and hacked it in. Obviously, what I'd like to do is make this more general such that it will always work.

I don't know whether this is the "right" approach or not. My guess is that there is perhaps a cleaner solution that more directly primes whatever cache is being lazily populated rather than fudging the issue with a phantom goto-definition request.

I created this as a draft PR because I'd really like help making this general. I think whether y'all want to accept this patch is perhaps a separate question. IMO, it seems like a good idea, but to be honest, I'm happy to maintain this patch on my own since it's so trivial. But I would like to generalize it so that it will work in any project.

My thinking is that all I really need to do is find a file and a token somewhere in the loaded project, and then use that as input. But I don't quite know how to connect all the data structures to do that. Any help would be appreciated!

cc @matklad since I've been a worm in your ear about this problem. :-)

Co-authored-by: Andrew Gallant <jamslam@gmail.com>
2020-04-25 14:30:10 +00:00
Jonas Schievink
3cf2c3b943 Prefer core/alloc paths on #![no_std] 2020-04-25 16:27:34 +02:00