Commit graph

18479 commits

Author SHA1 Message Date
vsrs
6031dee145 Enable assist only if an item is selected 2021-08-02 19:58:41 +03:00
vsrs
e71b239d37 fix generated tests 2021-08-02 19:49:36 +03:00
vsrs
0088f84c88 Allow several samples in "// Assist:" comments. 2021-08-02 19:49:36 +03:00
vsrs
580e5e277a Some comment tests 2021-08-02 19:49:36 +03:00
vsrs
4fa66f1e1e Sort struct enum variant fields 2021-08-02 19:49:36 +03:00
vsrs
6f8888cfe7 Sort enums 2021-08-02 19:49:36 +03:00
vsrs
2c7e99b209 Sort unions 2021-08-02 19:49:36 +03:00
vsrs
b31bf74c13 cargo fmt 2021-08-02 19:49:36 +03:00
vsrs
0694f18636 Sort struct fields 2021-08-02 19:49:36 +03:00
vsrs
643f3931f7 Sort trait and impl methods 2021-08-02 19:49:36 +03:00
bors[bot]
29506b5a26
Merge #9762
9762: fix: Fix ranged hover result range r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-08-02 16:17:15 +00:00
Lukas Wirth
8e0a7d8c08 Fix ranged hover result range 2021-08-02 18:16:47 +02:00
bors[bot]
cae54d86d8
Merge #9761
9761: feat: Show coerced types on type hover r=Veykril a=Veykril

This applies to both the ranged hover request as well as the normal hover type fallback.
![image](https://user-images.githubusercontent.com/3757771/127883884-2935b624-a3e5-4f35-861a-7d6d3266d187.png)
![image](https://user-images.githubusercontent.com/3757771/127883951-4ff96b6b-7576-4886-887b-1198c1121841.png)

We unfortunately have to leave out syntax highlighting here as otherwise the `Type` and `Coerced` words in the hover will get colored.

Note that this does not show all the coercions yet(and almost no pattern coercions) as not all coercion adjustments are implemented yet.

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-08-02 15:44:43 +00:00
Lukas Wirth
f2d2ce03c7 Also search for pattern nodes in ranged hover 2021-08-02 17:38:16 +02:00
Lukas Wirth
486603d559 Show coerced types on type hover 2021-08-02 17:10:36 +02:00
bors[bot]
138849a479
Merge #9751
9751: Make `LoadCargoConfig`, `fn load_workspace_at` & `fn load_workspace` public again r=matklad a=regexident

This [commit](b24f816c0d) which restricted the visibility of `LoadCargoConfig`, `fn load_workspace_at` & `fn load_workspace` unfortunately effectively rendered every crate/tool that uses rust-analyzer as a library dead in the water.

On of such tools is [cargo-modules](https://github.com/regexident/cargo-modules), a tool for generating tree/graph visualizations of one's Rust project and is powered by rust-analyzer as a library.

For more context see the PRs that introduced those types/functions and made them `pub`:

- https://github.com/rust-analyzer/rust-analyzer/pull/7595
- https://github.com/rust-analyzer/rust-analyzer/pull/7690

If kept as is rust-analyzer would effectively no longer be usable as a library.

cc `@SomeoneToIgnore` 

Co-authored-by: Vincent Esche <regexident@gmail.com>
2021-08-02 14:12:37 +00:00
bors[bot]
49e9e2124f
Merge #9759
9759: internal: Simplify inline_local_variable assist r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-08-02 13:28:21 +00:00
Lukas Wirth
432bb222c3 Simplify inline_local_variable assist 2021-08-02 15:27:47 +02:00
bors[bot]
314e2e75c0
Merge #9752
9752: feature: Declare proc-macro dependent crates in `rust-project.json` r=matklad a=tobywf

This adds the `is_proc_macro` flag in `rust-project.json`. By default, this is `false` and not required, so existing projects won't break/have the same behavior as before this change. If the flag is true, a dependency to the `proc_macro` sysroot crate is added (if it exists), so that rust-analyzer can resolve those imports.

This fixes #9726 .

I've also added some tests in the second commit. The first is a smoke test for a basic, minimal `rust-project.json` file. The second is a more targeted test for the flag. Both tests depend on the fake sysroot (a bunch of directories in the correct layout with empty `lib.rs` files), and also on `env!("CARGO_MANIFEST_DIR")` being an absolute path. I'm not sure if the later assumption is valid on all platforms. I wanted to at least try and add tests, but I'm happy to rework them or remove them if you don't think that's the way to go.

(You can license/relicense my contribution in any way you wish without contacting me.)

Co-authored-by: Toby Fleming <sourcecode@tobywf.com>
2021-08-02 13:14:22 +00:00
bors[bot]
0d56ff2a02
Merge #9758
9758: internal: explain that we don't `ref` in style.md r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-02 13:00:07 +00:00
Aleksey Kladov
12d7f5b56e internal: explain that we don't ref in style.md 2021-08-02 15:59:28 +03:00
bors[bot]
d6f2352a08
Merge #9757
9757: intenral: completion cleanups r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-02 12:41:15 +00:00
bors[bot]
e7be544b7c
Merge #9756
9756: internal: `resolve_doc_path` is able to resolve to macros r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-08-02 12:34:59 +00:00
Lukas Wirth
62ab73767f resolve_doc_path is able to resolve to macros 2021-08-02 14:33:09 +02:00
Aleksey Kladov
5f3662e01c minor: encode usage convention into API 2021-08-02 15:28:39 +03:00
Aleksey Kladov
8b6ea1545f simplify 2021-08-02 14:27:11 +03:00
Aleksey Kladov
71cd67fe47 failing test 2021-08-02 14:27:11 +03:00
Toby Fleming
d0b98060d4
Rust project project model smoke tests 2021-08-01 15:00:34 -07:00
Toby Fleming
cb13e4a2ca
Rust project supports proc-macro dependent crates 2021-08-01 14:43:10 -07:00
Vincent Esche
fee3507b71 Make LoadCargoConfig, fn load_workspace_at & fn load_workspace public again 2021-08-01 19:12:04 +02:00
bors[bot]
df0936b4af
Merge #9750
9750: Link “DST” to its definition r=lnicola a=gthb

Being new to Rust I wasn't familiar with this acronym and found it hard to guess (the context of syntax trees biased me to reading it as a D-something Syntax Tree and trying to guess what the D was), hard to google (in retrospect googling "rust dst" does the job, but I thought it was an abstract structure thing, not Rust-specific), and hard to Github-search, because `dst` is commonly short for “destination” in code.

Alternatively `<abbr title="dynamically sized type">DST</abbr>` would be about as helpful.

Co-authored-by: Gunnlaugur Thor Briem <gunnlaugur@gmail.com>
2021-08-01 14:40:44 +00:00
Gunnlaugur Thor Briem
4930e5d74d
Link “DST” to its definition
Being new to Rust I wasn't familiar with this acronym and found it hard to guess (the context of syntax trees biased me to reading it as a D-something Syntax Tree and trying to guess what the D was), hard to google (in retrospect googling "rust dst" does the job, but I thought it was an abstract structure thing, not Rust-specific), and hard to Github-search, because `dst` is commonly short for “destination” in code.

Alternatively `<abbr title="dynamically sized type">DST</abbr>` would be about as helpful.
2021-08-01 14:37:16 +00:00
bors[bot]
a793a0098d
Merge #9749
9749: Exclude `rust-analyzer.server.path` from VS Code's sync feature r=lnicola a=brainplot

By changing the scope of this configuration to `machine-overridible`, this setting becomes fully local for the VS Code instance the user is running.

Having this setting excluded from syncing should help avoid inconveniences for users who have VS Code installed on two different operating systems, where the paths to the language server binary would very likely mismatch.

Co-authored-by: Gianluca Recchia <gianluca.recchia@protonmail.com>
2021-08-01 10:11:07 +00:00
Gianluca Recchia
93433364ab
Exclude rust-analyzer.server.path from VS Code's sync feature
By changing the scope of this configuration to `machine-overridible`,
this setting becomes fully local for the VS Code instance the user is
running.

Having this setting excluded from syncing should help avoid
inconveniences for users who have VS Code installed on two different
operating systems, where the paths to the language server binary would
very likely mismatch.
2021-08-01 12:00:41 +02:00
bors[bot]
4118733f33
Merge #9747
9747: fix: Wrap inner tail expressions in MissingOkOrSomeInTailExpr r=Veykril a=Veykril

Fixes #8512

Also fixes a bug in for_each_tail_expr not visiting `else if` chains

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-31 18:27:41 +00:00
Lukas Wirth
1edbaa29f9 Wrap inner tail expressions in MissingOkOrSomeInTailExpr 2021-07-31 20:00:09 +02:00
bors[bot]
eb513c22f7
Merge #9746
9746: internal: add API to check what are the max limits in practice r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-07-31 15:27:11 +00:00
Aleksey Kladov
f952dc61d1 internal: add API to check what are the max limits in practice 2021-07-31 18:26:43 +03:00
bors[bot]
93873b0ce1
Merge #9739
9739: generate function assist favors deref cmpt types r=matklad a=mahdi-frms

Fixes #9713

Although that's still not relying on sematic info.

Co-authored-by: mahdi-frms <mahdif1380@outlook.com>
2021-07-31 15:08:29 +00:00
bors[bot]
a423b307e6
Merge #9744
9744: fix: Annotate type hints for pattern name ranges instead of the pattern itself r=Veykril a=Veykril

The current type hints do not go well with `bindings_after_at` which is likely to land with 1.56(https://github.com/rust-lang/rust/pull/85305 🎉very excited for this), hence annotate the names of ident patterns instead of the entire pattern.

This changes where the typehints go for ident patterns that use @ bindings, some example comparisons:

Before:
![Code_82ILMppkve](https://user-images.githubusercontent.com/3757771/127741276-e1dd173b-2964-4df0-abae-860283b2e1be.png)
After:
![Code_tPttN2rJpw](https://user-images.githubusercontent.com/3757771/127741277-e7fc2836-4f31-4c45-a3a9-69cbff3d52d9.png)

This change has no visible effect on patterns without ``@`` bindings.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-31 13:41:04 +00:00
Lukas Wirth
f7c7f89c3c Annotate type hints for pattern name ranges instead of the pattern itself 2021-07-31 15:30:45 +02:00
bors[bot]
6b733eac67
Merge #9743
9743: internal: a bit of completion profiling r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-07-31 13:23:00 +00:00
Aleksey Kladov
a5049e13bf internal: make non-zero times stand out in profile 2021-07-31 16:22:03 +03:00
Aleksey Kladov
08756012a5 internal: document query implication of completion rendering 2021-07-31 16:13:15 +03:00
Aleksey Kladov
d4e381f7b2 minor: follow code style 2021-07-31 16:05:07 +03:00
bors[bot]
3236845d67
Merge #9742
9742: fix: Fix hover range for derive inputs r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-31 13:00:09 +00:00
Lukas Wirth
b363755901 Fix hover range for derive inputs 2021-07-31 14:59:31 +02:00
bors[bot]
bcc3241c9e
Merge #9741
9741: minor: Replace useless types r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-31 12:30:09 +00:00
Lukas Wirth
7c7c4543da Replace useless types 2021-07-31 14:29:15 +02:00
bors[bot]
0cf28cedef
Merge #9740
9740: feat: `add_explicit_type` is applicable for closure parameters r=Veykril a=Veykril

Closes https://github.com/rust-analyzer/rust-analyzer/issues/8886
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-31 12:05:41 +00:00