Commit Graph

17439 Commits

Author SHA1 Message Date
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
bors[bot]
b250d5e6bf
Merge #8985
8985: minor: Minor test fixes / new tests r=flodiebold a=flodiebold



Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2021-05-25 11:07:50 +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
bors[bot]
4afc1b8c34
Merge #8983
8983: Fix type mismatch caused by macros r=flodiebold a=flodiebold

MacroStmts should be completely transparent, but it prevented
coercion. (I should maybe give `infer_expr` and `infer_expr_inner`
better names.)

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2021-05-25 09:21:46 +00: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
bors[bot]
9c63137ef3
Merge #8978
8978: internal: intern `AttrInput` r=jonas-schievink a=jonas-schievink

saves ~10 MB on r-a

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-05-24 22:51:57 +00: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
bors[bot]
1ebb53e5db
Merge #8976
8976: internal: rename hypothetical -> speculative r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-24 19:22:34 +00: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
Benjamin Coenen
629ab18994 add support of impl block for doctest into runnables
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2021-05-24 19:17:25 +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
Jonas Schievink
518d39cd2f Duplicate dependencies that have multiple DepKinds 2021-05-24 18:31:43 +02:00
bors[bot]
a59d41c1df
Merge #8967
8967: fix cursor position after item move command r=matklad a=eduardocanellas



Co-authored-by: Eduardo Canellas <eduardocanellas98@gmail.com>
2021-05-24 16:28:28 +00:00
Eduardo Canellas
3dce8a3924 fix: cursor position after item move command
closes Item movers need some fixes #8492
2021-05-24 13:17:28 -03:00
bors[bot]
c139eff5b8
Merge #8963
8963: Bump deps r=matklad a=lnicola



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-05-24 15:34:52 +00:00
Laurențiu Nicola
741f47f208 Update test fixtures 2021-05-24 18:18:05 +03:00
bors[bot]
c1e3bd8100
Merge #8969
8969: fix: Update download instructions r=cschmatzler a=lnicola

Closes #8966

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-05-24 14:58:06 +00:00
Laurențiu Nicola
400cf10299 Update download instructions 2021-05-24 17:57:20 +03:00
bors[bot]
2d532ab150
Merge #8968
8968: docs: fix binary installation instructions r=matklad a=cschmatzler

fixes #8966 

Co-authored-by: Christoph Schmatzler <christoph@schmatzler.name>
2021-05-24 14:41:49 +00:00
Christoph Schmatzler
9f8f7a8053 docs: fix binary installation instructions
issue #8926 removed uncompressed release artifacts. This updates the documentation to update instructions accordingly.
2021-05-24 16:38:33 +02:00
bors[bot]
01f8d40c5c
Merge #8965
8965: internal: intern `TypeBound` and `GenericArgs` r=jonas-schievink a=jonas-schievink

Saves a few MB, but not much

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-05-24 13:58:44 +00:00
Laurențiu Nicola
b43bc61981 Bump rustc_lexer 2021-05-24 16:39:19 +03:00
Laurențiu Nicola
f1cfbe6ffc Disable unaliged feature of object 2021-05-24 16:35:52 +03:00
Jonas Schievink
533e9207d3 Intern GenericArgs
This shaves off another ~4 mb or so
2021-05-24 15:35:46 +02:00
Laurențiu Nicola
d525cfc85a Bump object 2021-05-24 16:35:23 +03:00
Laurențiu Nicola
47afa4a5fc Bump misc deps 2021-05-24 16:31:54 +03:00
Laurențiu Nicola
74f1b21b08 Bump chalk 2021-05-24 16:27:24 +03:00
Jonas Schievink
8ebb8d29e1 internal: intern TypeBounds
Doesn't save much memory (~2 mb), but interning things is generally a
good pattern to follow
2021-05-24 15:13:23 +02:00
bors[bot]
05fc97e31b
Merge #8955
8955: feature: Support standalone Rust files r=matklad a=SomeoneToIgnore

![standalone](https://user-images.githubusercontent.com/2690773/119277037-0b579380-bc26-11eb-8d77-20d46ab4916a.gif)

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

Caveats: 

* I've decided to support multiple detached files in the code (anticipating the scratch files), but I found no way to open multiple files in VSCode at once: running `code *.rs` makes the plugin to register in the `vscode.workspace.textDocuments` only the first file, while code actually displays all files later.
Apparently what happens is the same as when you have VSCode open at some workplace already and then run `code some_other_file.rs`: it gets opened in the same workspace of the same VSCode with no server to support it.
If there's a way to override it, I'd appreciate the pointer.

* No way to toggle inlay hints, since the setting is updated for the workspace (which does not exist for a single file opened)
> [2021-05-24 00:22:49.100] [exthost] [error] Error: Unable to write to Workspace Settings because no workspace is opened. Please open a workspace first and try again.

* No runners/lens to run or check the code are implemented for this mode. 
In theory, we can detect `rustc`, run it on a file and run the resulting binary, but not sure if worth doing it at this stage.

Otherwise imports, hints, completion and other features work.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2021-05-24 12:40:25 +00:00
Kirill Bulatov
5c0369b1d0 Add a FIXME 2021-05-24 14:52:57 +03:00
bors[bot]
31a19148e9
Merge #8962
8962: internal: try re-enabling debug info on releases again r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-24 11:52:09 +00:00
Kirill Bulatov
d8c36029cc
Small file error display fix
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-24 14:47:20 +03:00
Aleksey Kladov
3ea62568ba internal: try re-enabling debug info on releases again
full LTO OOMs the LLVM, lets try thin

cc https://github.com/rust-lang/rust/issues/85598
2021-05-24 14:41:31 +03:00