Commit Graph

9813 Commits

Author SHA1 Message Date
Florian Diebold fe7bf993aa Implement better handling of divergence
Divergence here means that for some reason, the end of a block will not be
reached. We tried to model this just using the never type, but that doesn't work
fully (e.g. in `let x = { loop {}; "foo" };` x should still have type `&str`);
so this introduces a `diverges` flag that the type checker keeps track of, like
rustc does.
2020-05-08 18:15:24 +02:00
bors[bot] d3eb9d8eaf Merge #4376
4376: Fix type of byte literals r=matklad a=flodiebold

They're `&[u8; N]`, not `&[u8]` (see #4374).

Co-authored-by: Florian Diebold <florian.diebold@freiheit.com>
2020-05-08 13:22:05 +00:00
Florian Diebold f5177f91ae Fix type of byte literals
They're `&[u8; N]`, not `&[u8]` (see #4374).
2020-05-08 15:18:33 +02:00
bors[bot] 51e4b92c1e Merge #4375
4375: Cleanup toolchain handling r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-05-08 12:55:55 +00:00
Aleksey Kladov ecff5dc141 Cleanup 2020-05-08 14:55:28 +02:00
Aleksey Kladov 7c0409e0c7 Cleanup 2020-05-08 12:34:39 +02:00
Aleksey Kladov 6713be0b13 Rename ra_env -> ra_toolchain 2020-05-08 12:25:36 +02:00
bors[bot] 8295a9340c Merge #4329
4329: Look for `cargo`, `rustc`, and `rustup` in standard installation path r=matklad a=cdisselkoen

Discussed in #3118.  This is approximately a 90% fix for the issue described there.

This PR creates a new crate `ra_env` with a function `get_path_for_executable()`; see docs there.  `get_path_for_executable()` improves and generalizes the function `cargo_binary()` which was previously duplicated in the `ra_project_model` and `ra_flycheck` crates.  (Both of those crates now depend on the new `ra_env` crate.)  The new function checks (e.g.) `$CARGO` and `$PATH`, but also falls back on `~/.cargo/bin` manually before erroring out.  This should allow most users to not have to worry about setting the `$CARGO` or `$PATH` variables for VSCode, which can be difficult e.g. on macOS as discussed in #3118.

I've attempted to replace all calls to `cargo`, `rustc`, and `rustup` in rust-analyzer with appropriate invocations of `get_path_for_executable()`; I don't think I've missed any in Rust code, but there is at least one invocation in TypeScript code which I haven't fixed.  (I'm not sure whether it's affected by the same problem or not.) https://github.com/rust-analyzer/rust-analyzer/blob/a4778ddb7a00f552a8e653bbf56ae9fd69cfe1d3/editors/code/src/cargo.ts#L79

I'm sure this PR could be improved a bunch, so I'm happy to take feedback/suggestions on how to solve this problem better, or just bikeshedding variable/function/crate names etc.

cc @Veetaha 

Fixes #3118.

Co-authored-by: Craig Disselkoen <craigdissel@gmail.com>
Co-authored-by: veetaha <veetaha2@gmail.com>
2020-05-08 10:11:19 +00:00
bors[bot] 363c1f2f49 Merge #4372
4372: Add master config for inlayHints to make disabling easy r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-05-08 07:29:03 +00:00
Aleksey Kladov 3bf5ef02c0 Add master config for inlayHints to make disabling easy 2020-05-08 09:28:15 +02:00
bors[bot] 6f2f9049da Merge #4370
4370: Move feature desugaring to the right abstraction layer r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-05-08 00:57:29 +00:00
Aleksey Kladov d3110859ba Move feature desugaring to the right abstraction layer 2020-05-08 02:56:53 +02:00
bors[bot] 7be0a29c63 Merge #4367
4367: Update deps r=kjeremy a=kjeremy



Co-authored-by: kjeremy <kjeremy@gmail.com>
2020-05-07 20:46:25 +00:00
kjeremy 88a45a2ee3 Update deps 2020-05-07 16:22:53 -04:00
Craig Disselkoen 3077eae2a6 use home crate instead of dirs 2020-05-07 12:06:44 -07:00
bors[bot] 1b136aae0b Merge #4296
4296: Support cargo:rustc-cfg in build.rs r=matklad a=robojumper

Fixes #4238.

Co-authored-by: robojumper <robojumper@gmail.com>
2020-05-07 18:50:00 +00:00
bors[bot] 97b9b364d6 Merge #4362
4362: do not show runnables for main function outside of a binary target  r=matklad a=bnjjj

close #4356

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-07 17:30:13 +00:00
bors[bot] aa112bf714 Merge #4365
4365: Use the correct color for structs r=matklad a=matklad

This works around https://github.com/microsoft/vscode/issues/97162



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-05-07 16:49:42 +00:00
Aleksey Kladov 2904311664 Use the correct color for structs
This works around https://github.com/microsoft/vscode/issues/97162
2020-05-07 18:46:58 +02:00
bors[bot] fd84c31ff7 Merge #4346
4346: Fix rename of enum variant visible from module r=matklad a=montekki

Probably fixes #4237 

It looks like the ref is found correctly in this case but it's visibility is not correctly determined. I took a stab at fixing that by adding an implementation of `HasVisibility` for `EnumVariant` so it works more or less the same way it does for struct fields.

In other words, the `search_range` here does not contain the ref since it's not considered visible:

https://github.com/rust-analyzer/rust-analyzer/blob/efd8e34c396f1524623a495e47111f1047cf2879/crates/ra_ide_db/src/search.rs#L209-L214


Before that I tried to populate `ItemScope` with visible enum variants but that ended up with breaking tests all over the place and also it looked illogical in the end: `ItemScope` is not populated with, say, public struct fields and the same should be true for `enum` variants.

I've added two more or less identical tests: one for the case with a struct field rename and one for enum variant rename; the test for struct should probably be removed and the names should be changed.


Co-authored-by: Fedor Sakharov <fedor.sakharov@gmail.com>
2020-05-07 16:29:01 +00:00
bors[bot] a9945137dc Merge #4364
4364: Touch up assists public API r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-05-07 15:32:40 +00:00
Aleksey Kladov 1e790ea314 Simplify 2020-05-07 17:32:01 +02:00
Aleksey Kladov 28fcff125a Nicer API 2020-05-07 17:29:23 +02:00
Aleksey Kladov c6b81bc013 Rename AssitLabel -> Assist 2020-05-07 17:18:28 +02:00
Benjamin Coenen c839d4f7a9 do not show runnables for main function outside of a binary target #4356
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-07 16:52:14 +02:00
bors[bot] c7e305731c Merge #4350
4350:   Refactor assists API to be more convenient for adding new assists r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-05-07 14:28:47 +00:00
Aleksey Kladov 4867968d22 Refactor assists API to be more convenient for adding new assists
It now duplicates completion API in its shape.
2020-05-07 16:27:54 +02:00
Fedor Sakharov 210f0cbd27 Remove HasVisibility implementation 2020-05-07 16:31:51 +03:00
bors[bot] f4cd75ac06 Merge #4359
4359: Fix panic in FunctionSignature r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-05-07 12:32:21 +00:00
Aleksey Kladov 43cedecf68 Fix panic in FunctionSignature 2020-05-07 14:29:01 +02:00
Craig Disselkoen 227929f9dd simplify by using bail! macro 2020-05-06 13:29:22 -07:00
Craig Disselkoen 5d4648884b cargo fmt 2020-05-06 12:47:13 -07:00
Craig Disselkoen 44b01ccff3 return a PathBuf instead of String 2020-05-06 12:39:11 -07:00
bors[bot] 9cb55966fe Merge #4333
4333: Update Arch Linux and ALE install instructions r=matklad a=polyzen

Package has been added to the Arch repos:
https://www.archlinux.org/packages/community/x86_64/rust-analyzer/

ALE merged rust-analyzer support:
https://github.com/dense-analysis/ale/commit/70005134e5b2d40d176ee5b851ac64a296b22201

Co-authored-by: Daniel M. Capella <polyzen@archlinux.org>
2020-05-06 17:13:02 +00:00
bors[bot] 6b18d364fc Merge #4353
4353: Better mapping to TextMate scopes for keywords r=matklad a=matklad

https://github.com/microsoft/vscode/issues/94367#issuecomment-608629883



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-05-06 17:04:00 +00:00
Aleksey Kladov 71369f5c59 Better mapping to TextMate scopes for keywords
https://github.com/microsoft/vscode/issues/94367#issuecomment-608629883
2020-05-06 19:03:17 +02:00
bors[bot] 1a0988b899 Merge #4316 #4351
4316: do not truncate display for hover r=matklad a=bnjjj

close #4311 

4351: Fix Windows server path r=matklad a=lnicola

CC @Coder-256.

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2020-05-06 16:54:31 +00:00
Laurențiu Nicola e0b63855b1 Fix Windows server path
CC @Coder-256.
2020-05-06 19:53:14 +03:00
bors[bot] 5b697d5693 Merge #4349
4349: package.json: Minor configuration spelling fix r=matklad a=seanbright



Co-authored-by: Sean Bright <seanbright@users.noreply.github.com>
2020-05-06 16:46:55 +00:00
bors[bot] b832dfc917 Merge #4331
4331: Fixture improvements r=TimoFreiberg a=TimoFreiberg

As mentioned in [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/resolve_path.20between.20fixture.20files) :)

I think always allowing unindented first lines is friendlier than making the user fix it and I don't see any drawbacks.

Co-authored-by: Timo Freiberg <timo.freiberg@gmail.com>
2020-05-06 16:18:17 +00:00
Timo Freiberg 86fa80e5b3 Allow fixture strings with unindented first line
This allows fixtures like
        "//- /lib.rs
         ...
         //- /foo.rs
         ...
"
2020-05-06 18:09:28 +02:00
Timo Freiberg 8a5d14453e Add fixture doc comment 2020-05-06 18:09:28 +02:00
bors[bot] fbc8bd3fdb Merge #4043
4043: add Ok wrapping assist #3907 r=matklad a=bnjjj

About issue #3907 
close #3907 

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-06 16:04:47 +00:00
Benjamin Coenen 51c02ab84f add Ok wrapping
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-06 17:45:55 +02:00
Sean Bright 9a4553b833 package.json: Minor configuration spelling fix 2020-05-06 11:22:24 -04:00
bors[bot] e99447ffbf Merge #4347
4347: Fix usefulness check for never type r=flodiebold a=MikailBag



Co-authored-by: Mikail Bagishov <bagishov.mikail@yandex.ru>
2020-05-06 15:11:26 +00:00
Mikail Bagishov 7c94fa7d01 Fix usefulness check for never type 2020-05-06 17:59:27 +03:00
bors[bot] 1252107a3c Merge #4345
4345: Refactor assists a bit r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-05-06 14:39:49 +00:00
Aleksey Kladov 020ca6695f Simplify 2020-05-06 16:39:11 +02:00
Fedor Sakharov bd9f1f7eb7 Fix rename of enum variant visible from module 2020-05-06 17:35:22 +03:00