]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoMerge #7071
bors[bot] [Thu, 31 Dec 2020 15:29:26 +0000 (15:29 +0000)]
Merge #7071

7071: Pass --all-targets to "cargo check" when discovering external resources r=matklad a=WasabiFan

There is a repro case and background in the linked issue.

In short, the goal of this MR is to allow rust-analyzer to discover proc-macros which come from your tests (including, most importantly, dev-dependencies).

By default, `cargo check` implies the equivalent of `--lib --bins`, meaning it'll check your libraries and binaries -- but not tests! This means proc-macros (or, I guess, build scripts as well) weren't discovered by rust-analyzer if they came from tests.

One solution would be to manually add `--lib --bins --tests` (i.e., just augment the effective options to include tests). However, in this MR, I threw in `--all-targets`, which [according to the docs](https://doc.rust-lang.org/cargo/commands/cargo-check.html#target-selection) implies `--benches --examples` too. I have absolutely no idea what repercussions that will have on rust-analyzer for other projects, nor do I know if it's a problem that build scripts will now be discovered for tests/examples/benches. But I am not aware of a reason you _wouldn't_ want to discover these things in your examples too.

I think the main drawback of this change is that it will likely slow down the `cargo check`. At a minimum, it'll now be checking your tests _and_ their dependencies. The `cargo check` docs also say that including `--tests` as I have here may cause your lib crate to be built _twice_, once for the normal target and again for unit tests. My reading of that caveat suggests that "building twice" means it's built once for the tests _inside_ your lib, with a test profile, and again for any consumers of your lib, now using a normal release profile or similar. This doesn't seem surprising.

Very minor caveat: `--tests`  will not include tests within a binary if it has `test = false` set in `Cargo.toml`. (I discovered this manually by trial-and-error, but hey, it actually says that in the docs!) This is likely not an issue, but _does_ mean that if you are -- for whatever reason -- disabling tests like that and then manually specifying `cargo test --package <...> --bin <...>` to run them, rust-analyzer will remain unaware of proc-macros in your tests.

I have confirmed this fixes the original issue in my sandbox example linked in #7034 and in my own project in which I originally discovered this. I've left it configured as my default RA language server and will report back if I notice any unexpected side-effects.

Fixes #7034

Co-authored-by: Kaelin Laundry <wasabifan@outlook.com>
3 years agoMerge #7106
bors[bot] [Thu, 31 Dec 2020 15:11:14 +0000 (15:11 +0000)]
Merge #7106

7106: Split textDocument/formatting TextEdit with diff r=matklad a=Jesse-Bakker

#7044

Co-authored-by: Jesse Bakker <github@jessebakker.com>
3 years agoSplit textDocument/formatting TextEdit with diff
Jesse Bakker [Thu, 31 Dec 2020 12:05:19 +0000 (13:05 +0100)]
Split textDocument/formatting TextEdit with diff

3 years agoMerge #7107
bors[bot] [Thu, 31 Dec 2020 13:04:29 +0000 (13:04 +0000)]
Merge #7107

7107: add working dir to cargo metadata fail messages r=matklad a=lf-

Context: I was having an error in my workspace config that I couldn't figure out without this added output. In particular, I have a Code workspace with a docs folder and one of my top level crates [which each have their own custom target], which was picking up the Cargo workspace level Cargo.toml incorrectly [which in my project should not ever be used for the editor], and ultimately had to override it with `linkedProjects`.

Here's a sample of the changed output:

```
[INFO rust_analyzer::main_loop] handle_event(Workspaces([Err(Failed to read Cargo metadata from Cargo.toml file /home/jade/dev/mu/Cargo.toml, cargo 1.50.0-nightly (75d5d8cff 2020-12-22)

Caused by:
    0: Failed to run `cargo metadata --manifest-path /home/jade/dev/mu/Cargo.toml` in `/home/jade/dev/mu`
    1: Error during execution of `cargo metadata`: error: target path "../../riscv64imac-mu-shoo-elf.json" is not a valid file

       Caused by:
         No such file or directory (os error 2)
       ), Err(Failed to read Cargo metadata from Cargo.toml file /home/jade/dev/mu/shoo/Cargo.toml, cargo 1.50.0-nightly (75d5d8cff 2020-12-22)

Caused by:
    0: Failed to run `cargo metadata --manifest-path /home/jade/dev/mu/shoo/Cargo.toml` in `/home/jade/dev/mu/shoo`
    1: Error during execution of `cargo metadata`: error: target path "../../riscv64imac-mu-shoo-elf.json" is not a valid file

       Caused by:
         No such file or directory (os error 2)
       )]))
```

Co-authored-by: lf- <lf-@users.noreply.github.com>
3 years agoadd working dir to cargo metadata fail messages
lf- [Thu, 31 Dec 2020 12:42:59 +0000 (04:42 -0800)]
add working dir to cargo metadata fail messages

3 years agoMerge #7055
bors[bot] [Thu, 31 Dec 2020 11:21:23 +0000 (11:21 +0000)]
Merge #7055

7055: Install rustfmt if needed during formatting request r=matklad a=kinnison

In order to fix #6052 and to fix #4249 this PR installs `rustfmt` using `rustup` if `rustfmt --help` fails.

In theory we ought to memoise the attempts (both the `--help` and the installation) so that we don't keep retrying something which will fail (e.g. if nightly is missing rustfmt), but this is a first-pass for opinions.

In order to make it possible to notify the user of what happened, I added a facility for `GlobalStateSnapshot` to send *messages* to the client indicating what happened.  There may be a cleaner way to do this as well but I wasn't sure exactly what might be best given this is my first time in this codebase.

It may be worth, longer term, working with `rustup` to provide a way to detect a missing component binary since `rustup` returns `1` if `rustfmt` is not installed, which is not ideal.

Co-authored-by: Daniel Silverstone <dsilvers@digital-scurf.org>
3 years agohandle_formatting: Notice if rustfmt is missing and report
Daniel Silverstone [Thu, 31 Dec 2020 09:03:34 +0000 (09:03 +0000)]
handle_formatting: Notice if rustfmt is missing and report

In an attempt to fix #6052 and #4249 this attempts to detect
if rustfmt is a rustup proxy which isn't installed, and reports
the error message to the user for them to fix.

In theory this ought to be memoised but for now it'll do as-is.

Future work might be to ask the user if they would like us to
trigger the installation (if possible).

Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
3 years agoMerge #7105
bors[bot] [Thu, 31 Dec 2020 10:04:19 +0000 (10:04 +0000)]
Merge #7105

7105: Fix `==` in in format causes mismatched-arg-count r=edwin0cheng a=edwin0cheng

Fixes #7085

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
3 years agoFix `==` in in format causes mismatched-arg-count
Edwin Cheng [Thu, 31 Dec 2020 09:59:29 +0000 (17:59 +0800)]
Fix `==` in in format causes mismatched-arg-count

3 years agoMerge #7104
bors[bot] [Thu, 31 Dec 2020 09:14:22 +0000 (09:14 +0000)]
Merge #7104

7104: Remove some unneeded string allocations r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoRemove some unneeded string allocations
Lukas Wirth [Thu, 31 Dec 2020 09:13:14 +0000 (10:13 +0100)]
Remove some unneeded string allocations

3 years agoMerge #7101
bors[bot] [Thu, 31 Dec 2020 05:37:08 +0000 (05:37 +0000)]
Merge #7101

7101: Fix spacing bug in proc-macro TokenStream::to_string r=edwin0cheng a=edwin0cheng

bors r+

fixes #7100

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
3 years agoFix spacing in proc-macro tokens to_string
Edwin Cheng [Thu, 31 Dec 2020 05:01:15 +0000 (13:01 +0800)]
Fix spacing in proc-macro tokens to_string

3 years agoFix completion of Default struct update syntax
Nick Spain [Thu, 31 Dec 2020 05:22:59 +0000 (16:22 +1100)]
Fix completion of Default struct update syntax

Previously the inserted text was always `..Default::default()` which ends up as `...Default::default()`
if `.` was typed. Now  checks if the current token is `.` and inserts `.Default::default()`
if it is, so `..Default::default()` is correctly completed.

Fixes #6969

3 years agoMerge #7099
bors[bot] [Wed, 30 Dec 2020 19:10:56 +0000 (19:10 +0000)]
Merge #7099

7099: Remove unused clones in mbe r=edwin0cheng a=edwin0cheng

bors r+

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
3 years agoRemove unused clones in mbe
Edwin Cheng [Wed, 30 Dec 2020 18:38:40 +0000 (02:38 +0800)]
Remove unused clones in mbe

3 years agoMerge #7094
bors[bot] [Wed, 30 Dec 2020 15:42:05 +0000 (15:42 +0000)]
Merge #7094

7094: Update crates r=kjeremy a=kjeremy

Co-authored-by: kjeremy <kjeremy@gmail.com>
3 years agoUpdate crates
kjeremy [Wed, 30 Dec 2020 15:39:50 +0000 (10:39 -0500)]
Update crates

3 years agoMerge #7091
bors[bot] [Wed, 30 Dec 2020 12:55:26 +0000 (12:55 +0000)]
Merge #7091

7091: Add an option for extra env vars in the Code extension r=lf- a=lf-

I was debugging some issues with the RA extension around getting `cargo check` to work and it was particularly frustrating to get the RA_LOG variable set on the server since I had to change it in a login file. This should make that easier.

Co-authored-by: lf- <lf-@users.noreply.github.com>
3 years agoAdd an option for extra env vars in the Code extension
lf- [Wed, 30 Dec 2020 09:17:25 +0000 (01:17 -0800)]
Add an option for extra env vars in the Code extension

3 years agoMerge #7092
bors[bot] [Wed, 30 Dec 2020 10:39:45 +0000 (10:39 +0000)]
Merge #7092

7092: Simplify r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoSimplify
Aleksey Kladov [Wed, 30 Dec 2020 10:38:37 +0000 (13:38 +0300)]
Simplify

3 years agoMerge #7090
bors[bot] [Wed, 30 Dec 2020 09:38:35 +0000 (09:38 +0000)]
Merge #7090

7090: Allow spurious warning from rust-lang/rust#80501 r=lnicola a=lnicola

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
3 years agoAllow spurious warning from rust-lang/rust#80501
Laurențiu Nicola [Wed, 30 Dec 2020 09:37:52 +0000 (11:37 +0200)]
Allow spurious warning from rust-lang/rust#80501

3 years agoMerge #7088
bors[bot] [Wed, 30 Dec 2020 07:45:33 +0000 (07:45 +0000)]
Merge #7088

7088: Smarter bracketed `use` diagnostic r=lnicola a=AdnoC

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

Makes it so that if a bracketed use statement contains a comment inside the braces, no "Unnecessary braces in use statement" diagnostic is shown.

Co-authored-by: AdnoC <adam.r.cutler@gmail.com>
3 years agoindentation
AdnoC [Wed, 30 Dec 2020 05:56:00 +0000 (22:56 -0700)]
indentation

3 years agotest for new behavior
AdnoC [Wed, 30 Dec 2020 05:52:47 +0000 (22:52 -0700)]
test for new behavior

3 years agoSmarter bracketed use diagnostic
AdnoC [Wed, 30 Dec 2020 05:46:34 +0000 (22:46 -0700)]
Smarter bracketed use diagnostic

3 years agoMerge #7083
bors[bot] [Wed, 30 Dec 2020 00:39:29 +0000 (00:39 +0000)]
Merge #7083

7083: Refactor mbe parsing code r=edwin0cheng a=edwin0cheng

Inspire by #5426 , this PR refactor out the parsing code such that it only parsed on `mbe::Rule`, but not on invocations.

However, it just improve the overall performance unnoticeablely :(

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
3 years agoRefactor mbe parsing code
Edwin Cheng [Tue, 29 Dec 2020 18:35:21 +0000 (02:35 +0800)]
Refactor mbe parsing code

3 years agoMerge #7070
bors[bot] [Tue, 29 Dec 2020 16:14:18 +0000 (16:14 +0000)]
Merge #7070

7070: Use applySnippetWorkspaceEdit again for actions, allow it to create files r=matklad a=Veykril

Fixes #7037

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoApply text edits manually in vscode client
Lukas Wirth [Tue, 29 Dec 2020 14:43:17 +0000 (15:43 +0100)]
Apply text edits manually in vscode client

3 years agoMerge #7077
bors[bot] [Tue, 29 Dec 2020 13:15:07 +0000 (13:15 +0000)]
Merge #7077

7077: Avoid a couple of allocations r=Veykril a=lnicola

r? @Veykril

TBH I'm not sure this is worth it, but the other `Query` was already taking a `String`.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
3 years agoAvoid a couple of allocations
Laurențiu Nicola [Tue, 29 Dec 2020 12:35:49 +0000 (14:35 +0200)]
Avoid a couple of allocations

3 years agoMerge #7064
bors[bot] [Tue, 29 Dec 2020 12:19:31 +0000 (12:19 +0000)]
Merge #7064

7064: Ignore qualifiers when doing autoimport completions lookup r=lnicola a=SomeoneToIgnore

A follow-up of https://github.com/rust-analyzer/rust-analyzer/pull/6918#issuecomment-748511151 and the PR itself.

Tweaks the `import_map` query api to be more flexible with the ways to match against the import path and now fuzzy imports search in names only.
This had improved the completion speed for me locally in ~5 times for `fuzzy_completion` span time, but please recheck me here.

IMO we're fast and presice enough now, so I've added the modules back to the fuzzy search output.

Also tweaks the the expect tests to display functions explicitly, to avoid confusing "duplicate" results.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
3 years agoMerge #7076
bors[bot] [Tue, 29 Dec 2020 12:12:19 +0000 (12:12 +0000)]
Merge #7076

7076: Properly parse path separators in format-like postfix r=Veykril a=Veykril

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoProperly parse path separators in format-like postfix
Lukas Wirth [Tue, 29 Dec 2020 11:54:48 +0000 (12:54 +0100)]
Properly parse path separators in format-like postfix

3 years agoMerge #7075
bors[bot] [Tue, 29 Dec 2020 11:45:00 +0000 (11:45 +0000)]
Merge #7075

7075: format-postfix completion takes format instead of fmt r=lnicola a=Veykril

See https://github.com/rust-analyzer/rust-analyzer/issues/6843
this brings it back in line with the documentation

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoformat-postfix completion takes format instead of fmt
Lukas Wirth [Sat, 26 Dec 2020 16:55:48 +0000 (17:55 +0100)]
format-postfix completion takes format instead of fmt

3 years agoPass --all-targets to "cargo check"
Kaelin Laundry [Tue, 29 Dec 2020 03:33:16 +0000 (19:33 -0800)]
Pass --all-targets to "cargo check"

3 years agoInitial implementation of view-hir command
Phil Ellison [Mon, 28 Dec 2020 18:29:58 +0000 (18:29 +0000)]
Initial implementation of view-hir command

3 years agoTweak the fuzzy search limits
Kirill Bulatov [Mon, 28 Dec 2020 14:19:51 +0000 (16:19 +0200)]
Tweak the fuzzy search limits

3 years agoBetter display methods in expect tests
Kirill Bulatov [Mon, 28 Dec 2020 14:13:37 +0000 (16:13 +0200)]
Better display methods in expect tests

3 years agoAdd tests
Kirill Bulatov [Mon, 28 Dec 2020 13:22:03 +0000 (15:22 +0200)]
Add tests

3 years agoAdd docs and optimisations
Kirill Bulatov [Mon, 28 Dec 2020 12:54:31 +0000 (14:54 +0200)]
Add docs and optimisations

3 years agoBetter query api and fuzzy search
Kirill Bulatov [Mon, 28 Dec 2020 12:24:13 +0000 (14:24 +0200)]
Better query api and fuzzy search

3 years agoDraft the module exclusion in modules
Kirill Bulatov [Mon, 28 Dec 2020 09:41:08 +0000 (11:41 +0200)]
Draft the module exclusion in modules

3 years agoMerge #7060
bors[bot] [Mon, 28 Dec 2020 12:34:19 +0000 (12:34 +0000)]
Merge #7060

7060: Fix mbe fail to pass expr with attr r=edwin0cheng a=edwin0cheng

bors r+

Fixes #5896

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
3 years agoMerge #7059
bors[bot] [Mon, 28 Dec 2020 12:26:55 +0000 (12:26 +0000)]
Merge #7059

7059: Special case $_ in meta var instead of treat it as ident in mbe  r=lnicola a=edwin0cheng

In #6929, we treat '_' as an ident but rustc is only allow it in some special places (e.g. meta var in mbe , type, pat etc).

This PR rollback that and we only make '$_' works in meta var matching.

Fixes #7056

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
3 years agoFixed old failed test due to new fixes
Edwin Cheng [Mon, 28 Dec 2020 12:08:50 +0000 (20:08 +0800)]
Fixed old failed test due to new fixes

3 years agoFix mbe fail to pass expr with attr
Edwin Cheng [Mon, 28 Dec 2020 11:53:00 +0000 (19:53 +0800)]
Fix mbe fail to pass expr with attr

3 years agoSpecial case underscore in mbe meta op
Edwin Cheng [Mon, 28 Dec 2020 10:51:43 +0000 (18:51 +0800)]
Special case underscore in mbe meta op

3 years agoRollback 6929
Edwin Cheng [Mon, 28 Dec 2020 10:47:00 +0000 (18:47 +0800)]
Rollback 6929

3 years agoMerge #7058
bors[bot] [Mon, 28 Dec 2020 10:44:38 +0000 (10:44 +0000)]
Merge #7058

7058: Improve commit message style r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoImprove commit message style
Aleksey Kladov [Mon, 28 Dec 2020 10:43:07 +0000 (13:43 +0300)]
Improve commit message style

3 years agoMerge #7050
bors[bot] [Sun, 27 Dec 2020 16:42:01 +0000 (16:42 +0000)]
Merge #7050

7050: Ignore third punct when matching for 2-composite punct in mbe r=jonas-schievink a=edwin0cheng

Fixes #6692

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
3 years agoIgnore third punct in 2-composite punct
Edwin Cheng [Sun, 27 Dec 2020 15:51:00 +0000 (23:51 +0800)]
Ignore third punct in 2-composite punct

3 years agoMerge #6820
bors[bot] [Sun, 27 Dec 2020 14:39:05 +0000 (14:39 +0000)]
Merge #6820

6820: Pass the crate environment to proc macros r=jonas-schievink a=jonas-schievink

In theory, fixes https://github.com/rust-analyzer/rust-analyzer/issues/6696.

This seems to result in these obscure crashes for some reason:

```
thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', /home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/proc_macro/src/bridge/scoped_cell.rs:75:51
stack backtrace:
   0: rust_begin_unwind
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:483
   1: core::panicking::panic_fmt
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/panicking.rs:85
   2: core::panicking::panic
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/panicking.rs:50
   3: core::option::Option<T>::unwrap
             at /home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs:383
   4: proc_macro::bridge::scoped_cell::ScopedCell<T>::replace
             at /home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/proc_macro/src/bridge/scoped_cell.rs:75
   5: proc_macro::bridge::client::BridgeState::with::{{closure}}
             at /home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/proc_macro/src/bridge/client.rs:291
   6: std::thread::local::LocalKey<T>::try_with
             at /home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:272
   7: std::thread::local::LocalKey<T>::with
             at /home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:248
   8: proc_macro::bridge::client::BridgeState::with
             at /home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/proc_macro/src/bridge/client.rs:290
   9: proc_macro::bridge::client::<impl proc_macro::bridge::Bridge>::with
             at /home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/proc_macro/src/bridge/client.rs:329
  10: proc_macro::bridge::client::run_client::{{closure}}::{{closure}}
             at /home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/proc_macro/src/bridge/client.rs:375
  11: proc_macro::bridge::scoped_cell::ScopedCell<T>::set::{{closure}}
             at /home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/proc_macro/src/bridge/scoped_cell.rs:80
  12: proc_macro::bridge::scoped_cell::ScopedCell<T>::replace
             at /home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/proc_macro/src/bridge/scoped_cell.rs:75
  13: proc_macro::bridge::scoped_cell::ScopedCell<T>::set
             at /home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/proc_macro/src/bridge/scoped_cell.rs:80
  14: proc_macro::bridge::client::<impl proc_macro::bridge::Bridge>::enter::{{closure}}
             at /home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/proc_macro/src/bridge/client.rs:325
  15: std::thread::local::LocalKey<T>::try_with
             at /home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:272
  16: std::thread::local::LocalKey<T>::with
             at /home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:248
  17: proc_macro::bridge::client::<impl proc_macro::bridge::Bridge>::enter
             at /home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/proc_macro/src/bridge/client.rs:325
  18: proc_macro::bridge::client::run_client::{{closure}}
             at /home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/proc_macro/src/bridge/client.rs:370
  19: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:308
  20: std::panicking::try::do_call
             at /home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:381
  21: __rust_try
  22: std::panicking::try
             at /home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:345
  23: std::panic::catch_unwind
             at /home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:382
  24: proc_macro::bridge::client::run_client
             at /home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/proc_macro/src/bridge/client.rs:369
  25: proc_macro::bridge::client::Client<fn(proc_macro::TokenStream) .> proc_macro::TokenStream>::expand1::run
             at /home/jonas/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/proc_macro/src/bridge/client.rs:410
  26: proc_macro_srv::proc_macro::bridge::server::run_server
  27: proc_macro_srv::dylib::Expander::expand
  28: proc_macro_srv::ProcMacroSrv::expand
  29: proc_macro_srv::cli::run
  30: rust_analyzer::main
```

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoPass crate environment to proc macros
Jonas Schievink [Fri, 11 Dec 2020 13:57:50 +0000 (14:57 +0100)]
Pass crate environment to proc macros

3 years agoMove TokenExpander to base_db and rename it
Jonas Schievink [Fri, 11 Dec 2020 13:24:02 +0000 (14:24 +0100)]
Move TokenExpander to base_db and rename it

It's only used to break the dependency to proc_macro_api

3 years agoMerge #7047
bors[bot] [Sun, 27 Dec 2020 13:30:06 +0000 (13:30 +0000)]
Merge #7047

7047: Add force_show_panics flag for proc-macro bridge r=jonas-schievink a=edwin0cheng

https://github.com/rust-lang/rust/pull/75082 and https://github.com/rust-lang/rust/pull/76292 added a new flag in `proc_macro::Bridge` such that the ABI was changed. These ABI changing are the reason of some weird panics which caused #6880 and maybe related to the panic mentioned in #6820.

These changes are landed on rust stable 1.48 so I think it is okay to apply it now.

fixes #6880

r @jonas-schievink

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
3 years agoAdd force_show_panics flag
Edwin Cheng [Sun, 27 Dec 2020 10:00:59 +0000 (18:00 +0800)]
Add force_show_panics flag

3 years agoMerge #7043
bors[bot] [Sat, 26 Dec 2020 11:14:19 +0000 (11:14 +0000)]
Merge #7043

7043: Simplify assists resolution API r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoSimplify assists resolution API
Aleksey Kladov [Sat, 26 Dec 2020 11:11:42 +0000 (14:11 +0300)]
Simplify assists resolution API

Assist vs UnresolvedAssist split doesn't really pull its weight. This
is especially bad if we want to include `Assist` as a field of
diagnostics, where we'd have to make the thing generic.

3 years agoMerge #7038
bors[bot] [Fri, 25 Dec 2020 17:17:14 +0000 (17:17 +0000)]
Merge #7038

7038: Fix type typo in add_missing_impl_members doc r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoFix type typo in add_missing_impl_members doc
Lukas Wirth [Fri, 25 Dec 2020 17:15:31 +0000 (18:15 +0100)]
Fix type typo in add_missing_impl_members doc

3 years agoMerge #7036
bors[bot] [Fri, 25 Dec 2020 10:25:58 +0000 (10:25 +0000)]
Merge #7036

7036: Don't split path separators apart in doctest runnables r=Veykril a=Veykril

Fixes #7035

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoDon't split path separators apart in doctest runnables
Lukas Wirth [Fri, 25 Dec 2020 10:22:11 +0000 (11:22 +0100)]
Don't split path separators apart in doctest runnables

3 years agoMerge #7032
bors[bot] [Thu, 24 Dec 2020 16:38:10 +0000 (16:38 +0000)]
Merge #7032

7032: Simplify more r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoSimplify more
Aleksey Kladov [Thu, 24 Dec 2020 16:36:13 +0000 (19:36 +0300)]
Simplify more

3 years agoMerge #7031
bors[bot] [Thu, 24 Dec 2020 15:06:38 +0000 (15:06 +0000)]
Merge #7031

7031: Simplify r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoSimplify
Aleksey Kladov [Thu, 24 Dec 2020 14:54:44 +0000 (17:54 +0300)]
Simplify

3 years agoMerge #7030
bors[bot] [Thu, 24 Dec 2020 14:46:41 +0000 (14:46 +0000)]
Merge #7030

7030: Support labels in reference search r=matklad a=Veykril

Implements general navigation for labels, goto def, rename and gives labels their own semantic highlighting class.

Fixes #6966

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoSupport labels in reference search
Lukas Wirth [Wed, 23 Dec 2020 16:15:01 +0000 (17:15 +0100)]
Support labels in reference search

3 years agoMerge #7029
bors[bot] [Thu, 24 Dec 2020 13:40:29 +0000 (13:40 +0000)]
Merge #7029

7029: Flush stdout when clearing the progress bar r=lnicola a=lnicola

To prevent this from happening:

```
Database loaded 496.24ms, 288mi
Crates in this dir: 1
Total modules found: 14
Total declarations: 159
Total functions: 122
Item Collection: 6.02s, 61846mi
122/122 100% processing: archive::sizeTotal expressions: 6592
Expressions of unknown type: 4 (0%)
Expressions of partially unknown type: 104 (1%)
Type mismatches: 3
Inference: 1.03s, 8622mi
Total: 7.05s, 70468mi
```

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
3 years agoFlush stdout when clearing the progress bar
Laurențiu Nicola [Thu, 24 Dec 2020 13:38:40 +0000 (15:38 +0200)]
Flush stdout when clearing the progress bar

3 years agoMerge #7028
bors[bot] [Thu, 24 Dec 2020 12:50:30 +0000 (12:50 +0000)]
Merge #7028

7028: pit-of-success API for unresolved code actions r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agopit-of-success API for unresolved code actions
Aleksey Kladov [Thu, 24 Dec 2020 12:32:29 +0000 (15:32 +0300)]
pit-of-success API for unresolved code actions

3 years agoMerge #7021
bors[bot] [Thu, 24 Dec 2020 12:04:28 +0000 (12:04 +0000)]
Merge #7021

7021: Track labels in the HIR r=matklad a=Veykril

Groundwork for #6966

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoTrack labels in the HIR
Lukas Wirth [Wed, 23 Dec 2020 15:34:30 +0000 (16:34 +0100)]
Track labels in the HIR

3 years agoMerge #7027
bors[bot] [Thu, 24 Dec 2020 08:44:52 +0000 (08:44 +0000)]
Merge #7027

7027: Fix macro_rules not accepting brackets or parentheses r=matklad,lnicola a=Veykril

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoFix macro_rules not accepting brackets or parentheses
Lukas Wirth [Thu, 24 Dec 2020 08:26:03 +0000 (09:26 +0100)]
Fix macro_rules not accepting brackets or parentheses

3 years agoMerge #7026
bors[bot] [Thu, 24 Dec 2020 06:29:02 +0000 (06:29 +0000)]
Merge #7026

7026: chore: update coc-rust-analyzer inlay hints support r=lnicola a=fannheyward

coc-rust-analyzer now supports inlay hints for variables and method chaining.

Co-authored-by: Heyward Fann <fannheyward@users.noreply.github.com>
3 years agoUpdate manual.adoc
Heyward Fann [Thu, 24 Dec 2020 03:38:01 +0000 (11:38 +0800)]
Update manual.adoc

3 years agoMerge #7020
bors[bot] [Wed, 23 Dec 2020 19:50:04 +0000 (19:50 +0000)]
Merge #7020

7020: Implement const pat and expr inference r=flodiebold a=Veykril

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoMerge #7022
bors[bot] [Wed, 23 Dec 2020 19:44:27 +0000 (19:44 +0000)]
Merge #7022

7022: Prevent multiple incorrect case diagnostics in functions r=lnicola a=unexge

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/6970

Co-authored-by: unexge <unexge@gmail.com>
3 years agoPrevent multiple incorrect case diagnostics in functions
unexge [Wed, 23 Dec 2020 19:18:31 +0000 (22:18 +0300)]
Prevent multiple incorrect case diagnostics in functions

3 years agoMerge #7009
bors[bot] [Wed, 23 Dec 2020 12:55:25 +0000 (12:55 +0000)]
Merge #7009

7009: Implement workspace/willRenameFiles for single-level file moves r=matklad a=kjeremy

Automatically rename modules during file rename if they're in the same directory.

Fixes #6780

Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
3 years agoImplement workspace/willRenameFiles for single-level file moves
Jeremy Kolb [Tue, 22 Dec 2020 19:19:51 +0000 (14:19 -0500)]
Implement workspace/willRenameFiles for single-level file moves

Renames modules during file rename if they're in the same directory.

3 years agoMerge #7019
bors[bot] [Wed, 23 Dec 2020 12:04:32 +0000 (12:04 +0000)]
Merge #7019

7019: Try serde_path_to_error for LSP InitializeParams r=matklad a=lnicola

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
3 years agoImplement const block inference
Lukas Wirth [Wed, 23 Dec 2020 11:24:24 +0000 (12:24 +0100)]
Implement const block inference

3 years agoTry serde_path_to_error for LSP InitializeParams
Laurențiu Nicola [Wed, 23 Dec 2020 11:21:58 +0000 (13:21 +0200)]
Try serde_path_to_error for LSP InitializeParams

3 years agoImplement const pat inference
Lukas Wirth [Wed, 23 Dec 2020 11:15:38 +0000 (12:15 +0100)]
Implement const pat inference

3 years agoMerge #7016
bors[bot] [Wed, 23 Dec 2020 11:04:07 +0000 (11:04 +0000)]
Merge #7016

7016: Bump deps r=flodiebold a=lnicola

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
3 years agoBump deps
Laurențiu Nicola [Wed, 23 Dec 2020 09:46:36 +0000 (11:46 +0200)]
Bump deps

3 years agoBump chalk
Laurențiu Nicola [Wed, 23 Dec 2020 09:41:03 +0000 (11:41 +0200)]
Bump chalk

3 years agoMerge #7018
bors[bot] [Wed, 23 Dec 2020 10:51:56 +0000 (10:51 +0000)]
Merge #7018

7018: Cleanup handle_code_action r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoMake code more direct
Aleksey Kladov [Wed, 23 Dec 2020 10:36:57 +0000 (13:36 +0300)]
Make code more direct

* Push control flow outwards, as per
  https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/dev/style.md#preconditions

* Don't re-do the work, pass-in the arguments

3 years agoMerge #7010
bors[bot] [Wed, 23 Dec 2020 10:37:30 +0000 (10:37 +0000)]
Merge #7010

7010: Update ungrammar for const block patterns r=matklad a=Veykril

Fixes #6848

Adds const blocks and const block patterns to the AST and parses them.

Blocked on https://github.com/rust-analyzer/ungrammar/pull/17/, will merge that PR there once this one gets the OK so I can remove the local ungrammar dependency path and fix the Cargo.lock.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoRemove local ungrammar dependency
Lukas Wirth [Wed, 23 Dec 2020 10:22:36 +0000 (11:22 +0100)]
Remove local ungrammar dependency