]> git.lizzy.rs Git - rust.git/log
rust.git
2 years ago# This is a combination of 3 commits.
Anatol Ulrich [Tue, 14 Sep 2021 02:01:21 +0000 (04:01 +0200)]
# This is a combination of 3 commits.
# This is the 1st commit message:

add multi-token mappings for hover

# The commit message #2 will be skipped:

# make fallback an Option instead of vec

# The commit message #3 will be skipped:

# fix indentation

2 years agoMerge #10199
bors[bot] [Mon, 13 Sep 2021 18:14:20 +0000 (18:14 +0000)]
Merge #10199

10199: fix: Fix Cargo.toml change detection r=lnicola a=lnicola

Maybe fixes #9546

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoShuffle code around to avoid an allocation
Laurențiu Nicola [Mon, 13 Sep 2021 17:58:09 +0000 (20:58 +0300)]
Shuffle code around to avoid an allocation

2 years agoMerge #10225
bors[bot] [Mon, 13 Sep 2021 17:07:23 +0000 (17:07 +0000)]
Merge #10225

10225: internal: Add proc-macro fixture directive r=Veykril a=Veykril

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoMerge #10226
bors[bot] [Mon, 13 Sep 2021 16:51:37 +0000 (16:51 +0000)]
Merge #10226

10226: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoSimplify
Lukas Wirth [Mon, 13 Sep 2021 16:50:19 +0000 (18:50 +0200)]
Simplify

2 years agoAdd proc-macro fixture directive
Lukas Wirth [Mon, 13 Sep 2021 16:30:04 +0000 (18:30 +0200)]
Add proc-macro fixture directive

2 years agoFix Cargo.toml change detection
Laurențiu Nicola [Fri, 10 Sep 2021 16:34:47 +0000 (19:34 +0300)]
Fix Cargo.toml change detection

2 years agoMerge #10222
bors[bot] [Mon, 13 Sep 2021 11:52:29 +0000 (11:52 +0000)]
Merge #10222

10222: internal: Add workaround for rename error reporting r=lnicola a=lnicola

Fixes #9875

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoAdd workaround for rename error reporting
Laurențiu Nicola [Mon, 13 Sep 2021 11:46:29 +0000 (14:46 +0300)]
Add workaround for rename error reporting

2 years agoMerge #10221
bors[bot] [Mon, 13 Sep 2021 11:23:43 +0000 (11:23 +0000)]
Merge #10221

10221: internal: prevent possible bugs when adding magical comments r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agointernal: document tribal knowledge of how to assist
Aleksey Kladov [Mon, 13 Sep 2021 11:19:10 +0000 (14:19 +0300)]
internal: document tribal knowledge of how to assist

2 years agointernal: prevent possible bugs when adding magical comments
Aleksey Kladov [Mon, 13 Sep 2021 10:43:13 +0000 (13:43 +0300)]
internal: prevent possible bugs when adding magical comments

2 years agointernal: simplify
Aleksey Kladov [Mon, 13 Sep 2021 10:35:31 +0000 (13:35 +0300)]
internal: simplify

2 years agointernal: fix bugs in tests by simplifying code
Aleksey Kladov [Mon, 13 Sep 2021 10:28:00 +0000 (13:28 +0300)]
internal: fix bugs in tests by simplifying code

2 years agominore: improve readability
Aleksey Kladov [Mon, 13 Sep 2021 09:34:05 +0000 (12:34 +0300)]
minore: improve readability

Tuples are hard to understand

2 years agoMerge #10218
bors[bot] [Mon, 13 Sep 2021 07:58:28 +0000 (07:58 +0000)]
Merge #10218

10218: minor: Don't spam the manual with warnings r=lnicola a=lnicola

A single warning on the first line should™ be enough. Currently we put that warning on every section, while also breaking the table of contents in the process:

![image](https://user-images.githubusercontent.com/308347/133045747-5232ce04-7856-40fd-a82f-adcefb7a6f5a.png)

Fixes #9657

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoDon't spam the manual with warnings
Laurențiu Nicola [Mon, 13 Sep 2021 07:56:14 +0000 (10:56 +0300)]
Don't spam the manual with warnings

2 years agoMerge #10215
bors[bot] [Sun, 12 Sep 2021 21:21:21 +0000 (21:21 +0000)]
Merge #10215

10215: Use correct file syntax node for decl_access computation in find_all_refs r=Veykril a=Veykril

Defs and refs of locals only ever life in one file, this isn't true for fields though.
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10201

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoUse correct file syntax node for decl_access computation in find_all_refs
Lukas Wirth [Sun, 12 Sep 2021 21:12:08 +0000 (23:12 +0200)]
Use correct file syntax node for decl_access computation in find_all_refs

2 years agoMerge #10213
bors[bot] [Sun, 12 Sep 2021 12:23:56 +0000 (12:23 +0000)]
Merge #10213

10213: minor: Improve resilience of match checking r=flodiebold a=iDawer

In bug condition the match checking strives to recover giving false no-error diagnostic.

Suggested in https://github.com/rust-analyzer/rust-analyzer/pull/9105#discussion_r644656085

Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
2 years agoImprove resilience of match checking
Dawer [Sun, 12 Sep 2021 11:03:12 +0000 (16:03 +0500)]
Improve resilience of match checking

In bug condition the match checking strives to recover giving false no-error diagnostic.

2 years agoMerge #10212
bors[bot] [Sun, 12 Sep 2021 08:55:17 +0000 (08:55 +0000)]
Merge #10212

10212: fix: Avoid type inference panic on bitslice methods r=flodiebold a=flodiebold

Should fix #10090, fix #10046, and fix #10179.
This is only a workaround, but the proper fix requires some bigger
refactoring (also related to fixing #10058), and this at least prevents
the crash.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2 years agoAvoid type inference panic on bitslice methods
Florian Diebold [Sun, 12 Sep 2021 08:41:30 +0000 (10:41 +0200)]
Avoid type inference panic on bitslice methods

Should fix #10090, #10046, #10179.
This is only a workaround, but the proper fix requires some bigger
refactoring (also related to fixing #10058), and this at least prevents
the crash.

2 years agoMerge #10202
bors[bot] [Sun, 12 Sep 2021 07:54:56 +0000 (07:54 +0000)]
Merge #10202

10202: fix: Type param hover shows correct sized bounds. r=flodiebold a=iDawer

Closes  #9949

This adds implicit `: Sized` bound to type parameters at lowering step.

Hovering on type parameter does not show it's `: Sized` bound be it set explicitly or implicitly. This is because it doesn't track that the bound was set implicitly.

### Perf

```rust
./target/rust-analyzer-baseline-3dae94bf -q analysis-stats --memory-usage .
Database loaded:     4.51s, 311minstr, 110mb (metadata 1.08s, 22minstr, 743kb; build 3.20s, 8730kinstr, -237kb)
  crates: 38, mods: 770, decls: 17173, fns: 12835
Item Collection:     29.63s, 85ginstr, 372mb
  exprs: 353460, ??ty: 364 (0%), ?ty: 232 (0%), !ty: 144
Inference:           118.25s, 284ginstr, 601mb
Total:               147.88s, 370ginstr, 973mb

./target/rust-analyzer-hover-ty-param-dfb15292 -q analysis-stats --memory-usage .
Database loaded:     4.53s, 311minstr, 110mb (metadata 1.10s, 22minstr, 743kb; build 3.20s, 8672kinstr, -189kb)
  crates: 38, mods: 770, decls: 17173, fns: 12835
Item Collection:     29.59s, 85ginstr, 372mb
  exprs: 353460, ??ty: 364 (0%), ?ty: 232 (0%), !ty: 144
Inference:           121.69s, 296ginstr, 601mb
Total:               151.28s, 382ginstr, 974mb

```

Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
2 years agoMerge #10210
bors[bot] [Sat, 11 Sep 2021 17:49:55 +0000 (17:49 +0000)]
Merge #10210

10210: minor: make code clearer with ControlFlow r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agominor: make code clearer with ControlFlow
Aleksey Kladov [Sat, 11 Sep 2021 17:49:10 +0000 (20:49 +0300)]
minor: make code clearer with ControlFlow

2 years agoMerge #10207
bors[bot] [Sat, 11 Sep 2021 15:46:36 +0000 (15:46 +0000)]
Merge #10207

10207: minor: improve readability r=matklad a=matklad

It's important that module interface doesn't depend on features. Better
hide features in bodies.

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agominor: improve readability
Aleksey Kladov [Sat, 11 Sep 2021 15:42:38 +0000 (18:42 +0300)]
minor: improve readability

It's important that module interface doesn't depend on features. Better
hide features in bodies.

2 years agoMerge #10206
bors[bot] [Sat, 11 Sep 2021 15:40:04 +0000 (15:40 +0000)]
Merge #10206

10206: internal: Remove unused dependencies r=lnicola a=gilescope

cargo check --all-targets compiles cleanly without these dependencies for me.

Co-authored-by: Giles Cope <gilescope@gmail.com>
2 years agoremoving seemingly unused dev deps.
Giles Cope [Sat, 11 Sep 2021 15:26:36 +0000 (16:26 +0100)]
removing seemingly unused dev deps.

2 years agoremove unused deps
Giles Cope [Sat, 11 Sep 2021 15:20:04 +0000 (16:20 +0100)]
remove unused deps

2 years agominor: fix tests.
Dawer [Fri, 10 Sep 2021 18:02:37 +0000 (23:02 +0500)]
minor: fix tests.

2 years agofix: Type param hover shows correct sized bounds.
Dawer [Fri, 10 Sep 2021 15:48:39 +0000 (20:48 +0500)]
fix: Type param hover shows correct sized bounds.

2 years agointernal: add implicit `: Sized` bound to type parameters.
Dawer [Tue, 7 Sep 2021 07:36:15 +0000 (12:36 +0500)]
internal: add implicit `: Sized` bound to type parameters.

2 years agoMerge #10177
bors[bot] [Fri, 10 Sep 2021 14:14:02 +0000 (14:14 +0000)]
Merge #10177

10177: fix: Treat path dependencies like workspace members r=jonas-schievink a=jonas-schievink

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

Fixes diagnostics not showing up in path dependencies.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2 years agoMerge #10193
bors[bot] [Thu, 9 Sep 2021 19:34:39 +0000 (19:34 +0000)]
Merge #10193

10193: fix: fix type mismatches with `panic!()` on Rust 1.55.0 r=jonas-schievink a=jonas-schievink

This addresses the regression mentioned in https://github.com/rust-analyzer/rust-analyzer/issues/8961#issuecomment-916332702

(no test because https://github.com/rust-analyzer/rust-analyzer/issues/10192 makes that rather hard, but I've checked that the analysis-stats are back to normal)

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2 years agoSupport the new `rustc_builtin_macro` syntax
Jonas Schievink [Thu, 9 Sep 2021 19:32:41 +0000 (21:32 +0200)]
Support the new `rustc_builtin_macro` syntax

2 years agoMerge #10190
bors[bot] [Thu, 9 Sep 2021 18:13:26 +0000 (18:13 +0000)]
Merge #10190

10190: minor: Bump deps r=lnicola a=lnicola

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoBump chalk
Laurențiu Nicola [Thu, 9 Sep 2021 18:12:38 +0000 (21:12 +0300)]
Bump chalk

2 years agoBump deps
Laurențiu Nicola [Thu, 9 Sep 2021 18:09:57 +0000 (21:09 +0300)]
Bump deps

2 years agoMerge #10188
bors[bot] [Thu, 9 Sep 2021 15:07:43 +0000 (15:07 +0000)]
Merge #10188

10188: fix: add multi-token mapping support to runnables r=jonas-schievink a=lnicola

Closes #10184

changelog fix (first contribution) add multi-token mapping support to runnables

Co-authored-by: Anatol Ulrich <anatol.ulrich@ferrous-systems.com>
2 years agoimplement #10070 in runnables
Anatol Ulrich [Thu, 9 Sep 2021 00:16:08 +0000 (02:16 +0200)]
implement #10070 in runnables

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2 years agoMerge #10186
bors[bot] [Thu, 9 Sep 2021 08:56:33 +0000 (08:56 +0000)]
Merge #10186

10186: configure colorizedBracketPairs r=matklad a=IceSentry

The new bracket pair colorization feature of vscode colorizes all brackets no matter the language. In the context of rust colorizing the '<' and  '>' brackets doesn't make sense most of the time, especially in match statements with math like the following screenshot.

![image](https://user-images.githubusercontent.com/8348954/132622418-2edb7580-dc72-42df-894d-682d2882c7e3.png)

Currently this configuration is only possible on a language server level which is why this PR is necessary.

See https://github.com/microsoft/vscode/issues/132175 and https://github.com/microsoft/vscode/issues/132476 for more information on the issue in vscode

Co-authored-by: IceSentry <c.giguere42@gmail.com>
2 years agoconfigure colorizedBracketPairs
IceSentry [Thu, 9 Sep 2021 04:25:38 +0000 (00:25 -0400)]
configure colorizedBracketPairs

2 years agoMerge #10185
bors[bot] [Thu, 9 Sep 2021 00:23:00 +0000 (00:23 +0000)]
Merge #10185

10185: minor: include `ImplLoc` in panic context r=jonas-schievink a=jonas-schievink

cc https://github.com/rust-analyzer/rust-analyzer/issues/10084

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2 years agominor: include `ImplLoc` in panic context
Jonas Schievink [Thu, 9 Sep 2021 00:20:55 +0000 (02:20 +0200)]
minor: include `ImplLoc` in panic context

2 years agoMerge #10093
bors[bot] [Wed, 8 Sep 2021 22:34:59 +0000 (22:34 +0000)]
Merge #10093

10093: fix: Remove incorrectly filtering VS Code cargo task execution resolution by scope r=oeed a=oeed

This fixes #9093 ​introduced by #8995.

A filter was present on the function that adds the execution definition to Cargo tasks. This would mean Cargo tasks defined in workspaces (i.e. `.code-workspace` files) would not be given an execution, leading to a `There is no task provider registered for tasks of type "cargo".` error as descibed in #9093. I have made a minimum reproduction setup [here](https://github.com/oeed/ra-workspace).

This PR essentially removes that check. The `if (scope) { ... }` is to handle the case where `task.scope === undefined` using a deprecated constructor. I'm not sure if that is ever likely to occur and can remove if not needed.

There is some discussion about whether it's necessary to filter the tasks before building them. From my understanding, it shouldn't be needed as we should provide an execution for all `cargo` tasks; but I'm not overly familiar with VS Code internals so I could be wrong. For more info please see [the discussion](https://github.com/rust-analyzer/rust-analyzer/pull/8995#issuecomment-908920395) on #8995

Co-authored-by: Oliver Cooper <oliver.cooper@me.com>
2 years agoUndefined scope comment
Oliver Cooper [Wed, 8 Sep 2021 20:50:24 +0000 (08:50 +1200)]
Undefined scope comment

2 years agoMerge #10174
bors[bot] [Wed, 8 Sep 2021 14:40:54 +0000 (14:40 +0000)]
Merge #10174

10174: fix: path display error when start with `crate` r=flodiebold a=dzvon

Fixes  #10172

Co-authored-by: Dezhi Wu <wu543065657@163.com>
2 years agoMerge #10180
bors[bot] [Wed, 8 Sep 2021 12:46:34 +0000 (12:46 +0000)]
Merge #10180

10180: Fix resolution for inherent array methods r=flodiebold a=yotamofek

My second attempt at fixing #9992 , previous attempt was here: #10017 , but the logic was broken.

I know that this is not an ideal solution.... that would require, IIUC, a pretty big overhaul of the const generics handling in `rust-analyzer`. But, given that some of the array methods were/are being stabilized (e.g. https://github.com/rust-lang/rust/pull/87174 ), I think it'll be very beneficial to `rust-analyzer` users to have some preliminary support for them. (I know it's something I've been running into quite a lot lately :) )

As far as my limited understanding of this project's architecture goes, I think this isn't the worst hack in the world, and shouldn't be too much of a hassle to undo if/when const generics become better supported. If the maintainers deem this approach viable, I'll want to add some comments, emphasizing the purpose of this code, and that it should be removed at some point in the future.

Co-authored-by: Yotam Ofek <yotam.ofek@gmail.com>
2 years agoSplit and document array method resolution logic.
Yotam Ofek [Wed, 8 Sep 2021 10:15:40 +0000 (13:15 +0300)]
Split and document array method resolution logic.

2 years agoFix resolution of inherent array methods.
Yotam Ofek [Wed, 8 Sep 2021 08:13:29 +0000 (11:13 +0300)]
Fix resolution of inherent array methods.

2 years agoAdd (failing) test for inherent array method resolution.
Yotam Ofek [Wed, 8 Sep 2021 08:00:55 +0000 (11:00 +0300)]
Add (failing) test for inherent array method resolution.

2 years agoRemoved deprecated Task constructor
Oliver Cooper [Tue, 7 Sep 2021 22:46:31 +0000 (10:46 +1200)]
Removed deprecated Task constructor

2 years agoRename `is_member` to `is_local`
Jonas Schievink [Tue, 7 Sep 2021 15:29:58 +0000 (17:29 +0200)]
Rename `is_member` to `is_local`

2 years agoTreat path dependencies like workspace members
Jonas Schievink [Tue, 7 Sep 2021 15:26:21 +0000 (17:26 +0200)]
Treat path dependencies like workspace members

2 years agofix `super` path wrong display
Dezhi Wu [Tue, 7 Sep 2021 09:49:46 +0000 (17:49 +0800)]
fix `super` path wrong display

2 years agofix path wrong display
Dezhi Wu [Tue, 7 Sep 2021 08:54:02 +0000 (16:54 +0800)]
fix path wrong display

2 years agocargo fmt
Dezhi Wu [Tue, 7 Sep 2021 06:50:33 +0000 (14:50 +0800)]
cargo fmt

2 years agofix: path display error when start with `crate`
Dezhi Wu [Tue, 7 Sep 2021 06:44:30 +0000 (14:44 +0800)]
fix: path display error when start with `crate`

2 years agoMerge #10169
bors[bot] [Mon, 6 Sep 2021 15:55:34 +0000 (15:55 +0000)]
Merge #10169

10169: internal: parser cleanup r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agominor: modernize
Aleksey Kladov [Mon, 6 Sep 2021 15:42:07 +0000 (18:42 +0300)]
minor: modernize

2 years agoMerge #10168
bors[bot] [Mon, 6 Sep 2021 15:35:16 +0000 (15:35 +0000)]
Merge #10168

10168: internal: make name consistent with usage r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agointernal: make name consistent with usage
Aleksey Kladov [Mon, 6 Sep 2021 15:34:03 +0000 (18:34 +0300)]
internal: make name consistent with usage

2 years agoMerge #10167
bors[bot] [Mon, 6 Sep 2021 15:15:10 +0000 (15:15 +0000)]
Merge #10167

10167: minor: Avoid extra allocation in completion rendering r=lnicola a=lnicola

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoAvoid extra allocation in completion rendering
Laurențiu Nicola [Mon, 6 Sep 2021 14:55:07 +0000 (17:55 +0300)]
Avoid extra allocation in completion rendering

2 years agoMerge #10165
bors[bot] [Mon, 6 Sep 2021 14:37:32 +0000 (14:37 +0000)]
Merge #10165

10165: update to tracing-tree 0.1.10, which does not pull in syn r=matklad a=davidbarsky

I've updated tracing-tree to 0.1.10, which does not pull in syn and proc-macro2 (thanks for [the PR](https://github.com/davidbarsky/tracing-tree/pull/32), `@matklad!).`

It took a little bit more work than I expected to land https://github.com/davidbarsky/tracing-tree/issues/33, but I should get that done this week. However, I didn't want to keep y'all waiting, so here's _some_ of the changes that should hopefully improve your compile times.

Co-authored-by: David Barsky <me@davidbarsky.com>
2 years agoupdate to tracing-tree 0.1.10, which does not pull in syn.
David Barsky [Mon, 6 Sep 2021 14:33:08 +0000 (10:33 -0400)]
update to tracing-tree 0.1.10, which does not pull in syn.

2 years agoMerge #10164
bors[bot] [Mon, 6 Sep 2021 11:59:21 +0000 (11:59 +0000)]
Merge #10164

10164: docs: fix unknown configuration setting r=lnicola a=dzvon

Currently, the correct configuration of sysroot is `rust-analyzer.cargo.noSysroot (default: false)`.

Co-authored-by: Dezhi Wu <wu543065657@163.com>
2 years agodocs: fix unknown configuration setting
Dezhi Wu [Mon, 6 Sep 2021 11:57:17 +0000 (19:57 +0800)]
docs: fix unknown configuration setting

2 years agoMerge #10152
bors[bot] [Mon, 6 Sep 2021 10:54:18 +0000 (10:54 +0000)]
Merge #10152

10152: feat: Add completion for raw identifiers r=matklad a=nabakin

![rust_analyzer_pr](https://user-images.githubusercontent.com/894305/132110362-c21b713d-acaf-4a6d-9749-ff812172cbce.gif)
Adds support for valid Rust completion of raw identifiers.

Previously, code completion of fields made via raw identifiers would not re-insert those raw identifiers, resulting in invalid Rust code. Now, code completion of fields made via raw identifiers do re-insert those raw identifiers, resulting in valid Rust code.

The same is true for all code completion instances for fields and compatible Rust identifiers.

Co-authored-by: Blake Wyatt <894305+nabakin@users.noreply.github.com>
2 years agoMerge #10157
bors[bot] [Mon, 6 Sep 2021 10:46:06 +0000 (10:46 +0000)]
Merge #10157

10157: Add section on configuring compilation errors when using `rust-project.json` r=matklad a=dozzman

When using `rust-project.json` to specify the project workspace, flychecks are disabled. It is not mentioned that they can be re-enabled by specifying a custom checking command using the `checkOnSave.overrideCommand` configuration. This additional section makes it clear that using `rust-project.json` disables flychecks and how to enable them either using `cargo check` (as an example) or (more likely) a custom command which emits json error messages.

Further information can be found at this forum thread:

https://users.rust-lang.org/t/rust-analyzer-doesnt-show-cargo-check-compilation-errors-warnings-when-using-rust-project-json/64412

Co-authored-by: Dorian Peake <dozzman@hotmail.co.uk>
2 years agoMerge #10154
bors[bot] [Mon, 6 Sep 2021 10:38:41 +0000 (10:38 +0000)]
Merge #10154

10154: feat: Complete `#![recursion_limit = "N"]` instead of `#![recursion_limit = N]` r=lnicola a=hkmatsumoto

Currently ra emits `#![recursion_limit = 128]`, but this should rather be `#![recursion_limit = "128"]`

Co-authored-by: Hirochika Matsumoto <git@hkmatsumoto.com>
2 years agoMerge #10162
bors[bot] [Mon, 6 Sep 2021 09:20:29 +0000 (09:20 +0000)]
Merge #10162

10162: feat: enable completions inside macros after `.` r=jonas-schievink a=jonas-schievink

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/8158
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10039

This issue was not caused by us not being able to expand the macro (we can do that just fine). Instead, body lowering deliberately aborted lowering of a statement macro expansion when the expansion causes errors, citing some hygiene-related issue with recovery (`@edwin0cheng` if you remember what exactly the issue was I'd be happy to take a look).

Simply removing that code path doesn't cause any tests to fail, and makes completions in macros work better ("completion after `.`" is not the only thing that now works better, we also get better highlighting in incomplete macro calls).

Just to be sure, lets merge this after tomorrow's release.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2 years agoRecover from statement macro expansion errors
Jonas Schievink [Sun, 5 Sep 2021 22:16:12 +0000 (00:16 +0200)]
Recover from statement macro expansion errors

2 years agoMerge #10161
bors[bot] [Sun, 5 Sep 2021 19:37:17 +0000 (19:37 +0000)]
Merge #10161

10161: Don't dump `DefMap`s to build the panic context r=matklad a=matklad

internal: remove accidental code re-use
FragmentKind played two roles:

* entry point to the parser
* syntactic category of a macro call

These are different use-cases, and warrant different types. For example,
macro can't expand to visibility, but we have such fragment today.

This PR introduces `ExpandsTo` enum to separate this two use-cases.

I suspect we might further split `FragmentKind` into `$x:specifier` enum
specific to MBE, and a general parser entry point, but that's for
another PR!

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agointernal: remove accidental code re-use
Aleksey Kladov [Sun, 5 Sep 2021 19:30:06 +0000 (22:30 +0300)]
internal: remove accidental code re-use

FragmentKind played two roles:

* entry point to the parser
* syntactic category of a macro call

These are different use-cases, and warrant different types. For example,
macro can't expand to visibility, but we have such fragment today.

This PR introduces `ExpandsTo` enum to separate this two use-cases.

I suspect we might further split `FragmentKind` into `$x:specifier` enum
specific to MBE, and a general parser entry point, but that's for
another PR!

2 years agoMerge #10160
bors[bot] [Sun, 5 Sep 2021 18:43:25 +0000 (18:43 +0000)]
Merge #10160

10160: minor: Don't dump `DefMap`s to build the panic context r=jonas-schievink a=jonas-schievink

Fixes perf after https://github.com/rust-analyzer/rust-analyzer/pull/10159

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2 years agoDon't dump `DefMap`s to build the panic context
Jonas Schievink [Sun, 5 Sep 2021 18:42:22 +0000 (20:42 +0200)]
Don't dump `DefMap`s to build the panic context

2 years agoMerge #10159
bors[bot] [Sun, 5 Sep 2021 17:20:54 +0000 (17:20 +0000)]
Merge #10159

10159: Add panic info for `impl_trait`/`trait_data` r=jonas-schievink a=jonas-schievink

To debug https://github.com/rust-analyzer/rust-analyzer/issues/10084 further

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2 years agoAdd panic info for `impl_trait`/`trait_data`
Jonas Schievink [Sun, 5 Sep 2021 17:19:34 +0000 (19:19 +0200)]
Add panic info for `impl_trait`/`trait_data`

2 years agoMerge #10155
bors[bot] [Sun, 5 Sep 2021 16:57:46 +0000 (16:57 +0000)]
Merge #10155

10155: Minor: replace old name `CrateDefMap` in comments r=jonas-schievink a=toyboot4e

This PR replaces the old name `CrateDefMap` in comments with the new name `DefMap`. The renaming was done in [57a82fb0](https://github.com/rust-analyzer/rust-analyzer/commit/57a82fb0) (Jan 2021).

I didn't touch the working code ([CrateDefMapQueryQuery][QQ]). Thank you.

[QQ]: https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_db/src/apply_change.rs#L126

Co-authored-by: toyboot4e <toyboot4e@gmail.com>
2 years agoMerge #10158
bors[bot] [Sun, 5 Sep 2021 16:49:22 +0000 (16:49 +0000)]
Merge #10158

10158: Add crate name to nameres panic context r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2 years agoAdd crate name to nameres panic context
Jonas Schievink [Sun, 5 Sep 2021 16:48:34 +0000 (18:48 +0200)]
Add crate name to nameres panic context

2 years agoUpdate manual.adoc
Dorian Peake [Sun, 5 Sep 2021 15:59:38 +0000 (16:59 +0100)]
Update manual.adoc

2 years agoAdd rust-project.json + cargo check info to docs
Dorian Peake [Sun, 5 Sep 2021 15:32:05 +0000 (16:32 +0100)]
Add rust-project.json + cargo check info to docs

Add information about how to configure compilation errors/checks when using rust-project.json.

2 years agoMinor: replace old name `CrateDefMap`
toyboot4e [Sun, 5 Sep 2021 10:16:02 +0000 (19:16 +0900)]
Minor: replace old name `CrateDefMap`

2 years agoComplete `#![recursion_limit = "N"]` over `#![recursion_limit = N]`
Hirochika Matsumoto [Sun, 5 Sep 2021 08:57:11 +0000 (17:57 +0900)]
Complete `#![recursion_limit = "N"]` over `#![recursion_limit = N]`

2 years agoAdd completion for raw identifiers
Blake Wyatt [Sat, 4 Sep 2021 23:28:59 +0000 (19:28 -0400)]
Add completion for raw identifiers

2 years agoMerge #10148
bors[bot] [Sat, 4 Sep 2021 17:35:12 +0000 (17:35 +0000)]
Merge #10148

10148: docs: make dev docs more discoverable r=matklad a=matklad

I *think* people might try to debug ra by using only the troubleshooting
section. Might make sense to point them to dev docs then!

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agono need to reed the docs, feel free to charge ahead!
Aleksey Kladov [Sat, 4 Sep 2021 17:34:17 +0000 (20:34 +0300)]
no need to reed the docs, feel free to charge ahead!

But knowing where the docs are is useful ;)

2 years agodocs: make dev docs more discoverable
Aleksey Kladov [Sat, 4 Sep 2021 17:17:28 +0000 (20:17 +0300)]
docs: make dev docs more discoverable

I *think* people might try to debug ra by using only the troubleshooting
section. Might make sense to point them to dev docs then!

2 years agoMerge #10146
bors[bot] [Sat, 4 Sep 2021 14:04:30 +0000 (14:04 +0000)]
Merge #10146

10146: fix: use placeholder as default type in `Generate function` and `Extract into function`. r=matklad a=iDawer

Closes #10123

Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
2 years agoMerge #10147
bors[bot] [Sat, 4 Sep 2021 13:56:47 +0000 (13:56 +0000)]
Merge #10147

10147: fix: don't panic if the client sends invalid request r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agointernal: deduplicate
Aleksey Kladov [Sat, 4 Sep 2021 09:56:34 +0000 (12:56 +0300)]
internal: deduplicate

2 years agominor: update test
Dawer [Sat, 4 Sep 2021 10:19:44 +0000 (15:19 +0500)]
minor: update test

2 years agofix: don't panic if the client sends invalid request
Aleksey Kladov [Sat, 4 Sep 2021 09:27:27 +0000 (12:27 +0300)]
fix: don't panic if the client sends invalid request

2 years agofix: use placeholder as default type in `Extract into function`.
Dawer [Sat, 4 Sep 2021 09:21:14 +0000 (14:21 +0500)]
fix: use placeholder as default type in `Extract into function`.

2 years agofix: use placeholder as default type in `Generate function`.
Dawer [Sat, 4 Sep 2021 08:43:36 +0000 (13:43 +0500)]
fix: use placeholder as default type in `Generate function`.