Commit graph

11492 commits

Author SHA1 Message Date
bors[bot]
666fc1cec1
Merge #9015
9015: Merge pattern completion related bools into an enum r=Veykril a=Veykril

The two bools can never both be set so this is basically just a tri-state enum.
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-26 20:43:53 +00:00
Lukas Wirth
7d865ef071 Merge pattern completion related bools into an enum 2021-05-26 22:39:47 +02:00
bors[bot]
8389510f8d
Merge #9012
9012: feat: add tab stops for keyword completions r=matklad a=eduardocanellas

Add tab stops for all the keywords that I judged fit. I also introduced some line breaks and spaces, following the pattern I saw in the `postfix` module.

Co-authored-by: Eduardo Canellas <eduardocanellas98@gmail.com>
2021-05-26 20:29:52 +00:00
Lukas Wirth
26e784a575 simplify 2021-05-26 21:09:27 +02:00
Eduardo Canellas
052df3deb7 feat: add tab stops for keyword completions 2021-05-26 14:24:54 -03:00
bors[bot]
bb1c7fc0cf
Merge #9008
9008: fix: remove undesired completions from trait/impl blocks r=Veykril a=eduardocanellas

Related to #8518


Co-authored-by: Eduardo Canellas <eduardocanellas98@gmail.com>
2021-05-26 17:04:09 +00:00
Eduardo Canellas
ce36746035 fix: remove undesired completions from trait/impl blocks 2021-05-26 13:21:27 -03:00
bors[bot]
f3aaae6555
Merge #9007
9007: Internal: `clippy::redundant_clone` fixes r=lnicola a=lnicola

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-05-26 15:36:14 +00:00
Laurențiu Nicola
8206939fed clippy::redundant_clone fixes 2021-05-26 18:34:50 +03:00
bors[bot]
5a1fd05760
Merge #9003
9003: minor: Document semantic token modifiers r=Veykril a=Veykril

Part of #6457

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-26 12:08:56 +00:00
Lukas Wirth
887dd2d5bb Document semantic token modifiers 2021-05-26 13:37:54 +02:00
bors[bot]
5701c553cb
Merge #9002
9002: Move annotations below item attributes r=Veykril a=Veykril

This moves annotations/code lenses below attributes in items, bringing them inline with functions where this is already the case. This is done by changing the annotations covering range to just the name node's range which is also more inline with what the lsp expects which is that the range should ideally only cover a single line. 

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/9000
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-26 10:26:19 +00:00
Lukas Wirth
dfa47eaadb Move annotations below item attributes 2021-05-26 12:23:51 +02:00
bors[bot]
8483fb0f26
Merge #8996
8996: Fix bug where library functions were not highlighted as such r=arzg a=arzg

Sorry about forgetting to test this in my last PR.

Co-authored-by: Aramis Razzaghipour <aramisnoah@gmail.com>
2021-05-25 23:28:02 +00:00
Aramis Razzaghipour
8960a08951
Fix bug where library functions were not highlighted as such 2021-05-26 09:26:13 +10:00
bors[bot]
5587d0a3e3
Merge #8973
8973: internal: move diagnostics to hir r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-25 20:33:21 +00:00
bors[bot]
e23083f398
Merge #8993
8993: fix: don't show pd/ppd completions where it shouldn't be r=flodiebold a=eduardocanellas

Closes #8992


Co-authored-by: Eduardo Canellas <eduardocanellas98@gmail.com>
2021-05-25 19:58:49 +00:00
bors[bot]
3b10f9e714
Merge #8994
8994: Check for subdirs in vfs loader exclusions. r=matklad a=ammkrn

The current logic used to transfer global_excludes into vfs exclusions
only transfers global_excludes that are the parent of an item in
dirs.include.
This commit additionally adds an item from global_exclude to the vfs
exclusions if the global_exclude is a child of an included item.

Co-authored-by: ammkrn <ammkrn@tuta.io>
2021-05-25 16:40:57 +00:00
ammkrn
96ee19851b Check for subdirs in vfs loader exclusions.
The current logic used to transfer global_excludes into vfs exclusions
only transfers global_excludes that are the parent of an item in
dirs.include.
This commit additionally adds an item from global_exclude to the vfs
exclusions if the global_exclude is a child of an included item.
2021-05-25 11:35:39 -05:00
Eduardo Canellas
e31a762c63 fix: don't show pd/ppd completions where it shouldn't be 2021-05-25 11:53:11 -03:00
Aleksey Kladov
5c9f31d4c2 internal: move diagnostics to hir
The idea here is to eventually get rid of `dyn Diagnostic` and
`DiagnosticSink` infrastructure altogether, and just have a `enum
hir::Diagnostic` instead.

The problem with `dyn Diagnostic` is that it is defined in the lowest
level of the stack (hir_expand), but is used by the highest level (ide).

As a first step, we free hir_expand and hir_def from `dyn Diagnostic`
and kick the can up to `hir_ty`, as an intermediate state. The plan is
then to move DiagnosticSink similarly to the hir crate, and, as final
third step, remove its usage from the ide.

One currently unsolved problem is testing. You can notice that the test
which checks precise diagnostic ranges, unresolved_import_in_use_tree,
was moved to the ide layer. Logically, only IDE should have the infra to
render a specific range.

At the same time, the range is determined with the data produced in
hir_def and hir crates, so this layering is rather unfortunate. Working
on hir_def shouldn't require compiling `ide` for testing.
2021-05-25 17:49:59 +03:00
Lukas Wirth
28ca371755 Consider trait to be in scope for trait-impl 2021-05-25 16:16:29 +02:00
bors[bot]
35db5e99f6
Merge #8990
8990: feat: Also do goto implementation on assoc consts r=lnicola a=lf-

I forgot to put this into #8988, sorry.

Goto implementation on a const on the trait will go to the
implementations with their respective definitions of the const, if
present.

Co-authored-by: Jade <software@lfcode.ca>
2021-05-25 13:33:07 +00:00
Jade
0292efd363 Also do goto implementation on assoc consts
I forgot to put this into #8988, sorry.

Goto implementation on a const on the trait will go to the
implementations with their respective definitions of the const, if
present.
2021-05-25 06:27:41 -07:00
bors[bot]
33fdd512e3
Merge #8987
8987: Fix lowering of FnOnce() without return type r=flodiebold a=flodiebold

This should result in an implicit `-> ()`, not leaving out the binding.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2021-05-25 13:25:15 +00:00
Florian Diebold
7c6f764ad6 Hide -> () in Fn traits 2021-05-25 15:23:52 +02:00
bors[bot]
f3cfd8afb6
Merge #8988
8988: feat: go to implementation on trait functions r=matklad a=lf-

Fix #8537.

GIF:
![output](https://user-images.githubusercontent.com/6652840/119501981-45a45c00-bd1e-11eb-8336-9145f2888643.gif)

Co-authored-by: Jade <software@lfcode.ca>
2021-05-25 13:14:34 +00:00
Lukas Wirth
3ee4e6c54c Fix type inference not working for new Try trait 2021-05-25 14:59:54 +02:00
Jade
3e4dfaf97a feat: go to implementation on trait functions
Fix #8537.

GIF:
https://user-images.githubusercontent.com/6652840/119501981-45a45c00-bd1e-11eb-8336-9145f2888643.gif
2021-05-25 05:46:15 -07:00
Florian Diebold
35c948ff4a Fix lowering of FnOnce() without return type
This should result in an implicit `-> ()`, not leaving out the binding.
2021-05-25 14:29:53 +02:00
bors[bot]
835cf55887
Merge #8767
8767: implement range formatting r=matklad a=euclio

Fixes #7580.

This PR implements the `textDocument/rangeFormatting` request using `rustfmt`'s `--file-lines` option.

Still needs some tests. What I want to know is how I should handle the instability of the `--file-lines` option. It's still unstable in rustfmt, so it's only available on nightly, and needs a special flag to enable. Is there a way for `rust-analyzer` to detect if it's using nightly rustfmt, or for users to opt-in?

Co-authored-by: Andy Russell <arussell123@gmail.com>
2021-05-25 12:15:48 +00:00
bors[bot]
b7414fa14a
Merge #8986
8986: Add go to type definition for struct fields within struct r=matklad a=lf-

Example:

```rust
struct A;

struct B {
    a/*<- cursor*/: A,
}
```

Go to type definition used to not work on this position. It now goes to
`A` as expected.

Co-authored-by: Jade <software@lfcode.ca>
2021-05-25 11:25:00 +00:00
Florian Diebold
c33ee36d2a Minor test fixes / new tests 2021-05-25 13:07:18 +02:00
Jade
ff585e4730 Add go to type definition for struct fields within struct
Example:

```rust
struct A;

struct B {
    a/*<- cursor*/: A,
}
```

Go to type definition used to not work on this position. It now goes to
`A` as expected.
2021-05-25 04:06:54 -07:00
Florian Diebold
b26a472ccb Fix type mismatch caused by macros
MacroStmts should be completely transparent, but it prevented
coercion. (I should maybe give `infer_expr` and `infer_expr_inner`
better names.)
2021-05-25 11:15:02 +02:00
bors[bot]
8b049ec393
Merge #8942
8942: Add `library` semantic token modifier to items from other crates r=arzg a=arzg

Closes #5772.

A lot of code here is pretty repetitive; please let me know if you have any ideas how to improve it, or whether it’s fine as-is.

Side-note: How can I add tests for this? I don’t see a way for the test Rust code in `test_highlighting` to reference other crates to observe the new behaviour.


Co-authored-by: Aramis Razzaghipour <aramisnoah@gmail.com>
2021-05-25 02:30:47 +00:00
Aramis Razzaghipour
d75277b66b
Refactor application of library semantic token modifier 2021-05-25 12:20:12 +10:00
bors[bot]
6d473c0a8f
Merge #8979
8979: minor: update `CrateGraph` comment r=jonas-schievink a=jonas-schievink

`cfg` flags are now implemented, and crates *may* have names, it doesn't
doesn't matter for name resolution

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-05-24 22:58:43 +00:00
Jonas Schievink
13b8449a11 Update CrateGraph comment
`cfg` flags are now implemented, and crates *may* have names, it doesn't
doesn't matter for name resolution
2021-05-25 00:56:24 +02:00
Jonas Schievink
31175a7f88 internal: intern AttrInput 2021-05-25 00:50:19 +02:00
bors[bot]
86ca1764b6
Merge #8975
8975: Use todo!() as placeholder body for generated match arms r=matklad a=jDomantas

`todo!()` seems to be a better fit for this than `{}`. Seeing that this assist predates stabilization of `todo` my guess is that simply no one bothered to change it yet.

Also fixed the issue where if the last arm was not block-like, rust-analyzer would not add a comma after it and would generate invalid code.

Co-authored-by: Domantas Jadenkus <djadenkus@gmail.com>
2021-05-24 19:59:51 +00:00
bors[bot]
f5f24a9a2c
Merge #8977
8977: internal: minor `TokenMap` cleanups r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-05-24 19:52:01 +00:00
Jonas Schievink
c8f40b1503 Fixup 2021-05-24 21:47:01 +02:00
Aleksey Kladov
45112aa8c0 internal: rename hypothetical -> speculative
Lets steal this good naming from Roslyn before I forget about it yet
again.
2021-05-24 22:21:25 +03:00
Domantas Jadenkus
3641abc0c3 add test that it does not create extraneous commas 2021-05-24 22:17:16 +03:00
Domantas Jadenkus
8d2e3816bc tidy 2021-05-24 22:17:16 +03:00
Domantas Jadenkus
22e5194396 generate match arms with todo!() as placeholder body 2021-05-24 22:17:16 +03:00
Jonas Schievink
489ae7a800 Make TokenTextRange private 2021-05-24 20:29:48 +02:00
Jonas Schievink
27bf62b70e Move TokenMap to its own file 2021-05-24 18:43:42 +02:00
bors[bot]
3926f60cb5
Merge #8970
8970: fix: duplicate dependencies that have multiple DepKinds r=jonas-schievink a=jonas-schievink

Cargo collapses identical dependencies that are listed under `[dependencies]` and `[build-dependencies]` into a single `NodeDep`. We have to undo that by duplicating the dependency for each of its listed `DepKind`s.

Not doing that would incorrectly treat a dependency as `DepKind::Normal`, even though it is *also* meant to be a `DepKind::Build`.

Fixes https://github.com/rust-analyzer/rust-analyzer/pull/8812#issuecomment-847125395

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-05-24 16:38:15 +00:00