Commit Graph

12451 Commits

Author SHA1 Message Date
Jade
b90ed92a5c Support exclusive_range_pattern
Fix #9779
2021-08-03 21:36:29 -07:00
Jade
e3a67ccec6 tree-wide: fix rustdoc warnings, add some links 2021-08-03 21:34:20 -07:00
bors[bot]
8a8431133e
Merge #9775
9775: internal: extract_assist is aware of the expression owner r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-08-03 18:48:43 +00:00
Lukas Wirth
29c4ae6f9a extract_assist is aware of the expression owner 2021-08-03 20:47:51 +02:00
bors[bot]
09ec0a15fa
Merge #9773
9773: internal: Improve `extract_function` assist r=Veykril a=Veykril

- fix: It doesn't try to overwrite parts of selected comments any longer
- fix: It doesn't wrap tail expressions and return types in a result or option unnecessarily
- feat?: It now adds a `const` modifier to the created function if extract somethings from a const context 

Fixes #7840

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-08-03 16:53:12 +00:00
Lukas Wirth
9edaf0cad8 extract_function is const aware 2021-08-03 18:43:28 +02:00
Lukas Wirth
e62ce6f61a Reorganize functions in extract_function assist 2021-08-03 18:24:33 +02:00
Lukas Wirth
027a99fc70 Do no tear comments apart in extract_function assist 2021-08-03 17:39:49 +02:00
bors[bot]
00c8cab20b
Merge #9765
9765: internal: Introduce TypeInfo r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-08-03 15:32:51 +00:00
Lukas Wirth
b96f1adf5c Give TypeInfo fields and methods more appropriate names 2021-08-03 17:28:51 +02:00
Lukas Wirth
8afa2722b2 Revise TypeInfo::ty usage 2021-08-03 17:24:43 +02:00
Lukas Wirth
25ff7171c4 Introduce TypeInfo 2021-08-03 16:41:53 +02:00
bors[bot]
4b0c97668c
Merge #9772
9772: feat: filter out duplicate macro completions r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-03 14:37:25 +00:00
Aleksey Kladov
2f9273633b feat: filter out duplicate macro completions
closes #9303
2021-08-03 17:36:06 +03:00
bors[bot]
ffbb43f336
Merge #9770
9770: Downgrade notify and use `RecommendedWatcher` r=lnicola a=lnicola

Closes #9769

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-08-03 12:04:13 +00:00
Laurențiu Nicola
5b0c86af7d Downgrade notify and use RecommendedWatcher 2021-08-03 14:33:37 +03:00
bors[bot]
da894358e1
Merge #9764
9764: fix: Don't use the module as the candidate node in fuzzy path flyimport r=Veykril a=Veykril

The problem was that the candidate node is whats being used for the scope, so using an inline module will yield the surrounding scope of the module instead of the scope of the module itself.
Also seems to fix the problem in this comment https://github.com/rust-analyzer/rust-analyzer/issues/9760#issuecomment-891125674, though I could not recreate that in a test for some reason.

Fixes #9760

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-08-02 18:43:02 +00:00
Lukas Wirth
e138676664 Don't use the module as the candidate node in fuzzy path flyimport 2021-08-02 19:56:32 +02: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
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
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
Lukas Wirth
b363755901 Fix hover range for derive inputs 2021-07-31 14:59:31 +02: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