Commit Graph

6151 Commits

Author SHA1 Message Date
Aleksey Kladov
4b8e9d5483 Move tests to where they belong 2020-04-24 01:26:27 +02:00
Aleksey Kladov
174952e89b Refactor 2020-04-24 01:24:08 +02:00
Aleksey Kladov
953b5f23cc Restore CompletionItem immutability 2020-04-24 01:17:33 +02:00
Aleksey Kladov
6654b9aff3 More functional 2020-04-24 01:08:27 +02:00
Aleksey Kladov
75cb1c1806 Move 2020-04-24 00:11:33 +02:00
bors[bot]
5eb51c1e60
Merge #4106
4106: Fix wrong substitution code r=matklad a=flodiebold

We need to shift in when we're substituting inside a binder.

This should fix #4053 (it doesn't fix the occasional overflow that also occurs on the Diesel codebase though).

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2020-04-23 21:58:52 +00:00
Florian Diebold
0c01b4eb6a Fix wrong substitution code
We need to shift in when we're substituting inside a binder.

This should fix #4053 (it doesn't fix the occasional overflow that also occurs
on the Diesel codebase though).
2020-04-23 23:53:08 +02:00
bors[bot]
e833e03783
Merge #3954
3954: Improve autocompletion by looking on the type and name r=matklad a=bnjjj

This tweet (https://twitter.com/tjholowaychuk/status/1248918374731714560) gaves me the idea to implement that in rust-analyzer.

Basically for this first example I made some examples when we are in a function call definition. I look on the parameter list to prioritize autocompletions for the same types and if it's the same type + the same name then it's displayed first in the completion list.

So here is a draft, first step to open a discussion and know what you think about the implementation. It works (cf tests) but maybe I can make a better implementation at some places. Be careful the code needs some refactoring to be better and concise.

PS: It was lot of fun writing this haha

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-04-23 21:48:45 +00:00
bors[bot]
01f1f10fec
Merge #4111 #4112
4111: Record definitions in `extern` blocks r=jonas-schievink a=jonas-schievink

Enables completion of extern functions and statics.

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

4112: Add Launch configuration for release build r=matklad a=jonas-schievink

The debug build takes very long until I can test anything useful, with the release build it's much quicker. Add another Run configuration for it.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-04-23 21:37:06 +00:00
Jonas Schievink
5cc9546ca0 Record definitions in extern blocks 2020-04-23 23:36:23 +02:00
Aleksey Kladov
dd59237e0c minor 2020-04-23 23:18:18 +02:00
Aleksey Kladov
27dd0086ea Fully get rid of SyntaxNodePtr::range 2020-04-23 21:23:36 +02:00
Edwin Cheng
1627b55028 Bubble up error 2020-04-24 01:38:58 +08:00
Aleksey Kladov
ca6d7bfe61 Cleanup proc_macro config
In general, there should be no reason to call `.to_string_lossy`.
If you want to display the path, use `.display()`.
If you want to pass the path to an OS API (like std::process::Command)
than use `PathBuf` or `OsString`.
2020-04-23 18:55:26 +02:00
Edwin Cheng
25e8f5ded9 Fix typo 2020-04-24 00:16:17 +08:00
Edwin Cheng
0744497699 Panic proc macro srv if read request failed 2020-04-24 00:06:01 +08:00
bors[bot]
278bf351e3
Merge #4065
4065: Complete unqualified enum names in patterns and expressions r=matklad a=nathanwhit

This PR implements the completion described in #4014.
The result looks like so for patterns:
<img width="542" alt="Screen Shot 2020-04-20 at 3 53 55 PM" src="https://user-images.githubusercontent.com/17734409/79794010-8f529400-831f-11ea-9673-f838aa9bc962.png">

and for `expr`s:
<img width="620" alt="Screen Shot 2020-04-21 at 3 51 24 PM" src="https://user-images.githubusercontent.com/17734409/79908784-d73ded80-83e9-11ea-991d-921f0cb27e6f.png">


I'm not confident that the completion text itself is very robust, as it will unconditionally add completions for enum variants with the form `Enum::Variant`. This means (I believe) it would still suggest `Enum::Variant` even if the local name is changed i.e. `use Enum as Foo` or the variants are brought into scope such as through `use Enum::*`.

Co-authored-by: nathanwhit <nathan.whitaker01@gmail.com>
2020-04-23 15:35:31 +00:00
Aleksey Kladov
4176c03d12 Remove SyntaxPtr::range from more places 2020-04-23 16:33:01 +02:00
bors[bot]
0502be3bf4
Merge #4093
4093: Simplify config r=matklad a=Veetaha



Co-authored-by: veetaha <veetaha2@gmail.com>
2020-04-23 09:49:03 +00:00
bors[bot]
6ec64805e3
Merge #4094
4094: proc_macro: add ability to log to stderr and view output in vscode r=matklad a=Veetaha

r? @edwin0cheng 

Co-authored-by: veetaha <veetaha2@gmail.com>
2020-04-23 09:32:45 +00:00
bors[bot]
604b936ca0
Merge #4092
4092: feat: run ignored tests r=matklad a=hdevalke

I started making some exercices on https://exercism.io/ and a lot of test have the `#[ignore]` attribute.
The `Run Test|Debug` code lens show up, but running the test results in:

```
running 1 test
test test_one_piece ... ignored

test result: ok. 0 passed; 0 failed; 1 ignored; 0 measured; 5 filtered out
```

This pull request adds the `--ignored` flag if needed.

Co-authored-by: Hannes De Valkeneer <hannes@de-valkeneer.be>
2020-04-23 09:24:15 +00:00
veetaha
a3a8d10191 Fix typo 2020-04-23 02:00:56 +03:00
veetaha
b5620341fc proc_macro: add ability to log to stderr and view output in vscode 2020-04-23 01:57:02 +03:00
veetaha
364fbd7fc7 Simplify config 2020-04-23 01:30:55 +03:00
Hannes De Valkeneer
380a2870c7 feat: run ignored tests 2020-04-22 23:54:09 +02:00
nathanwhit
dfde73ef90 Update tests to reflect new completions 2020-04-22 12:21:22 -04:00
nathanwhit
18ad86fdda Add tests for enum completion
Adds tests for completion of enum variants in match arms, if-let statements, and basic expressions.
2020-04-22 12:21:22 -04:00
nathanwhit
8664509745 Complete unqualified enum variants when possible 2020-04-22 12:21:14 -04:00
nathanwhit
6c61a7b22f Add utility fn for expected type of a node
Adds `expected_type_of` to `CompletionContext` to return the expected type of a
node, if it is known.
2020-04-22 12:20:18 -04:00
bors[bot]
3f1f3a835a
Merge #4090
4090: Fix config naming r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-22 15:26:47 +00:00
Aleksey Kladov
9e16e2b279 Align the name of proc-macro enabling flag
We use `enable`, not `enabled` elsewhere
2020-04-22 17:22:59 +02:00
Aleksey Kladov
d436beeb04 Match implementation of diagnostics flag to the docs 2020-04-22 17:22:18 +02:00
Leander Tentrup
445052f6d4 Adapt format specifier highlighting to support escaped squences and unicode identifiers 2020-04-22 15:28:35 +02:00
Leander Tentrup
b2829a5216 Apply suggestions from code review
Co-Authored-By: bjorn3 <bjorn3@users.noreply.github.com>
2020-04-22 10:18:46 +02:00
Andrew Chin
165f5c6577 Don't panic on rust-analyzer --help
Special case handling for `-h` and `--help` if no subcommand is given.

Closes #4068
2020-04-21 20:23:01 -04:00
Timo Freiberg
f2f882bc44 Add pub(crate) to functions generated in other module 2020-04-21 23:04:44 +02:00
Timo Freiberg
74780a15f6 Jump to sourceChanges in other files 2020-04-21 23:04:44 +02:00
Timo Freiberg
ba8faf3efc Add target file information to AssistAction 2020-04-21 23:04:44 +02:00
Timo Freiberg
317fc650d5 Make add_function generate functions in other modules via qualified path 2020-04-21 23:04:44 +02:00
Kirill Bulatov
ce06a6b422 Do not add default and closure types in 'add explicit type' assist 2020-04-21 22:56:40 +03:00
bors[bot]
7ab28cacbb
Merge #4076
4076: Improve remove derive attrs r=matklad a=edwin0cheng

This PR implemented a proper `remove_derive_attrs` function which **merely** remove  any `#[derive(*)]` attributes.

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-04-21 18:50:53 +00:00
Edwin Cheng
4a303366c8 Improve remove dervie attrs 2020-04-22 01:44:21 +08:00
Benjamin Coenen
da6b136ea5 Improve autocompletion by looking on the type and name
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-04-21 17:19:18 +02:00
bors[bot]
4a250021b1
Merge #4038
4038: Group generated ast boilerplate apart from the interesting part r=matklad a=Veetaha

Boilerplate `AstNode` and `From` impls are moved to the end further from the interesting part in `generated.rs`

Co-authored-by: veetaha <veetaha2@gmail.com>
2020-04-21 12:58:27 +00:00
Benjamin Coenen
b6a7be19d9 Improve autocompletion by looking on the type and name
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-04-21 14:36:56 +02:00
Benjamin Coenen
7f143b154e Merge branch 'master' of github.com:rust-analyzer/rust-analyzer 2020-04-21 14:32:02 +02:00
Benjamin Coenen
1c3a1385a5 Improve autocompletion by looking on the type and name
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-04-21 14:31:57 +02:00
bors[bot]
a88887df07
Merge #4071
4071: Cleanup args a bit r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-21 10:10:22 +00:00
Aleksey Kladov
d9bed8aa45 Cleanup args a bit 2020-04-21 12:06:25 +02:00
Edwin Cheng
ce382e6a79 Refactor a bit 2020-04-21 05:22:17 +08:00
Edwin Cheng
bd350108b0 Fix restart missing arguments in proc-macro-srv 2020-04-21 04:57:55 +08:00
bors[bot]
0ad6b6d407
Merge #4061
4061: ra_proc_macro: cleanups here and there r=edwin0cheng a=Veetaha

r? @edwin0cheng 

Co-authored-by: veetaha <veetaha2@gmail.com>
Co-authored-by: Veetaha <veetaha2@gmail.com>
2020-04-20 20:25:33 +00:00
veetaha
fc460b1e42 Migrate to Result<T, io::Error> -> io::Result<T> 2020-04-20 22:42:36 +03:00
veetaha
d8ca817456 Fix doc comment 2020-04-20 22:24:10 +03:00
Veetaha
834960d841
Fix typo
Co-Authored-By: Laurențiu Nicola <lnicola@users.noreply.github.com>
2020-04-20 22:07:47 +03:00
Veetaha
0f5b1fef5e Display path not debug it
Co-Authored-By: Laurențiu Nicola <lnicola@users.noreply.github.com>
2020-04-20 22:06:41 +03:00
Veetaha
982af2286a
Display path not debug it
Co-Authored-By: Laurențiu Nicola <lnicola@users.noreply.github.com>
2020-04-20 21:50:06 +03:00
veetaha
d3019164dc ra_proc_macro: cleanups here and there 2020-04-20 21:37:02 +03:00
Florian Diebold
0be68a4825 Update Chalk, and cache Chalk env elaboration through a query
This should fix some of the worst performance problems.
2020-04-20 19:16:01 +02:00
Aleksey Kladov
8a04372fec Fix panic in split_imports assist
The fix is admittedly quit literally just papering over.

Long-term, I see two more principled approaches:

* we switch to a fully tree-based impl, without parse . to_string
  step; with this approach, there shouldn't be any panics. The results
  might be nonsensical, but so was the original input.

* we preserve the invariant that re-parsing constructed node is an
  identity, and make all the `make_xxx` method return an `Option`.

closes #4044
2020-04-20 16:34:01 +02:00
Leander Tentrup
ac798e1f7c Implement syntax highlighting for format strings
Detailed changes:
1) Implement a lexer for string literals that divides the string in format specifier `{}` including the format specifier modifier.
2) Adapt syntax highlighting to add ranges for the detected sequences.
3) Add a test case for the format string syntax highlighting.
2020-04-20 11:19:15 +02:00
Jeremy Kolb
d7f3d858ad Some clippy fixes 2020-04-19 15:15:49 -04:00
veetaha
972d3b2ba3 Group generated ast boilerplate apart from the interesting part 2020-04-18 23:51:13 +03:00
bors[bot]
36840bd6c7
Merge #4036
4036: Fix a bunch of unresovled references r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-18 20:18:57 +00:00
Aleksey Kladov
b79fd82559 Correctly infer types in guard expressions
The root cause was that we forgot to add bindings from the arm to the
guard expression

closes #3980
2020-04-18 22:16:04 +02:00
Aleksey Kladov
fa2ea8f494 Fix goto definition for record patterns 2020-04-18 22:11:49 +02:00
bors[bot]
7a59cd49ff
Merge #4035
4035: Convert bool to ident instead of literal in mbe r=matklad a=edwin0cheng

Fixed #1249

Currently we treat boolean literal as `tt::Literal` , which makes parsing $lit:lit matcher easily.
However, proc-macro2 treat boolean literal as `ident` :

4173a21dc4/src/lib.rs (L939)

OT: I am quite happy we finally need to fix this bug :)

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-04-18 19:36:37 +00:00
bors[bot]
b95b77f92f
Merge #4034
4034: Add semantic tag for unresolved references r=matklad a=matklad

This is a quick way to implement unresolved reference diagnostics.
For example, adding to VS Code config

    "editor.tokenColorCustomizationsExperimental": {
        "unresolvedReference": "#FF0000"
    },

will highlight all unresolved refs in red.

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-18 19:29:17 +00:00
Aleksey Kladov
ca61356b01 Add semantic tag for unresolved references
This is a quick way to implement unresolved reference diagnostics.
For example, adding to VS Code config

    "editor.tokenColorCustomizationsExperimental": {
        "unresolvedReference": "#FF0000"
    },

will highlight all unresolved refs in red.
2020-04-18 21:28:51 +02:00
Edwin Cheng
a1b5cf81eb Convert bool to ident instead of literal in mbe 2020-04-19 03:24:17 +08:00
bors[bot]
b949500126
Merge #4032
4032: Add mbe lifetime split test r=matklad a=edwin0cheng



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-04-18 18:57:14 +00:00
Edwin Cheng
ce674be217 Add mbe lifetime split test 2020-04-19 02:45:17 +08:00
bors[bot]
6f60e646fc
Merge #3894
3894: Match check enum record r=flodiebold a=JoshMcguigan

This PR implements match statement exhaustiveness checking for record type enums.

It also make a minor addition to the test infrastructure to allow testing against a single diagnostic, so you can be sure your test is triggering (or not) whichever diagnostic you expect.

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
2020-04-18 18:42:07 +00:00
bors[bot]
98819d8919
Merge #4029
4029: Fix various proc-macro bugs r=matklad a=edwin0cheng

This PRs does the following things:

1. Fixed #4001 by splitting `LIFETIME` lexer token to two mbe tokens. It is because rustc token stream expects `LIFETIME` as a combination of punct and ident, but RA `tt:TokenTree` treats it as a single `Ident` previously.
2. Fixed #4003, by skipping `proc-macro` for completion. It is because currently we don't have `AstNode` for `proc-macro`. We would need to redesign how to implement `HasSource` for `proc-macro`.
3.  Fixed a bug how empty `TokenStream` merging in `proc-macro-srv` such that no L_DOLLAR and R_DOLLAR will be emitted accidentally. 


Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-04-18 17:56:54 +00:00
Benjamin Coenen
af3c19e85f Merge branch 'master' of github.com:rust-analyzer/rust-analyzer 2020-04-18 17:14:24 +02:00
Leander Tentrup
29a846464b Refactor flattening logic for highlighted syntax ranges 2020-04-18 15:02:51 +02:00
Josh Mcguigan
7adb681b1f missing match arm diagnostic support enum record type 2020-04-18 05:54:56 -07:00
Edwin Cheng
72bba98828 Merge empty delim subtree in proc-macro 2020-04-18 19:29:04 +08:00
Edwin Cheng
da18f11307 Split LIFETIME to two tokens in mbe 2020-04-18 19:28:07 +08:00
Edwin Cheng
f78de3bb95 Ignore proc-macro in completion 2020-04-18 19:26:54 +08:00
Florian Diebold
b49ecafd40 find_path: Builtins are always in scope
Fixes #3977.
2020-04-18 12:06:22 +02:00
bors[bot]
0948932145
Merge #4026
4026: Omit more parameter hints in the presence of underscores r=matklad a=lnicola

Fixes #4017.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-04-18 09:01:41 +00:00
bors[bot]
162481d5ce
Merge #4023
4023: Fix another crash from wrong binders r=matklad a=flodiebold

Basically, if we had something like `dyn Trait<T>` (where `T` is a type parameter) in an impl we lowered that to `dyn Trait<^0.0>`, when it should be `dyn Trait<^1.0>` because the `dyn` introduces a new binder. With one type parameter, that's just wrong, with two, it'll lead to crashes.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2020-04-18 08:48:08 +00:00
Laurențiu Nicola
8a51a74556 Omit more parameter hints in the presence of underscores 2020-04-18 10:53:48 +03:00
Florian Diebold
d3cb9ea0bf Fix another crash from wrong binders
Basically, if we had something like `dyn Trait<T>` (where `T` is a type
parameter) in an impl we lowered that to `dyn Trait<^0.0>`, when it should be
`dyn Trait<^1.0>` because the `dyn` introduces a new binder. With one type
parameter, that's just wrong, with two, it'll lead to crashes.
2020-04-18 00:01:09 +02:00
Leander Tentrup
2e2c03ee2d Fix incorrect order of syntax highlight ranges 2020-04-17 22:50:30 +02:00
Florian Diebold
6a7fc76b89 Fix type equality for dyn Trait
Fixes a lot of false type mismatches.

(And as always when touching the unification code, I have to say I'm looking
forward to replacing it by Chalk's...)
2020-04-17 19:42:36 +02:00
Florian Diebold
fbd95785a6 Add two more tests for associated types 2020-04-17 18:27:38 +02:00
Aleksey Kladov
f178df1a5e Don't use SyntaxNodePtr::range when determining scope for offset 2020-04-17 18:04:49 +02:00
bors[bot]
179d983535
Merge #4012
4012: fix panic on ellipsis in pattern r=flodiebold a=JoshMcguigan

fixes #3999

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
2020-04-17 12:39:20 +00:00
Josh Mcguigan
408f914bf4 fix panic on ellipsis in pattern 2020-04-17 05:36:44 -07:00
Aleksey Kladov
028f1e2e3a Don\t suggest import itself as a completion for import 2020-04-17 14:28:20 +02:00
bors[bot]
0262c9b9c0
Merge #4010
4010: Fix handling of ranges in diagnostics r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-17 11:57:29 +00:00
Aleksey Kladov
146f6f5a45 Simplify Diagnostic structure
It's not entirely clear what subnode ranges should mean in the
presence of macros, so let's leave them out for now. We are not using
them heavily anyway.
2020-04-17 13:56:42 +02:00
Aleksey Kladov
a8196ffe84 Correctly highlight ranges of diagnostics from macros
closes #2799
2020-04-17 13:56:38 +02:00
Aleksey Kladov
302bf97bbf Don't expose impl details of SyntaxPtr 2020-04-17 12:25:41 +02:00
bors[bot]
bd6b532224
Merge #4009
4009: Better snippet when completing trait method r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-17 10:06:01 +00:00
Aleksey Kladov
3b75bc154f Better snippet when completing trait method 2020-04-17 12:05:35 +02:00
bors[bot]
46105cdaba
Merge #4004
4004: Use mmap for proc macro libs r=matklad a=lnicola

Fixes #4002.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-04-17 09:40:53 +00:00
Laurențiu Nicola
93fcf1c133 Use mmap for proc macro libs 2020-04-17 12:38:38 +03:00
bors[bot]
f8016b8194
Merge #3996
3996: Fix path for proc-macro in nightly / stable release r=matklad a=edwin0cheng

I messed up that I forget we use different executable names for nightly / stable release, I changed to use the current executable name instead.

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-04-17 09:31:57 +00:00
Benjamin Coenen
379787858b feat: improve dot completions with scoring
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-04-17 10:59:04 +02:00
Benjamin Coenen
0a1585075c Merge branch 'master' of github.com:rust-analyzer/rust-analyzer 2020-04-17 10:30:39 +02:00
Benjamin Coenen
071ef268b5 feat: improve dot completions with scoring
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-04-17 10:29:32 +02:00
Laurențiu Nicola
02b96d522c Reduce allocations when looking up proc macro decl 2020-04-17 11:12:05 +03:00
Edwin Cheng
ef6ee16006 Fix path for proc-macro in nightly / stable build 2020-04-17 04:45:03 +08:00
bors[bot]
8d296be109
Merge #3995
3995: Separate project discovery from project loading r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-16 20:36:19 +00:00
Aleksey Kladov
422ae477ce Unmix error handling when discovering workspaces
Hitting an io::Error is a legit problem. Finding more than one
Cargo.toml is not.
2020-04-16 22:35:50 +02:00
bors[bot]
10d8cb913c
Merge #3958
3958: Add proc-macro related config and tests r=matklad a=edwin0cheng

This PR do the following things:

1. Add cli argument `proc-macro` for running proc-macro server.
2. Added support for proc-macro in bench and analysis-stats
3. Added typescript config for proc-macros
4. Added an heavy test for proc-macros. 

To test it out: 

1. run `cargo xtask install --proc-macro`
2. add `"rust-analyzer.cargo.loadOutDirsFromCheck": true"` and `"rust-analyzer.procMacro.enabled": true"` in vs code config.

[Edit] Change to use `rust-analyzer proc-macro` for running proc-macro standalone process.

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-04-16 20:21:59 +00:00
Edwin Cheng
b4c5ee33ae Fix extern_process args 2020-04-17 04:08:01 +08:00
Aleksey Kladov
be2654b0ed Decouple project loading from project discovery a bit 2020-04-16 22:02:10 +02:00
Aleksey Kladov
cae2498513 Don't expose SyntaxNodePtr impl details 2020-04-16 21:01:04 +02:00
Benjamin Coenen
6ebc8bbeb0 feat: improve dot completions with scoring
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-04-16 18:30:08 +02:00
Edwin Cheng
177becea98 Add proc-macro cli command for rust-analyzer 2020-04-16 21:13:57 +08:00
bors[bot]
0390d62168
Merge #3979
3979: fix missing match arm false positive for enum with no variants r=flodiebold a=JoshMcguigan

fixes #3974

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
2020-04-16 12:57:31 +00:00
Josh Mcguigan
360bdf653b fix false positive for enum with no variants 2020-04-16 05:37:49 -07:00
Edwin Cheng
ca7dc69a8e Add tests for proc_macro 2020-04-16 19:28:06 +08:00
Edwin Cheng
a4b0ce07f8 Add config for proc_macro 2020-04-16 19:28:06 +08:00
Edwin Cheng
22e33f308a Add with-proc-macro in bench ,stats and diagnositcs 2020-04-16 19:27:44 +08:00
Florian Diebold
39fe3a6486 Test for non-working proc macro server assoc types 2020-04-16 13:06:23 +02:00
Florian Diebold
14570df015 Switch Chalk to recursive solver
+ various fixes related to that.
2020-04-16 13:06:23 +02:00
Florian Diebold
e8d0d79a0c Update Chalk 2020-04-16 12:39:00 +02:00
Benjamin Coenen
06076f95a7 feat: improve dot completions in a struct literal expression
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-04-15 22:10:57 +02:00
bors[bot]
1e0ba04033
Merge #3966 #3968
3966: Add support for bounds on associated types in trait definitions r=matklad a=flodiebold

E.g.
```rust
trait Trait {
    type Item: SomeOtherTrait;
}
```
Note that these don't simply desugar to where clauses; as I understand it, where clauses have to be proved by the *user* of the trait, but these bounds are proved by the *implementor*. (Also, where clauses on associated types are unstable.)

(Another one from my recursive solver branch...)

3968: Remove format from syntax_bridge hot path r=matklad a=edwin0cheng

Although only around 1% speed up by running:

```
Measure-Command {start-process .\target\release\rust-analyzer "analysis-stats -q ." -NoNewWindow -wait}
```

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-04-15 09:29:36 +00:00
bors[bot]
d61909f904
Merge #3964 #3965 #3967
3964: Nicer Chalk debug logs r=matklad a=flodiebold

I'm looking at a lot of Chalk debug logs at the moment, so here's a few changes to make them slightly nicer...

3965: Implement inline associated type bounds r=matklad a=flodiebold

Like `Iterator<Item: SomeTrait>`.

This is an unstable feature, but it's used in the standard library e.g. in the definition of Flatten, so we can't get away with not implementing it :)

(This is cherry-picked from my recursive solver branch, where it works better, but I did manage to write a test that works with the current Chalk solver as well...)

3967: Handle `Self::Type` in trait definitions when referring to own associated type r=matklad a=flodiebold

It was implemented for other generic parameters for the trait, but not for `Self`.

(Last one off my recursive solver branch 😄 )

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2020-04-15 09:19:46 +00:00
bors[bot]
9726401eae
Merge #3963
3963: Upgrade Chalk r=matklad a=flodiebold



Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2020-04-15 09:08:39 +00:00
bors[bot]
923efa72bd
Merge #3969
3969: Change add_function assist to use todo!() instead of unimplemented!() r=matklad a=TimoFreiberg

In the spirit of #3935

Co-authored-by: Timo Freiberg <timo.freiberg@gmail.com>
2020-04-15 08:55:44 +00:00
bors[bot]
d6327297e4
Merge #3978
3978: insta 0.16 r=matklad a=kjeremy



Co-authored-by: kjeremy <kjeremy@gmail.com>
2020-04-15 08:31:18 +00:00
bors[bot]
b495e56b0d
Merge #3971
3971: add diagnostics subcommand to rust-analyzer CLI r=JoshMcguigan a=JoshMcguigan

This PR adds a `diagnostics` subcommand to the rust-analyzer CLI. The intent is to detect all diagnostics on a workspace. It returns a non-zero status code if any error diagnostics are detected. Ideally I'd like to run this in CI against the rust analyzer project as a guard against false positives.

```
$ cargo run --release --bin rust-analyzer -- diagnostics .
```

Questions for reviewers:

1. Is this the proper way to get all diagnostics for a workspace? It seems there are at least a few ways this can be done, and I'm not sure if this is the most appropriate mechanism to do this.
2. It currently prints out the relative file path as it is collecting diagnostics, but it doesn't print the crate name. Since the file name is relative to the crate there can be repeated names, so it would be nice to print some identifier for the crate as well, but it wasn't clear to me how best to accomplish this. 

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
2020-04-14 23:35:50 +00:00
Josh Mcguigan
6be972770e diagnostics cli, iterate over members 2020-04-14 16:26:03 -07:00
kjeremy
eedab116ab insta 0.16 2020-04-14 13:57:02 -04:00
Benjamin Coenen
c5d18f570c add sort_text to sort in editor view
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-04-14 19:28:33 +02:00
Benjamin Coenen
b092bbc83d Merge branch 'master' of github.com:rust-analyzer/rust-analyzer 2020-04-14 19:20:30 +02:00
Josh Mcguigan
f9701efbe7 cli diagnostics walk files 2020-04-14 04:35:34 -07:00
Josh Mcguigan
f62c73a972 add diagnostics subcommand to rust-analyzer CLI 2020-04-13 18:40:41 -07:00
Timo Freiberg
1231418f31 Change add_function assist to use todo!() 2020-04-13 22:17:06 +02:00
bors[bot]
c82e7696e6
Merge #3961
3961: Fix double comma when merge imports on second line r=edwin0cheng a=IceSentry

This fixes the bug when merging imports from the second line when it already has a comma it would previously insert a comma.

There's probably a better way to check for a COMMA. 

This also ends up with a weird indentation, but rust-fmt can easily deal with it so I'm not sure how to resolve that.

Closes #3832

Co-authored-by: IceSentry <c.giguere42@gmail.com>
2020-04-13 18:03:12 +00:00
IceSentry
ed0eedb1dd Fix PR 2020-04-13 13:59:30 -04:00
Edwin Cheng
464af68ec5 Remove format from syntax_bridge hot path 2020-04-14 01:23:33 +08:00
bors[bot]
d075f49e6d
Merge #3960
3960: ellipsis in tuple patterns r=JoshMcguigan a=JoshMcguigan

This PR lowers ellipsis in tuple patterns. It fixes a bug in the way ellipsis were previously lowered (by replacing the ellipsis with a single `Pat::Wild` no matter how many items the `..` was taking the place of).

It also uses this new information to properly handle `..` in tuple struct patterns when perform match statement exhaustiveness checks.

While this PR provides the building blocks for match statement exhaustiveness checks for tuples, there are some additional challenges there, so that is still unimplemented (unlike tuple structs).

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
2020-04-13 15:20:17 +00:00
Josh Mcguigan
ee822d19b7 handle tuple patterns with ellipsis 2020-04-13 08:19:19 -07:00
Florian Diebold
d88d67819b Handle Self::Type in trait definitions when referring to own associated type
It was implemented for other generic parameters for the trait, but not for `Self`.
2020-04-13 16:32:23 +02:00
Florian Diebold
c216a93da7 Upgrade Chalk 2020-04-13 16:18:25 +02:00
Florian Diebold
c8b2ec8c20 Add support for bounds on associated types in trait definitions
E.g.
```
trait Trait {
    type Item: SomeOtherTrait;
}
```
Note that these don't simply desugar to where clauses; as I understand it, where
clauses have to be proved by the *user* of the trait, but these bounds are proved
by the *implementor*. (Also, where clauses on associated types are unstable.)
2020-04-13 15:57:28 +02:00
Florian Diebold
db32a2e421 Implement inline associated type bounds
Like `Iterator<Item: SomeTrait>`.

This is an unstable feature, but it's used in the standard library e.g. in the
definition of Flatten, so we can't get away with not implementing it :)
2020-04-13 15:07:39 +02:00
Florian Diebold
2e7b88b525 Nicer display of projections in Chalk logs 2020-04-13 14:46:03 +02:00
Florian Diebold
7886513f89 Nicer display of closures in Chalk logs 2020-04-13 14:31:03 +02:00
IceSentry
2e279ca031 Generalize test and clean up imports 2020-04-12 21:34:01 -04:00
IceSentry
abdf725c55 Fix double comma when merge imports on second line
This fixes the a bug when merging imports from the second line when it already has a comma it would previously insert a comma.

There's probably a better way to check for a COMMA. 

This also ends up with a weird indentation, but rust-fmt can easily deal with it so I'm not sure how to resolve that.

Closes #3832
2020-04-12 21:29:14 -04:00
Benjamin Coenen
0640957429 Improve autocompletion by looking on the type and name, change implementation, include sort in Completions struct
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-04-12 17:58:06 +02:00