]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoMerge #7135
bors[bot] [Sat, 2 Jan 2021 20:47:27 +0000 (20:47 +0000)]
Merge #7135

7135: Fix warnings on nightly r=lnicola a=cynecx

Co-authored-by: cynecx <me@cynecx.net>
3 years agoUse fully qualified `Itertools::intersperse` call to silence nightly warnings about...
cynecx [Sat, 2 Jan 2021 19:58:06 +0000 (20:58 +0100)]
Use fully qualified `Itertools::intersperse` call to silence nightly warnings about a potential name collision due to recent libstd api additions

3 years agoFix warnings on rust-nightly
cynecx [Sat, 2 Jan 2021 19:48:39 +0000 (20:48 +0100)]
Fix  warnings on rust-nightly

3 years agoMerge #7133
bors[bot] [Sat, 2 Jan 2021 17:42:45 +0000 (17:42 +0000)]
Merge #7133

7133: Proper handling $crate and local_inner_macros r=jonas-schievink a=edwin0cheng

This PR introduces `HygineFrames` to store the macro definition/call site hierarchy in hyginee and when resolving `local_inner_macros` and `$crate`, we use the token to look up the corresponding frame and return the correct value.

See also: https://rustc-dev-guide.rust-lang.org/macro-expansion.html#hygiene-and-hierarchies

fixe #6890 and  #6788

r? @jonas-schievink

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
3 years agoMerge #7130
bors[bot] [Sat, 2 Jan 2021 16:23:06 +0000 (16:23 +0000)]
Merge #7130

7130: Add extract_assignment assist r=Jesse-Bakker a=Jesse-Bakker

Add extract-assignment assist (#7006).

Assist is for now only implemented on if/match-statements where the assigment is the last statement in every block,
as for other cases, one would have to check whether the assignment has effects on the rest of the block and
extract a temporary variable for it in the block.

Co-authored-by: Jesse Bakker <github@jessebakker.com>
3 years agoAdd support for MatchExpr to extract_assigment assist
Jesse Bakker [Sat, 2 Jan 2021 14:33:23 +0000 (15:33 +0100)]
Add support for MatchExpr to extract_assigment assist

3 years agoAdd extract-assignment assist
Jesse Bakker [Sat, 2 Jan 2021 00:55:56 +0000 (01:55 +0100)]
Add extract-assignment assist

3 years agoUse arena instead of vec
Edwin Cheng [Sat, 2 Jan 2021 14:48:22 +0000 (22:48 +0800)]
Use arena instead of vec

3 years agoMerge #7134
bors[bot] [Sat, 2 Jan 2021 14:16:26 +0000 (14:16 +0000)]
Merge #7134

7134: Fix infer error of macro invocation in array expr r=edwin0cheng a=edwin0cheng

Fixed following infer error:

```rust
macro_rules! bar { () => {0u32} }
fn test() {
    let a = [bar!()];   // a : [unknown]
}
```

bors r+

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
3 years agoFix infer error of macro invocation in array expr
Edwin Cheng [Sat, 2 Jan 2021 14:06:59 +0000 (22:06 +0800)]
Fix infer error of macro invocation in array expr

3 years agoIntroduce HygieneFrames for proper token hyginee
Edwin Cheng [Sat, 2 Jan 2021 12:25:05 +0000 (20:25 +0800)]
Introduce HygieneFrames for proper token hyginee

3 years agoMerge #7132
bors[bot] [Sat, 2 Jan 2021 07:52:30 +0000 (07:52 +0000)]
Merge #7132

7132: Stop using beta toolchain in xtask dist r=lnicola a=lnicola

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
3 years agoStop using beta toolchain in xtask dist
Laurențiu Nicola [Sat, 2 Jan 2021 07:51:41 +0000 (09:51 +0200)]
Stop using beta toolchain in xtask dist

3 years agoMerge #7125
bors[bot] [Fri, 1 Jan 2021 19:50:02 +0000 (19:50 +0000)]
Merge #7125

7125: Don't emit arg count diagnostics for method calls with unknown receiver r=flodiebold a=flodiebold

Fixes #7098.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
3 years agoDon't emit arg count diagnostics for method calls with unknown receiver
Florian Diebold [Fri, 1 Jan 2021 19:45:49 +0000 (20:45 +0100)]
Don't emit arg count diagnostics for method calls with unknown receiver

Fixes #7098.

3 years agoMerge #7123
bors[bot] [Fri, 1 Jan 2021 16:33:45 +0000 (16:33 +0000)]
Merge #7123

7123: Add support for Rust 2021. r=lnicola a=m-ou-se

This adds `2021` in all places where rust-analyzer already knew about `2015` and `2018`.

The only edition-specific behaviour I could find in the source code was gated on a direct comparison with `Edition2015`, so `Edition2021` should (correctly) behave the same as `Edition2018`:

https://github.com/rust-analyzer/rust-analyzer/blob/56a7bf7ede12f6bec194265ea4a95911c9e469bd/crates/hir_def/src/nameres/path_resolution.rs#L132

Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
3 years agoFormatting.
Mara Bos [Fri, 1 Jan 2021 16:31:32 +0000 (17:31 +0100)]
Formatting.

3 years agoAdd support for Rust 2021.
Mara Bos [Fri, 1 Jan 2021 16:22:23 +0000 (17:22 +0100)]
Add support for Rust 2021.

3 years agoMerge #7121
bors[bot] [Fri, 1 Jan 2021 14:20:51 +0000 (14:20 +0000)]
Merge #7121

7121: Show lifetimes and labels on hover r=Veykril a=Veykril

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoShow lifetimes and labels on hover
Lukas Wirth [Fri, 1 Jan 2021 14:07:41 +0000 (15:07 +0100)]
Show lifetimes and labels on hover

3 years agoMerge #7080
bors[bot] [Fri, 1 Jan 2021 13:45:10 +0000 (13:45 +0000)]
Merge #7080

7080: Implement ConstParams for HIR r=Veykril a=Veykril

r? @flodiebold

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoAdd ConstParams to the ide layer
Lukas Wirth [Fri, 1 Jan 2021 09:07:01 +0000 (10:07 +0100)]
Add ConstParams to the ide layer

3 years agoMerge #7116
bors[bot] [Fri, 1 Jan 2021 11:06:27 +0000 (11:06 +0000)]
Merge #7116

7116: Fix deep syntax tree bug generated by proc-macro r=jonas-schievink a=edwin0cheng

This PR fixed a bug from `semver-parser` and `pest_derive` crates which generate a very deep syntax tree such that serde reject to de-serialize. To fix this bug, we disabled recursion limit in `serde` (by calling [`Deserializer::disable_recursion_limit`](https://docs.rs/serde_json/1.0.61/serde_json/struct.Deserializer.html#method.disable_recursion_limit))

I have a feeling that we still need some way to protect against bad proc-macro generating huge syntax node, but I have no  idea right now.

r? @jonas-schievink

Fixes #7103

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
3 years agoAdd ConstParams to the HIR
Lukas Wirth [Fri, 1 Jan 2021 09:06:42 +0000 (10:06 +0100)]
Add ConstParams to the HIR

3 years agoMerge #7117
bors[bot] [Fri, 1 Jan 2021 07:45:19 +0000 (07:45 +0000)]
Merge #7117

7117: Use stable instead of beta on macos-11 release runner r=lnicola a=lnicola

Because beta was promoted to stable yesterday.

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
3 years agoUse stable instead of beta on macos-11 release runner
Laurențiu Nicola [Fri, 1 Jan 2021 07:44:01 +0000 (09:44 +0200)]
Use stable instead of beta on macos-11 release runner

3 years agoRemove serde_stacker which depends on cc
Edwin Cheng [Fri, 1 Jan 2021 07:26:55 +0000 (15:26 +0800)]
Remove serde_stacker which depends on cc

3 years agoFix deep syntax tree bug generated by proc-macro
Edwin Cheng [Fri, 1 Jan 2021 07:09:27 +0000 (15:09 +0800)]
Fix deep syntax tree bug generated by proc-macro

3 years agoMerge #7102
bors[bot] [Fri, 1 Jan 2021 00:32:59 +0000 (00:32 +0000)]
Merge #7102

7102: Fix completion of Default struct update syntax r=Veykril a=nick96

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.

I think there's probably a better way to implement this context aware completion because I've seen it in other parts of rust-analyzer as a user but I'm not sure how to do it.

Fixes #6969

Co-authored-by: Nick Spain <nicholas.spain@stileeducation.com>
3 years agoStrip completion prefix of what has already been typed
Nick Spain [Fri, 1 Jan 2021 00:17:15 +0000 (11:17 +1100)]
Strip completion prefix of what has already been typed

Per Veykril's suggestion, this removes the need to repeat the completion text twice. It also handles the completion
in a more general case.

3 years agoAdd a test for correct completion of ..Default::default()
Nick Spain [Fri, 1 Jan 2021 00:10:02 +0000 (11:10 +1100)]
Add a test for correct completion of ..Default::default()

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

7112: deny_clippy test works with cfg_attr r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agodeny_clippy test works with cfg_attr
Aleksey Kladov [Thu, 31 Dec 2020 22:58:04 +0000 (01:58 +0300)]
deny_clippy test works with cfg_attr

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 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