Commit graph

5816 commits

Author SHA1 Message Date
Aleksey Kladov
311cbbdad5 Remove some unwraps 2020-03-28 12:27:54 +01:00
Aleksey Kladov
6596e7cddf Nice string formatting 2020-03-28 12:27:54 +01:00
Aleksey Kladov
b764c38436 Start stdx
This crate will hold everything to small to be worth publishing
2020-03-28 11:01:25 +01:00
Piotr Szpetkowski
f016d8b900
Fix merge-imports assist for wildcard imports 2020-03-27 17:28:25 +01:00
Aleksey Kladov
dc311b10f3 Fix assist description 2020-03-27 13:23:19 +01:00
bors[bot]
a4901fdcfd
Merge #3742
3742: Replace if with if-let r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-27 11:21:57 +00:00
Aleksey Kladov
91e482b46d Replace if with if-let 2020-03-27 12:15:46 +01:00
bors[bot]
f9cf86475c
Merge #3741
3741: More general ctor for ifs r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-27 10:38:31 +00:00
Aleksey Kladov
cbb53cf55c More general ctor for ifs 2020-03-27 11:38:00 +01:00
bors[bot]
31528620a8
Merge #3740
3740: Simplify r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-27 10:27:01 +00:00
Aleksey Kladov
d953df319b Simplify 2020-03-27 11:25:11 +01:00
bors[bot]
b1594f1080
Merge #3727
3727: Introduce ra_proc_macro r=matklad a=edwin0cheng

This PR implemented:

1.  Reading dylib path of proc-macro crate from cargo check , similar to how `OUTDIR` is obtained.
2.  Added a new crate `ra_proc_macro` and implement the foot-work for reading result from external proc-macro expander. 
3. Added a struct `ProcMacroClient` , which will be responsible to the client side communication to the External process.



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-03-26 17:09:32 +00:00
Edwin Cheng
db162df264 Remove deps on tt_mbe 2020-03-27 00:46:40 +08:00
bors[bot]
20c110e57f
Merge #3732
3732: Assist: replace unwrap with match r=matklad a=unrealhoang

attempt on #3669

Co-authored-by: Unreal Hoang <unrealhoang@gmail.com>
2020-03-26 15:38:03 +00:00
Aleksey Kladov
db34abeb85 Get rid of ItemOrMacro 2020-03-26 16:10:01 +01:00
Unreal Hoang
d9df0f43ac
Assist: replace unwrap with match 2020-03-27 00:08:12 +09:00
Aleksey Kladov
b7aaefb5a4 Minor incremental tests cleanup 2020-03-26 15:44:31 +01:00
Edwin Cheng
72e68d0caf Refactoring a bit 2020-03-26 10:49:23 +08:00
Edwin Cheng
d0b6ed4441 Add ProcMacroClient 2020-03-26 03:29:45 +08:00
Aleksey Kladov
9f53cec1da Cleanup memory usage stats 2020-03-25 19:35:46 +01:00
Edwin Cheng
a617f24eae Add ra_proc_macro 2020-03-26 01:30:39 +08:00
Edwin Cheng
07ec31813c fix typo of visibility_of 2020-03-26 00:11:38 +08:00
bors[bot]
0f6fb0ec3b
Merge #3722
3722: Fix parsing lambdas with return type r=matklad a=matklad

We should eat only a single block, and not whatever larger expression
may start with a block.

closes #3721



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-25 16:01:54 +00:00
Aleksey Kladov
f6188caaa0 Fix parsing lambdas with return type
We should eat only a single block, and not whatever larger expression
may start with a block.

closes #3721
2020-03-25 17:01:28 +01:00
Aleksey Kladov
72c6fc3ff0 Fix add visibility false-positive 2020-03-25 15:55:57 +01:00
Aleksey Kladov
b3665fccfb Preserve relative ordering of grouped assists 2020-03-25 15:45:52 +01:00
bors[bot]
785eb32f49
Merge #3717
3717: Always expand macros during analysis r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-25 12:53:48 +00:00
Aleksey Kladov
2ccfb49bab Always expand macros during analysis 2020-03-25 13:53:15 +01:00
Edwin Cheng
2adc9a8d5f Remove collect proc_macro definitions 2020-03-25 20:14:22 +08:00
Edwin Cheng
5bd3aa05d6 Fix trailling whitespace 2020-03-25 19:50:12 +08:00
Edwin Cheng
8afb445357 Rename to CustomDerive 2020-03-25 19:50:12 +08:00
Edwin Cheng
7667aa6033 Refactoring a bit 2020-03-25 19:50:12 +08:00
Edwin Cheng
519dc15cb1 Use dummy implementation 2020-03-25 19:50:12 +08:00
Edwin Cheng
34dc8d25c1 Add basic custom derive lowering 2020-03-25 19:50:12 +08:00
Aleksey Kladov
f7f0f33e05 Remove dead code 2020-03-25 10:09:50 +01:00
bors[bot]
8a73a8937d
Merge #3707
3707: Add ItemScope::visibility_of r=matklad a=edwin0cheng

~This PR implements `HasVisibility` for various constructs and change `Definition::search_scope` to use `Visibility` directly instead of depends on ad-hoc string parsing.~

This PR added `visibility_of`  in `ItemScope` and `Module` and use it directly directly instead of depends on ad-hoc string parsing.

And also add a FIXME to indicate that there is a bug which do not search child-submodules in other files recursively in `Definition::search_scope`.

I will submit another PR to fix that bug after this is merged.

cc @flodiebold 

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-03-25 08:09:26 +00:00
Matt Hooper
7b35da04bf Improvements based on code review feedback 2020-03-25 00:18:55 +01:00
Matt Hooper
9d298115a6 Fmt corrections 2020-03-24 23:22:41 +01:00
Matt Hooper
b70ce559b8 Added more unit tests 2020-03-24 23:22:41 +01:00
Matt Hooper
a197abbc7a Added new inlay hint kind and rules for method chaining 2020-03-24 23:18:42 +01:00
Edwin Cheng
d606521723 Use visibility_of in search 2020-03-25 04:45:55 +08:00
Edwin Cheng
bcfb3700ce Add ItemScope::visibility_of 2020-03-25 04:45:42 +08:00
bors[bot]
fae627174a
Merge #3664
3664: Introduce TokenConverter Trait r=matklad a=edwin0cheng

This PR add a `TokenConverter` Trait to share the conversion logic between raw `lexer` token and Syntax Node Token.

Related #2158.

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-03-24 16:41:56 +00:00
bors[bot]
9690f6bc43
Merge #3708
3708: Generalise syntax rewriting infrastructure to allow removal of nodes r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-24 16:15:08 +00:00
Aleksey Kladov
062f6e3bbe Generalise syntax rewriting infrastructure to allow removal of nodes 2020-03-24 17:14:33 +01:00
bors[bot]
7c2cc85806
Merge #3705
3705: Align naming r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-24 11:56:43 +00:00
Aleksey Kladov
9bf2cd609c Align naming 2020-03-24 12:56:07 +01:00
bors[bot]
6ef64622af
Merge #3700
3700: fill match arms with empty block rather than unit tuple r=matklad a=JoshMcguigan

As requested by @Veetaha in #3689 and #3687, this modifies the fill match arms assist to create match arms as an empty block `{}` rather than a unit tuple `()`.

In one test I left one of the pre-existing match arms as a unit tuple, and added a body to another match arm, to demonstrate that the contents of existing match arms persist. 

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
2020-03-24 11:48:32 +00:00
bors[bot]
8617fe641d
Merge #3694
3694: Complete only missing fields r=matklad a=SomeoneToIgnore



Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-03-24 09:49:25 +00:00
Kirill Bulatov
f1cf1cc1ca Code review fixes
Co-Authored-By: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-24 11:33:47 +02:00
bors[bot]
c6db6e2352
Merge #3696 #3698 #3703
3696: vscode: more type safety r=matklad a=Veetaha



3698: Consider references when applying postfix completions r=matklad a=SomeoneToIgnore

Sometimes my RA debugging workflow breaks because `.dbg` is applied to the variable that is used later in the code.
It's safer to consider the refences to avoid this for completions that may trigger the move.

3703: Don't try to enable proposed API's on stable r=matklad a=matklad



bors r+
🤖

Co-authored-by: veetaha <veetaha2@gmail.com>
Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-24 08:54:30 +00:00
Kirill Bulatov
dd3b64124b Add a test 2020-03-24 10:43:24 +02:00
Kirill Bulatov
944f28fe5b Use more generic public api 2020-03-24 10:43:22 +02:00
Kirill Bulatov
d5e11b33a3 Remove the upcast 2020-03-24 10:43:00 +02:00
Kirill Bulatov
d221ff4f9e Auto import macros 2020-03-24 10:43:00 +02:00
Josh Mcguigan
7ba934fe58 fill match arms with empty block rather than unit tuple 2020-03-23 19:23:30 -07:00
Kirill Bulatov
4e43df26b2 Consider references when applying postfix completions 2020-03-24 01:56:06 +02:00
Josh Mcguigan
df58ab8963 update itertools version to 0.9.0 2020-03-23 16:22:46 -07:00
Kirill Bulatov
00cbe81a5b Complete only missing fields 2020-03-24 00:36:06 +02:00
Aleksey Kladov
3bd119a4c1 Add a test 2020-03-23 20:57:42 +01:00
bors[bot]
eff1b3fe4d
Merge #3689
3689: implement fill match arm assist for tuple of enums r=matklad a=JoshMcguigan

This updates the fill match arm assist to work in cases where the user is matching on a tuple of enums. 

Note, for now this does not apply when some match arms exist (other than the trivial `_`), but I think this could be added in the future.

I think this also lays the groundwork for filling match arms when matching on tuples of non-enum values, for example a tuple of an enum and a boolean.

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
2020-03-23 16:41:46 +00:00
Aleksey Kladov
f8fd242199
Merge pull request #3686 from Veetaha/feature/hover-actual-type-params
ra_hir: add more privacy for Type
2020-03-23 14:06:54 +01:00
Aleksey Kladov
a2f7ca27c0
Merge pull request #3678 from edwin0cheng/refactor-rename
Fix rename argument in macro call
2020-03-23 14:06:40 +01:00
Josh Mcguigan
bc48c9d511 review comments 2020-03-23 05:19:09 -07:00
bors[bot]
851a03492e
Merge #3690
3690: ra_hir: add more docs r=matklad a=Veetaha

Cited from [hear](https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/hover/near/191446937)

Co-authored-by: veetaha <veetaha2@gmail.com>
2020-03-23 12:06:11 +00:00
veetaha
e6691844db ra_hir: fix typo 2020-03-23 14:04:50 +02:00
veetaha
0fc21bd303 ra_hir: add more docs 2020-03-23 14:00:51 +02:00
bors[bot]
a27f5e3e05
Merge #3632
3632: ra_cargo_watch: log errors r=matklad a=Veetaha

Until this moment we totally ignored all the errors from cargo process. Though this is still true, but we
now try to log ones that are critical (i.e. misconfiguration errors and ignore compile errors).

This fixes #3631, and gives us a better error message to more gracefully handle the #3265
![image](https://user-images.githubusercontent.com/36276403/76958683-d7e1f080-6920-11ea-83d8-04561c11ccc4.png)

Though I think that outputting this only to `Output` channel is not enough. We should somehow warn the user that he passed wrong arguments to `cargo-watch.args`. I didn't bother looking for how to do this now, but this PR at least gives us something.

*cc* @kiljacken @matklad 

Co-authored-by: veetaha <veetaha2@gmail.com>
Co-authored-by: Veetaha <veetaha2@gmail.com>
2020-03-23 11:55:26 +00:00
bors[bot]
c7a2052e73
Merge #3681
3681: Only include machine-applicable suggestions r=kiljacken a=lnicola

Fixes #3676
Fixes #3633
Fixes #3391 

r? @kiljacken

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-03-23 11:41:32 +00:00
Josh Mcguigan
2afccbe477 implement fill match arm assist for tuple of enums 2020-03-22 23:28:25 -07:00
veetaha
559aeb2932 ra_hir: add more privacy for Type 2020-03-23 02:01:07 +02:00
bors[bot]
baa11d52f4
Merge #3684
3684: ra_hir_def: fix typo r=edwin0cheng a=Veetaha



Co-authored-by: veetaha <veetaha2@gmail.com>
2020-03-22 19:59:05 +00:00
veetaha
dc1fbef985 ra_hir_def: fix typo 2020-03-22 19:38:55 +02:00
bors[bot]
9328aba706
Merge #3677
3677: Add support for macro in symbol_index r=kjeremy a=edwin0cheng

This PR allows macro showing up in `Open symbol` search:

![show_macro](https://user-images.githubusercontent.com/11014119/77244297-548d0b80-6c4e-11ea-8613-15926cc297b3.png)


Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-03-22 14:50:42 +00:00
Laurențiu Nicola
96da53fc56 Only include machine-applicable suggestions 2020-03-22 16:45:15 +02:00
bors[bot]
655b4f16f0
Merge #3679
3679: Some miniscule refactorings r=matklad a=Veetaha



Co-authored-by: veetaha <veetaha2@gmail.com>
2020-03-22 14:17:06 +00:00
Edwin Cheng
af8c37cb57
Fix typo
Co-Authored-By: Veetaha <veetaha2@gmail.com>
2020-03-22 22:01:48 +08:00
veetaha
bfb6e3fd83 ra_hir: migrate some stuff to matches!() 2020-03-22 15:45:32 +02:00
veetaha
a8e5da8a70 ra_hir_ty: fix formatting 2020-03-22 15:44:38 +02:00
Edwin Cheng
6d5443ef94 Add test 2020-03-22 19:53:34 +08:00
Edwin Cheng
cba4dd1a8a Improve find_all_ref work inside macro 2020-03-22 19:53:28 +08:00
Edwin Cheng
f647faac60 Refactor search 2020-03-22 19:52:45 +08:00
Edwin Cheng
532e178f8e Add find_node_at_offset_with_descend 2020-03-22 19:52:14 +08:00
veetaha
8be28a2d4f ra_cargo_watch: log exit code too 2020-03-22 12:01:49 +02:00
Edwin Cheng
bb22a4e386 Add support for macro in symbo_index 2020-03-22 15:00:44 +08:00
Veetaha
788b29d343
Smol self-nit 2020-03-22 01:27:03 +02:00
bors[bot]
6fe956420f
Merge #3673
3673: Add recursive limit for macro expansion when expanding expression r=flodiebold a=edwin0cheng

cc @flodiebold 

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-03-21 22:39:06 +00:00
veetaha
8414342640 fix: typo 2020-03-21 23:37:15 +02:00
veetaha
ce73c43848 ra_cargo_watch: return Result<> from run_cargo(), and don't read stderr for now
As stated by matklad, reading the stderr
should be done alngside with
stdout via select() (or I guess poll()),
there is no such implementation in stdlib,
since it is quite low level and platform-dependent and it
also requires quite a bit of unrelated code we don't use it for now.

As referenced by bjorn3, there is an implementation of the needed read2() function
in rustc compiletest. The better solution will be to extract this function
to a separate crate in future:
https://github.com/rust-analyzer/rust-analyzer/pull/3632#discussion_r395605298
2020-03-21 23:37:15 +02:00
veetaha
59ba386bee ra_cargo_watch: log more errors 2020-03-21 23:36:31 +02:00
Edwin Cheng
d62dd63256 Use target-name for crate-name 2020-03-22 01:09:38 +08:00
bors[bot]
50c6a315ab
Merge #3671
3671: Add identity expansion checking in ill-form expansion  r=flodiebold a=edwin0cheng

This PR try to add more checking code in error case in macro expansion. The bug in #3642 is introduced by  #3580 , which allow ill-form macro expansion in *all* kind of macro expansions. 

In general we should separate hypothetical macro expansion and the actual macro expansion call. However, currently the `Semantic`  workflow we are using only support single macro expansion type, we might want to review it and make it works in both ways. (Maybe add a field in `MacroCallLoc` for differentiation) 

Fix #3642

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-03-21 16:02:07 +00:00
Edwin Cheng
92cc6c9816 Add recursive limit in expression macro expansion 2020-03-21 23:58:47 +08:00
Edwin Cheng
9ff50d7e83 Move test to hir_ty 2020-03-21 23:41:07 +08:00
Edwin Cheng
6d6606895c Fix typo 2020-03-21 23:08:53 +08:00
Edwin Cheng
e1a9461806 Add identity expansion checking 2020-03-21 22:43:48 +08:00
Josh Mcguigan
c3702a6b71 disable invert if assist for if-let to fix #3281 2020-03-21 06:40:18 -07:00
Edwin Cheng
adc54632ae Add open delim when delim not match 2020-03-21 05:20:28 +08:00
Edwin Cheng
6bcaa1d7d1 Fix text range bug and reorder 2020-03-21 04:57:20 +08:00
Edwin Cheng
622c843a4c Add TokenConvertor trait 2020-03-21 03:08:56 +08:00
Edwin Cheng
27c516970b Add test for delim bug 2020-03-20 23:36:29 +08:00
bors[bot]
467a040509
Merge #3623
3623: 'Fill match arms' should work with existing match arms r=matklad a=slyngbaek

Addresses #3039

This essentially adds missing match arms. The algorithm for this
can get complicated rather quickly so bail in certain conditions
and rely on a PlaceholderPat.

The algorighm works as such:
- Iterate through the Enum Def Variants
- Attempt to see if the variant already exists as a match arm
- If yes, skip the enum variant. If no, include it.
- If it becomes complicated, rather than exhaustively deal with every
  branch, mark it as a "partial match" and simply include the
  placeholder.

  Conditions for "complication":
  - The match arm contains a match guard
  - Any kind of nested destrucuring

Order the resulting merged match branches as such:
1. Provided match arms
2. Missing enum variant branch arms
3. End with Placeholder if required

- Add extra tests

Co-authored-by: Steffen Lyngbaek <steffenlyngbaek@gmail.com>
2020-03-20 08:26:15 +00:00
bors[bot]
e0952899ae
Merge #3662
3662: Support arbitrary discriminants r=matklad a=matklad

Closes #3661



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-20 07:51:24 +00:00
Aleksey Kladov
89694ec8f6 Support arbitrary discriminants
Closes #3661
2020-03-20 08:50:34 +01:00
Steffen Lyngbaek
ec24c09006 Remove const
- Add test for @ matching
- Address comments
2020-03-19 14:17:34 -07:00
Steffen Lyngbaek
eb51abdc64 Fixes to more accurately give complete_scope completions
- Exclude const, static, functions form is_pat_binding_and_path
  (there might be more?)
- Add a check to filter out Record Fields
- Fix tests
2020-03-19 14:12:00 -07:00
Steffen Lyngbaek
6941a7faba - Exclude Local Scope for BindPats
- Exclude BindPats with @ or ref
- Remove outdated test and add one testing for ref
2020-03-19 14:12:00 -07:00
Steffen Lyngbaek
b6d6277362 Completition for type name? #3418
Iterate through TupleStructPat's until a MatchArm if
one exists. Store in a new is_pat_bind_and_path bool
and allow the `complete_scope` to find matches.

Added some tests to ensure it works in simple and nested cases.
2020-03-19 14:12:00 -07:00
Steffen Lyngbaek
b5ba9c3e3a Address nits and suggestions.
Simplify the logic a lot by removing the check for a placeholder pat.
This means the auto-fill no longer returns a compile-able value.
2020-03-19 11:49:01 -07:00
Steffen Lyngbaek
5f8f8a38a2 Don't show assist if all arms are present 2020-03-19 11:47:33 -07:00
Steffen Lyngbaek
6087c01460 'Fill match arms' should work with existing match arms
Addresses #3039

This essentially adds missing match arms. The algorithm for this
can get complicated rather quickly so bail in certain conditions
and rely on a PlaceholderPat.

The algorighm works as such:
- Iterate through the Enum Def Variants
- Attempt to see if the variant already exists as a match arm
- If yes, skip the enum variant. If no, include it.
- If it becomes complicated, rather than exhaustively deal with every
  branch, mark it as a "partial match" and simply include the
  placeholder.

  Conditions for "complication":
  - The match arm contains a match guard
  - Any kind of nested destrucuring

Order the resulting merged match branches as such:
1. Provided match arms
2. Missing enum variant branch arms
3. End with Placeholder if required

- Add extra tests
2020-03-19 11:47:33 -07:00
Aleksey Kladov
f840fcb2f5 Simplify Arena to use a generic index 2020-03-19 18:46:30 +01:00
Aleksey Kladov
fc230b943b Simplify Sysroot 2020-03-19 17:59:31 +01:00
Aleksey Kladov
516fe293a8 More direct CargoWorkspace 2020-03-19 17:53:31 +01:00
Aleksey Kladov
7e2bca4ec3 Cleanup imports 2020-03-19 12:36:33 +01:00
Aleksey Kladov
0c55c06944 Merge nested use trees 2020-03-19 12:18:59 +01:00
Aleksey Kladov
ef3bf906c4 Generalize 2020-03-19 11:38:26 +01:00
Aleksey Kladov
0bf903411c Use match_ast 2020-03-18 20:51:47 +01:00
Aleksey Kladov
3f6dc20d3c Merge imports assist
Work towards #2220
2020-03-18 19:34:47 +01:00
Aleksey Kladov
4e50efcfc5 Strongly-typed generic methods for editing nodes 2020-03-18 19:34:47 +01:00
Aleksey Kladov
3c88ef76d6 Reduce visibility 2020-03-18 16:48:45 +01:00
veetaha
4d83961acb ra_hir_def: remove dat fixme 2020-03-18 02:35:49 +02:00
Emil Lauridsen
2dd887de47 Use dyn-ref instead of impl to impact compile times the least 2020-03-17 14:56:53 +01:00
Emil Lauridsen
5af81b8456 Slight readablity improvement 2020-03-17 14:56:14 +01:00
Emil Lauridsen
e154132c91 Remove outDirOverrides 2020-03-17 14:55:44 +01:00
Emil Lauridsen
f84deffd72 Support loading OUT_DIR for CLI runs 2020-03-17 14:47:05 +01:00
Emil Lauridsen
4fb79f2ca0 Support specifying OUT_DIR in json project 2020-03-17 14:47:05 +01:00
Emil Lauridsen
f5a2fcf8f5 Change existing OUT_DIR override config to make use of new infrastructure 2020-03-17 14:47:05 +01:00
Emil Lauridsen
33c6c7abc6 Support loading OUT_DIR from cargo check at launch 2020-03-17 14:47:05 +01:00
Aleksey Kladov
de7662c852 Check that no file contains trailing ws
rustfmt allows trailing spaces in string literals unfortunately.
2020-03-17 11:42:54 +01:00
phynalle
cafacb74aa Fix typo 2020-03-17 19:15:30 +09:00
Florian Diebold
6c20d7e979 Small fixes 2020-03-16 18:46:08 +01:00
Florian Diebold
32dce75747 Some more refactoring 2020-03-16 18:38:19 +01:00
Florian Diebold
d6b622cdef Some cleanup 2020-03-16 18:38:19 +01:00
Florian Diebold
d655749aae Turn ExpandResult into struct 2020-03-16 18:38:19 +01:00
Florian Diebold
f3c6a2e3db Fix remaining test failure 2020-03-16 18:38:19 +01:00
Florian Diebold
0660dd10d2 Fix performance problem 2020-03-16 18:38:19 +01:00
Florian Diebold
e6ec4a329f Better fix for stuck parser? 2020-03-16 18:38:19 +01:00
Florian Diebold
035db0fbb9 Add test, remove printlns 2020-03-16 18:38:19 +01:00
Florian Diebold
c32529ddd0 Get tests working 2020-03-16 18:38:19 +01:00
Florian Diebold
0f3a54dd4d wip 2020-03-16 18:38:19 +01:00
Florian Diebold
6305d094ac Attempt to implement ranking of rules when none matches perfectly (wip) 2020-03-16 18:38:19 +01:00
Florian Diebold
b973158aeb Make MBE expansion more resilient (WIP) 2020-03-16 18:38:19 +01:00
Aleksey Kladov
9faea2364d Use dyn Trait for working with databse
It improves compile time in `--release` mode quite a bit, it doesn't
really slow things down and, conceptually, it seems closer to what we
want the physical architecture to look like (we don't want to
monomorphise EVERYTHING in a single leaf crate).
2020-03-16 17:42:30 +01:00
Veetaha
dd4ff92aa3
Remove dat fixme 2020-03-16 14:13:50 +02:00
bors[bot]
a007a123af
Merge #3573
3573: Check all crates of the workspace r=matklad a=matklad

Previously, if the root of the was was a real crate, only this crate
was checked.

Ideally, we might want some kind of config here (which might be just
overriding the whole command), but `--workspace` is def a nicer
default.

r? @kiljacken 

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-16 11:55:36 +00:00
bors[bot]
5bdc249b2c
Merge #3587
3587: Use WorkDoneProgress LSP API for initial load r=matklad a=slyngbaek

Addresses #3283

Rather than using custom UI for showing the loaded state. Rely
on the WorkDoneProgress API in 3.15.0
https://microsoft.github.io/language-server-protocol/specification#workDoneProgress.

No client-side work was necessary. The UI is not exactly what is
described in the issue but afaict that's how VS Code implements the LSP
API.

- The WorkDoneProgressEnd does not appear to display its message
  contents (controlled by vscode)

Co-authored-by: Steffen Lyngbaek <steffenlyngbaek@gmail.com>
2020-03-16 11:48:46 +00:00
bors[bot]
2eb1677b12
Merge #3603
3603: Fix crate display name dashes r=matklad a=SomeoneToIgnore

A follow-up of https://github.com/rust-analyzer/rust-analyzer/pull/3602#discussion_r392733525

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-03-16 10:33:13 +00:00
Kirill Bulatov
92fd430dab Use Display instead of a custom method 2020-03-16 12:03:43 +02:00
bors[bot]
a99cac671c
Merge #3540
3540: Swtches to rust SSR query check r=matklad a=mikhail-m1

related to #3186 

Co-authored-by: Mikhail Modin <mikhailm1@gmail.com>
2020-03-16 09:48:09 +00:00
Kirill Bulatov
059ed25a3e Fix crate display name dashes 2020-03-16 11:47:52 +02:00
bors[bot]
6616f336b2
Merge #3598
3598: ra_hir_expand: migrate to impl_intern_key!() r=matklad a=Veetaha



Co-authored-by: Veetaha <gerzoh1@gmail.com>
Co-authored-by: Veetaha <veetaha2@gmail.com>
2020-03-16 09:41:38 +00:00
bors[bot]
6bc226fa19
Merge #3602
3602: ra_ide: remove dead code, migrate from readonly String -> &str r=matklad a=Veetaha

https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/hover/near/190671355

Co-authored-by: veetaha <veetaha2@gmail.com>
2020-03-16 09:15:29 +00:00
Steffen Lyngbaek
b6dec2eb1f Fix tests part 2... 2020-03-15 23:32:28 -07:00
Steffen Lyngbaek
70ccda3941 Fix broken tests
- Handle case of no projects. The notification still needs to be posted
2020-03-15 21:44:27 -07:00
Steffen Lyngbaek
e3db4f3716 Rely on the safer workspace_loaded check 2020-03-15 20:48:39 -07:00
veetaha
98c34b725f ra_ide: refactor readonly String -> &str 2020-03-16 02:35:59 +02:00
veetaha
4fd07a02a2 ra_ide: remove dead code in HoverResult 2020-03-16 01:30:50 +02:00
Mikhail Modin
b150965ed7 Swtches to rust SSR query check 2020-03-15 21:23:18 +00:00
Veetaha
7eb5d89a85
ra_hir_expand: change the ordering of imports as per the formatter 2020-03-15 18:51:09 +02:00
Veetaha
cbd9f46bc7
ra_hir_expand: migrate to impl_intern_key!() 2020-03-15 18:25:55 +02:00
bors[bot]
efa72c899d
Merge #3591
3591: Support local macro_rules r=matklad a=edwin0cheng

This PR implement local `macro_rules` in function body, by adding following things:

1. While lowering, add a `MacroDefId` in body's `ItemScope` as a textual legacy macro. 
2. Make `Expander::enter_expand` search with given `ItemScope`.
3. Make `Resolver::resolve_path_as_macro` search with `LocalItemScope`.

Fix #2181

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-03-15 12:15:09 +00:00
Florian Diebold
0a9ea782eb Fix completion of trait items
Trait items should be public by default.
2020-03-14 20:48:36 +01:00
Edwin Cheng
fe78a14bbb Support local macro_rules 2020-03-14 14:25:51 +08:00
Steffen Lyngbaek
5a1e531176 Fix broken tests
- Properly wait for workspace loading to be done
2020-03-13 22:06:49 -07:00
Steffen Lyngbaek
f0b58fd1fa Use idiomatic way of defining floats 2020-03-13 16:27:39 -07:00
Steffen Lyngbaek
083035fd06 Use WorkDoneProgress LSP API for initial load
Addresses #3283

Rather than using custom UI for showing the loaded state. Rely
on the WorkDoneProgress API in 3.15.0
https://microsoft.github.io/language-server-protocol/specification#workDoneProgress.

No client-side work was necessary. The UI is not exactly what is
described in the issue but afaict that's how VS Code implements the LSP
API.

- The WorkDoneProgressEnd does not appear to display its message
  contents (controlled by vscode)
2020-03-13 16:03:02 -07:00
Aleksey Kladov
6eb05c4a14 Simplify 2020-03-13 18:02:04 +01:00
Aleksey Kladov
a6638af4a6 Simplify tests 2020-03-13 18:00:23 +01:00
Aleksey Kladov
687bec117c Don't use generic DB where a concrete one will do 2020-03-13 17:58:49 +01:00
bors[bot]
4c85e53531
Merge #3561 #3577
3561: feat: add debug code lens r=matklad a=hdevalke

Refs #3539

3577: Protect against infinite macro expansion in def collector r=edwin0cheng a=flodiebold

Something I noticed while trying to make macro expansion more resilient against errors.

There was a test for this, but it wasn't actually working because the first recursive expansion failed. (The comma...)

Even with this limit, that test (when fixed) still takes some time to pass because of the exponential growth of the expansions, so I disabled it and added a different one without growth.

CC @edwin0cheng 

Co-authored-by: Hannes De Valkeneer <hannes@de-valkeneer.be>
Co-authored-by: hdevalke <2261239+hdevalke@users.noreply.github.com>
Co-authored-by: Florian Diebold <florian.diebold@freiheit.com>
2020-03-13 14:01:29 +00:00
Florian Diebold
89eb9e8002 Protect against infinite macro expansion in def collector
There was a test for this, but it wasn't actually working because the first
recursive expansion failed. (The comma...)

Even with this limit, that test (when fixed) still takes some time to pass
because of the exponential growth of the expansions, so I disabled it and added
a different one without growth.
2020-03-13 14:50:03 +01:00
Aleksey Kladov
bee5cdb359 Parse variadics correctly
closes #3571
2020-03-13 13:54:14 +01:00
Florian Diebold
d6195fa21f Fix completion of HashMap::new
The `ty` function in code_model returned the type with placeholders for type
parameters. That's nice for printing, but not good for completion, because
placeholders won't unify with anything else: So the type we got for `HashMap`
was `HashMap<K, V, T>`, which doesn't unify with `HashMap<?, ?, RandomState>`,
so the `new` method wasn't shown.

Now we instead return `HashMap<{unknown}, {unknown}, {unknown}>`, which does
unify with the impl type. Maybe we should just expose this properly as variables
though, i.e. we'd return something like `exists<type, type, type> HashMap<?0,
?1, ?2>` (in Chalk notation). It'll make the API more complicated, but harder to
misuse. (And it would handle cases like `type TypeAlias<T> = HashMap<T, T>` more
correctly.)
2020-03-13 13:04:32 +01:00
Aleksey Kladov
680182d0a0 Restore cargo-fmt gating 2020-03-13 12:54:32 +01:00
Aleksey Kladov
1e19847af3 Move verbose tests out of line 2020-03-13 12:20:42 +01:00
Aleksey Kladov
f2dd023150 Check all crates of the workspace
Previously, if the root of the was was a real crate, only this crate
was checked.

Ideally, we might want some kind of config here (which might be just
overriding the whole command), but `--workspace` is def a nicer
default.
2020-03-13 10:59:20 +01:00
bors[bot]
b0ed808266
Merge #3553
3553: Completions do not show for function with same name as mod r=matklad a=JoshMcguigan

fixes #3444 

I've added a test case in `crates/ra_ide/src/completion/complete_path.rs` which verifies the described behavior in #3444. Digging in, I found that [the module scope iterator](ba62d8bd1c/crates/ra_ide/src/completion/complete_path.rs (L22)) only provides the module `z`, and does not provide the function `z` (although if I name the function something else then it does show up here). 

I thought perhaps the name wasn't being properly resolved, but I added a test in `crates/ra_hir_def/src/nameres/tests.rs` which seems to suggest that it is? I've tried to figure out how to bridge the gap between these two tests (one passing, one failing) to see where the function `z` is being dropped, but to this point I haven't been able to track it down.

Any pointers on where I might look for this? 

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
2020-03-13 09:18:47 +00:00
bors[bot]
56590097ed
Merge #3572
3572: Add test for completion of unresolved items r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-13 08:36:38 +00:00
Aleksey Kladov
9297f4d991 Add test for completion of unresolved items 2020-03-13 09:30:21 +01:00
CAD97
88c944f96b Remove some TextUnit->usize escapees 2020-03-12 22:33:27 -04:00
Josh Mcguigan
7208498d54 fix issue 3444 2020-03-12 17:16:28 -07:00
Hannes De Valkeneer
39c92b3872 fixup! feat: add debug code lens
autodetect vscode-lldb
2020-03-12 22:31:47 +01:00
Aleksey Kladov
a6bb4cd0ec Fix completion tests 2020-03-12 22:03:30 +01:00
Hannes De Valkeneer
e9d025b618 fixup! feat: add debug code lens
avoid repetition of `--no-run`
2020-03-12 21:28:26 +01:00
hdevalke
60b154ff92
Update crates/rust-analyzer/src/main_loop/handlers.rs
use `Vec::new` instead of `Vec::with_capacity(0)`

Co-Authored-By: Veetaha <veetaha2@gmail.com>
2020-03-12 20:56:34 +01:00
Aleksey Kladov
b3fa7312a7 Simpler deserialization 2020-03-12 18:01:36 +01:00
Aleksey Kladov
fd3ece2b73 Make naming more uniform 2020-03-12 17:38:48 +01:00
bors[bot]
d98a5fab46
Merge #3543
3543: Parameter inlay hint separate from variable type inlay? #2876 r=matklad a=slyngbaek

Add setting to allow enabling either type inlay hints or parameter
inlay hints or both. Group the the max inlay hint length option
into the object.

- Add a new type for the inlayHint options.
- Add tests to ensure the inlays don't happen on the server side

Co-authored-by: Steffen Lyngbaek <steffenlyngbaek@gmail.com>
2020-03-12 16:02:55 +00:00
bors[bot]
944bd2cbc3
Merge #3559
3559: Implement builtin assert! macro r=matklad a=edwin0cheng

This PR add a dummy implementation for `assert!` macro, which mainly make `hover` and `goto-def` works on arguments inside it.

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-03-12 15:38:04 +00:00
bors[bot]
7bbdca6182
Merge #3564
3564: Better handling of a few kinds of cargo/clippy diagnostics r=matklad a=kiljacken

This was initially supposed to just be a fix for #3433, but I caught a few things that ended up being useful as well.

This PR primarily makes us handle multi-edit fix suggestions properly. Instead of just applying the first fix we apply all the parts of the fix in a single action.

Second up, this PR handles diagnostics with multiple primary spans, f.x. the unused import diagnostic from rustc:
![image](https://user-images.githubusercontent.com/209321/76531793-03269480-6476-11ea-9180-41c0ea705553.png)

The LSP doesn't handle this too well, as it only support a single complete range for each diagnostic, so we get duplicate messages in the problem panel of VSCode:
![image](https://user-images.githubusercontent.com/209321/76531901-29e4cb00-6476-11ea-9746-cd57f8974b85.png)

However, I feel like the improved visual aspect in-editor outweighs the duplication in the problem panel. I'm open to not including the second commit if anybody really doesn't like the idea of duplicate diagnostics in the problem pane.

Fixes #3433
Fixes #3257

Co-authored-by: Emil Lauridsen <mine809@gmail.com>
2020-03-12 14:46:42 +00:00
Aleksey Kladov
afd64ef4f7
Merge pull request #3562 from FireofGods/display_for_node
Add `std::fmt::Display` as a supertrait for `AstNode`
2020-03-12 15:40:53 +01:00
Emil Lauridsen
98e8ad5e60 Handle diagnostics with multiple primary spans 2020-03-12 15:24:20 +01:00
Emil Lauridsen
637c795b3c Correctly handle multi-line fixes from cargo/clippy 2020-03-12 15:01:53 +01:00
Steffen Lyngbaek
58248e24cd Switch from Vec<InlayKind> to object with props
- Instead of a single object type, use several individual nested types
  to allow toggling from the settings GUI
- Remove unused struct definitions
- Install and test that the toggles work
2020-03-11 20:14:39 -07:00
Hannes De Valkeneer
e903fd0d97 feat: add debug code lens
Refs #3539
2020-03-11 22:26:47 +01:00
Fireassember
31eec5e80c implementing Display for enums too. 2020-03-11 22:54:24 +02:00
Edwin Cheng
8f7703b006 Update comment
Co-Authored-By: bjorn3 <bjorn3@users.noreply.github.com>
2020-03-12 02:00:56 +08:00
Edwin Cheng
8c159b54e9 Add test on hover 2020-03-11 23:14:15 +08:00
Edwin Cheng
759bcea96d Implement dummy assert macro 2020-03-11 23:08:12 +08:00
Aleksey Kladov
4a745cc8cf Fix parsing of stement-ish binary expressions
closes #3512
2020-03-11 14:28:18 +01:00
Aleksey Kladov
85c30b1915 Continue multiline non-doc comment blocks 2020-03-11 12:58:16 +01:00
Aleksey Kladov
90fe534f03 Split on enter tests 2020-03-11 12:58:16 +01:00
Aleksey Kladov
52da9e90a6 Move on enter to a separate module 2020-03-11 12:58:16 +01:00
bors[bot]
c48dcf7411
Merge #3549
3549: Implement env! macro r=matklad a=edwin0cheng

This PR implements `env!` macro by adding following things:

1. Added `additional_outdirs` settings in vscode. (naming to be bikeshed)
2. Added `ExternSourceId` which is a wrapping for SourceRootId but only used in extern sources. It is because `OUT_DIR` is not belonged to any crate and we have to access it behind an `AstDatabase`.
3. This PR does not implement the `OUT_DIR` parsing from `cargo check`. I don't have general design about this,  @kiljacken could we reuse some cargo watch code for that ?

~~Block on [#3536]~~

PS: After this PR , we (kind of) completed the `include!(concat!(env!('OUT_DIR'),  "foo.rs")` macro call combo. [Exodia Obliterate!](https://www.youtube.com/watch?v=RfqNH3FoGi0)

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-03-11 10:51:07 +00:00
bors[bot]
7b323b45a1
Merge #3555
3555: Introduce completion test utils r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-11 10:10:49 +00:00
Aleksey Kladov
dad8f1e064 Introduce completion test utils 2020-03-11 11:09:57 +01:00
Aleksey Kladov
9b0b59c5d2 Add a test for disabled argument snippets 2020-03-11 10:39:39 +01:00
bors[bot]
bf77850c81
Merge #3542
3542: Renames work on struct field shorthands r=matklad a=m-n

When renaming either a local or a struct field, struct field shorthands are now renamed correctly.

Happy to refactor this if it doesn't fit the design of the code. Thanks for adding the suggestion of where to start on the issue.

I wasn't sure if I should also look at the behavior of renaming when placing the cursor at the field shorthand; the following describes the behavior with this patch:

```rust
#[test]
fn test_rename_field_shorthand_for_unspecified() {
    // when renaming a shorthand, should we have a way to specify
    // between renaming the field and the local?
    //
    // If not is this the correct default?
    test_rename(
        r#"
struct Foo {
    i: i32,
}
 impl Foo {
    fn new(i: i32) -> Self {
        Self { i<|> }
    }
}
"#,
        "j",
        r#"
struct Foo {
    i: i32,
}
 impl Foo {
    fn new(j: i32) -> Self {
        Self { i: j }
    }
}
"#,
    );
}
```
Resolves #3431

Co-authored-by: Matt Niemeir <matt.niemeir@gmail.com>
2020-03-11 09:22:09 +00:00
Matt Niemeir
13ccbb2919 find_usages limited to actual usages again 2020-03-10 22:27:38 -05:00
Edwin Cheng
6ea7c31915 Add extern source 2020-03-11 11:04:02 +08:00
Steffen Lyngbaek
974ed7155a Deduplicate some Inlay definitions
- Remove match conversion for InlayKind since we're using remote
2020-03-10 18:59:49 -07:00
Steffen Lyngbaek
cfb48df149 Address Issues from Github
- Updated naming of config
- Define struct in ra_ide and use remote derive in rust-analyzer/config
- Make inlayConfig type more flexible to support more future types
- Remove constructor only used in tests
2020-03-10 14:36:01 -07:00
Steffen Lyngbaek
e98aff109a Parameter inlay hint separate from variable type inlay? #2876
Add setting to allow enabling either type inlay hints or parameter
inlay hints or both. Group the the max inlay hint length option
into the object.

- Add a new type for the inlayHint options.
- Add tests to ensure the inlays don't happen on the server side
2020-03-10 14:33:45 -07:00
Florian Diebold
adc7b8ea2d Fix completion with a partially unknown type
To test whether the receiver type matches for the impl, we unify the given self
type (in this case `HashSet<{unknown}>`) with the self type of the
impl (`HashSet<?0>`), but if the given self type contains Unknowns, they won't
be unified with the variables in those places. So we got a receiver type that
was different from the expected one, and concluded the impl doesn't match.

The fix is slightly hacky; if after the unification, our variables are still
there, we make them fall back to Unknown. This does make some sense though,
since we don't want to 'leak' the variables.

Fixes #3547.
2020-03-10 21:02:13 +01:00
Aleksey Kladov
14094e4477 Move FeatureFlags 2020-03-10 18:56:15 +01:00
Aleksey Kladov
bf582e77d6 Pull completion options up to the rust-analyzer 2020-03-10 18:47:09 +01:00
Aleksey Kladov
2347c03dcd Introduce CompletionOptions 2020-03-10 18:40:22 +01:00
Edwin Cheng
5a292309c5 Add and fix tests 2020-03-11 01:06:01 +08:00
Edwin Cheng
e00a1e0b79 Setup Env in world 2020-03-11 01:06:01 +08:00
Edwin Cheng
22f064cca7 Add resolve_extern_path in DB 2020-03-11 01:06:01 +08:00
Edwin Cheng
8153a0b3ef Add ExternSourceId and env functions 2020-03-11 01:06:01 +08:00
Edwin Cheng
c1db5d26a0 Add additional_outdirs in config 2020-03-11 01:06:01 +08:00
bors[bot]
6b9d66bbee
Merge #3536
3536: Add get and set for `Env` r=matklad a=edwin0cheng

This PR add three things :

1. Add `get` and `set` in `Env`.
2. Implement fixture meta for `with_single_file`. 
3. Add `env` meta in fixture.

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-03-10 16:46:21 +00:00
Aleksey Kladov
34bc0f4f55
Merge pull request #3506 from slyngbaek/3183
Next steps in assoc item completion #3183
2020-03-10 17:45:57 +01:00
Edwin Cheng
95ba7da1ab Check only one fixture 2020-03-11 00:45:03 +08:00
Edwin Cheng
773f3afd36 Add fixture meta for single file fixture 2020-03-11 00:45:03 +08:00
Aleksey Kladov
59a3ec5f33 ⬆️ fst 2020-03-10 15:03:32 +01:00
Matt Niemeir
ce8121bd65 Renaming a local renames struct field shorthand 2020-03-09 22:14:17 -05:00
Matt Niemeir
a9b6aec8a7 Struct field rename renames field in constructor field shorthand 2020-03-09 22:14:17 -05:00
Steffen Lyngbaek
f67e6a850e Switch to explicit offsets for impl_def
Blacklists are prone to more errors
2020-03-09 13:02:09 -07:00
bors[bot]
530ff9f57f
Merge #3533
3533: Updates insta to 0.15.0 and bumps console to 0.10.0 r=matklad a=kjeremy



Co-authored-by: kjeremy <kjeremy@gmail.com>
2020-03-09 14:38:20 +00:00
kjeremy
d1e9f0af04 Updates insta to 0.15.0 and bumps console to 0.10.0 2020-03-09 10:28:30 -04:00
kjeremy
c981c8b0d0 Fix SelectionRange return type 2020-03-09 10:17:16 -04:00
Aleksey Kladov
34b0409298 Print crate name in profil 2020-03-09 11:55:43 +01:00
bors[bot]
a6133206d1
Merge #3527
3527: Simplify r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-09 10:19:26 +00:00
Aleksey Kladov
100cbc57ce Simplify 2020-03-09 11:19:03 +01:00
Aleksey Kladov
d0d5aa935b Simplify 2020-03-09 11:17:39 +01:00
Aleksey Kladov
254ef1860b Minimize API 2020-03-09 11:16:06 +01:00
Aleksey Kladov
0320ebdd10 Use Index for CrateGraph 2020-03-09 11:11:59 +01:00
bors[bot]
0dbd8ff59b
Merge #3526
3526: Silence "file out of workspace" errors r=matklad a=matklad

We really should fix this limitation of the VFS, but it's some way off
at the moment, so let's just silence the user-visible error for now.

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-09 09:59:02 +00:00
Aleksey Kladov
43bc03faf0 Silence "file out of workspace" errors
We really should fix this limitation of the VFS, but it's some way off
at the moment, so let's just silence the user-visible error for now.
2020-03-09 10:54:14 +01:00
bors[bot]
57c27f9139
Merge #3519
3519: Show mod path on hover r=matklad a=SomeoneToIgnore

Closes #1064

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-03-09 09:33:46 +00:00
Kirill Bulatov
e1aa96f2c5 Less abstract CrateData api 2020-03-09 11:26:46 +02:00
bors[bot]
beb4f49541
Merge #3513
3513: Completion in macros r=matklad a=flodiebold

I experimented a bit with completion in macros. It's kind of working, but there are a lot of rough edges.

 - I'm trying to expand the macro call with the inserted fake token. This requires some hacky additions on the HIR level to be able to do "hypothetical" expansions. There should probably be a nicer API for this, if we want to do it this way. I'm not sure whether it's worth it, because we still can't do a lot if the original macro call didn't expand in nearly the same way. E.g. if we have something like `println!("", x<|>)` the expansions will look the same and everything is fine; but in that case we could maybe have achieved the same result in a simpler way. If we have something like `m!(<|>)` where `m!()` doesn't even expand or expands to something very different, we don't really know what to do anyway.
 - Relatedly, there are a lot of cases where this doesn't work because either the original call or the hypothetical call doesn't expand. E.g. if we have `m!(x.<|>)` the original token tree doesn't parse as an expression; if we have `m!(match x { <|> })` the hypothetical token tree doesn't parse. It would be nice if we could have better error recovery in these cases.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2020-03-09 08:56:58 +00:00
bors[bot]
30062da628
Merge #3516
3516: Handle visibility in more cases in completion r=matklad a=flodiebold

This means we don't show private items when completing paths or method calls.

We might want to show private items if we can edit their definition and provide a "make public" assist, but I feel like we'd need better sorting of completion items for that, so they can be not shown or sorted to the bottom by default. Until then, they're usually more of a distraction to me.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2020-03-09 08:50:19 +00:00
bors[bot]
0363c9495a
Merge #3518
3518: Add parse_to_token_tree r=matklad a=edwin0cheng

This PR introduce a function for parsing `&str` to `tt::TokenTree`:

```rust
// Convert a string to a `TokenTree`
pub fn parse_to_token_tree(text: &str) -> Option<(tt::Subtree, TokenMap)> {
````

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-03-09 08:43:07 +00:00
bors[bot]
7ac99aad28
Merge #3524
3524: Ignore client-specific notifications r=matklad a=matklad

closes #3523



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-09 08:27:31 +00:00
Aleksey Kladov
8aeab8d7b0 Ignore client-specific notifications
closes #3523
2020-03-09 09:26:41 +01:00
Steffen Lyngbaek
9138d39947 Clean up completion matching.
- Add test to ensure nested completions don't happen
2020-03-08 17:50:41 -07:00