Commit Graph

5682 Commits

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