Commit Graph

6012 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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