]> git.lizzy.rs Git - rust.git/log
rust.git
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`.

2 years agoMerge #10145
bors[bot] [Sat, 4 Sep 2021 07:29:50 +0000 (07:29 +0000)]
Merge #10145

10145: Update dependency minor versions
 r=lnicola a=lf-

bors r+
🤖

Co-authored-by: Jade <software@lfcode.ca>
2 years agoUpdate dependency minor versions
Jade [Sat, 4 Sep 2021 07:17:36 +0000 (00:17 -0700)]
Update dependency minor versions

2 years agoMerge #10139
bors[bot] [Fri, 3 Sep 2021 18:03:52 +0000 (18:03 +0000)]
Merge #10139

10139: Fix replacing for loops over ranges with for_each. r=yotamofek a=yotamofek

Previously, the assist would turn this:
```rust
for x in 0..92 {
    ...
}
```
into the syntactically incorrect code below:
```rust
0..92.for_each(|x| ...)
```

This fixes the assist by parenthesizing range expressions.

Co-authored-by: Yotam Ofek <yotam.ofek@gmail.com>
2 years agoUpdate crates/ide_assists/src/handlers/replace_for_loop_with_for_each.rs
Yotam Ofek [Fri, 3 Sep 2021 18:02:48 +0000 (21:02 +0300)]
Update crates/ide_assists/src/handlers/replace_for_loop_with_for_each.rs

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agoMerge #10130
bors[bot] [Fri, 3 Sep 2021 17:49:23 +0000 (17:49 +0000)]
Merge #10130

10130: fix error message for when DidChangeTextDocument path doesn't exist r=matklad a=alidn

Fixes #10129

Co-authored-by: Ali <59405723+alidn@users.noreply.github.com>
2 years agoFix replacing for loops over ranges with for_each.
Yotam Ofek [Fri, 3 Sep 2021 16:43:40 +0000 (19:43 +0300)]
Fix replacing for loops over ranges with for_each.

2 years agoMerge #10135
bors[bot] [Fri, 3 Sep 2021 14:28:27 +0000 (14:28 +0000)]
Merge #10135

10135: minor: fix some clippy lints r=lnicola a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agominor: fix some clippy lints
Lukas Wirth [Fri, 3 Sep 2021 14:00:50 +0000 (16:00 +0200)]
minor: fix some clippy lints

2 years agoMerge #10132
bors[bot] [Fri, 3 Sep 2021 09:25:29 +0000 (09:25 +0000)]
Merge #10132

10132: docs(logging): use `tracing` for logging r=matklad a=dzvon

Currently, we're using `tracing` for logging, but the doc is lagging, so update it.

#9274

Co-authored-by: Dezhi Wu <wu543065657@163.com>
2 years agodocs(logging): use `tracing` for logging
Dezhi Wu [Fri, 3 Sep 2021 09:07:38 +0000 (17:07 +0800)]
docs(logging): use `tracing` for logging

2 years agofix error message for when DidChangeTextDocument path doesn't exist
Ali [Thu, 2 Sep 2021 22:19:47 +0000 (15:19 -0700)]
fix error message for when DidChangeTextDocument path doesn't exist

2 years agoMerge #10127
bors[bot] [Thu, 2 Sep 2021 17:14:23 +0000 (17:14 +0000)]
Merge #10127

10127: fix: When descending tokens don't bail on failed macro call expansions r=Veykril a=Veykril

(with `#[test]` expansion enabled)
![image](https://user-images.githubusercontent.com/3757771/131887786-ced9988b-80fa-4e8f-b114-337572950cc3.png)

The problem was pretty simple, since we go through the ancestors we first try to expand the macro call node we are in since in attributed items these are valid syntaxnodes instead of TokenTrees, we then fail the expansion since the expansion only exists in the attribute expanded file and therefor skip the attribute expansion due to returning immediately. So instead of breaking out we just continue looking up the ancestors.

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10115
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoWhen descending tokens don't bail on failed macro call expansions
Lukas Wirth [Thu, 2 Sep 2021 17:10:40 +0000 (19:10 +0200)]
When descending tokens don't bail on failed macro call expansions

2 years agoMerge #10124
bors[bot] [Thu, 2 Sep 2021 15:32:10 +0000 (15:32 +0000)]
Merge #10124

10124: fix: Use correct search scopes for macros r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoUse correct search scopes for macros
Lukas Wirth [Thu, 2 Sep 2021 15:30:02 +0000 (17:30 +0200)]
Use correct search scopes for macros

2 years agoMerge #10114
bors[bot] [Wed, 1 Sep 2021 19:53:10 +0000 (19:53 +0000)]
Merge #10114

10114: fix: Deduplicate imports for qualify_path r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoDeduplicate imports for qualify_path
Lukas Wirth [Wed, 1 Sep 2021 19:51:28 +0000 (21:51 +0200)]
Deduplicate imports for qualify_path

2 years agoMerge #10103
bors[bot] [Wed, 1 Sep 2021 17:21:05 +0000 (17:21 +0000)]
Merge #10103

10103: fix: make "find references" multi-token mapping aware r=jonas-schievink a=jonas-schievink

Part of https://github.com/rust-analyzer/rust-analyzer/issues/10070

I was hoping that this would fix "find references" on salsa queries, but salsa emits multiple defs sharing the same span (the trait method, and an impl of that trait).

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2 years agofix: multi-token mapping aware find references
Jonas Schievink [Wed, 1 Sep 2021 16:17:32 +0000 (18:17 +0200)]
fix: multi-token mapping aware find references

2 years agoMerge #10109
bors[bot] [Wed, 1 Sep 2021 14:17:47 +0000 (14:17 +0000)]
Merge #10109

10109: fix: Enable flyimport for ident patterns r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoEnable flyimport for ident patterns
Lukas Wirth [Wed, 1 Sep 2021 14:13:53 +0000 (16:13 +0200)]
Enable flyimport for ident patterns

2 years agoMerge #10108
bors[bot] [Wed, 1 Sep 2021 12:52:29 +0000 (12:52 +0000)]
Merge #10108

10108: fix: make `goto_implementation` multi-token mapping aware r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agofix: make `goto_implementation` multi-token mapping aware
Lukas Wirth [Wed, 1 Sep 2021 12:51:37 +0000 (14:51 +0200)]
fix: make `goto_implementation` multi-token mapping aware

2 years agoMerge #9954
bors[bot] [Wed, 1 Sep 2021 09:26:10 +0000 (09:26 +0000)]
Merge #9954

9954: feat: Show try operator propogated types on ranged hover  r=matklad a=Veykril

Basically this just shows the type of the inner expression of the `?` expression as well as the type of the expression that the `?` returns from:
![Code_wIrCxMqLH9](https://user-images.githubusercontent.com/3757771/130111025-f7ee0742-214a-493b-947a-b4a671e4be92.png)

Unless both of these types are `core::result::Result` in which case we show the error types only.
![Code_Xruw5FCBNI](https://user-images.githubusercontent.com/3757771/130111024-f9caef82-92e4-4070-b3dd-f2ff9e5d87a9.png)

If both types are `core::option::Option` with different type params we do not show this special hover either as it would be pointless(instead fallback to default type hover)

Very much open to changes to the hover text here(I suppose we also want to show the actual type of the `?` expression, that is its output type?).

Fixes #9931

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoMinor fixes
Lukas Wirth [Wed, 1 Sep 2021 09:25:42 +0000 (11:25 +0200)]
Minor fixes

2 years agoMerge #9405
bors[bot] [Wed, 1 Sep 2021 09:14:25 +0000 (09:14 +0000)]
Merge #9405

9405: Fix extract_function with macro arg r=Veykril a=sasurau4

## Overview

Fix #9266

Co-authored-by: Daiki Ihara <sasurau4@gmail.com>
2 years agoFix extract_function with macro arg
Daiki Ihara [Fri, 25 Jun 2021 13:14:42 +0000 (22:14 +0900)]
Fix extract_function with macro arg

2 years agoMerge #10101
bors[bot] [Tue, 31 Aug 2021 16:15:44 +0000 (16:15 +0000)]
Merge #10101

10101: internal: reduce coupling r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agointernal: reduce coupling
Aleksey Kladov [Tue, 31 Aug 2021 16:14:33 +0000 (19:14 +0300)]
internal: reduce coupling

tt is a data structure, data structures cant' go wrong, they shouldn't
have the knowledge that the world outside of them has all kinds of
errors.

2 years agoMerge #10100
bors[bot] [Tue, 31 Aug 2021 16:04:54 +0000 (16:04 +0000)]
Merge #10100

10100: internal: cleanup proc macro server error handlig r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agointernal: cleanup proc macro server error handlig
Aleksey Kladov [Tue, 31 Aug 2021 16:01:39 +0000 (19:01 +0300)]
internal: cleanup proc macro server error handlig

When dealing with proc macros, there are two very different kinds of
errors:

* first, usual errors of "proc macro panicked on this particular input"
* second, the proc macro server might day if the user, eg, kills it

First kind of errors are expected and are a normal output, while the
second kind are genuine IO-errors.

For this reason, we use a curious nested result here: `Result<Result<T,
E1>, E2>` pattern, which is 100% inspired by http://sled.rs/errors.html

2 years agoMerge #10099
bors[bot] [Tue, 31 Aug 2021 13:58:16 +0000 (13:58 +0000)]
Merge #10099

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

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agoMerge #10095
bors[bot] [Tue, 31 Aug 2021 12:47:33 +0000 (12:47 +0000)]
Merge #10095

10095: internal: Augment panic context when resolving path r=jonas-schievink a=jonas-schievink

Should help with debugging https://github.com/rust-analyzer/rust-analyzer/issues/10084 and similar issues.

Might have a perf impact since the string is created on every function call.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2 years agominor: improve readability
Aleksey Kladov [Tue, 31 Aug 2021 12:44:43 +0000 (15:44 +0300)]
minor: improve readability

naming, layout & comments help!

2 years agoMerge #10098
bors[bot] [Tue, 31 Aug 2021 12:27:27 +0000 (12:27 +0000)]
Merge #10098

10098: minor: dead code r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agominor: dead code
Aleksey Kladov [Tue, 31 Aug 2021 12:26:59 +0000 (15:26 +0300)]
minor: dead code

2 years agoMerge #10097
bors[bot] [Tue, 31 Aug 2021 12:17:50 +0000 (12:17 +0000)]
Merge #10097

10097: fix: Allow inherent impls for arrays r=jonas-schievink a=jonas-schievink

Part of https://github.com/rust-analyzer/rust-analyzer/issues/9992 (method resolution of these methods still does not work)

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2 years agoAllow inherent impl for arrays
Jonas Schievink [Tue, 31 Aug 2021 12:15:39 +0000 (14:15 +0200)]
Allow inherent impl for arrays

2 years agointernal: simplify
Aleksey Kladov [Tue, 31 Aug 2021 11:54:22 +0000 (14:54 +0300)]
internal: simplify

2 years agoAugment panic context when resolving path
Jonas Schievink [Tue, 31 Aug 2021 11:42:46 +0000 (13:42 +0200)]
Augment panic context when resolving path

2 years agoMerge #10094
bors[bot] [Tue, 31 Aug 2021 11:39:34 +0000 (11:39 +0000)]
Merge #10094

10094: internal: split database loading time in anaysis-stats into components r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agointernal: split database loading time in anaysis-stats into components
Aleksey Kladov [Tue, 31 Aug 2021 11:38:52 +0000 (14:38 +0300)]
internal: split database loading time in anaysis-stats into components

2 years agoMerge #10091
bors[bot] [Tue, 31 Aug 2021 11:24:30 +0000 (11:24 +0000)]
Merge #10091

10091: fix: fix "disjunction in conjunction" panic r=matklad a=jonas-schievink

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

The DNF construction code created expressions that were combined in a way that made us "forget" to make their contents valid DNF again. This PR fixes that by flattening nested `any(any())` and `all(all())` predicates. There was also a typo that led to a redundant call to `make_nnf` instead of the correct recursive call to `make_dnf` (but this didn't seem to break/fix anything).

This also adds some light property testing, though I'm not really sure this is the best way to do it.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2 years agoSimplify `int_in_range`
Jonas Schievink [Tue, 31 Aug 2021 11:11:17 +0000 (13:11 +0200)]
Simplify `int_in_range`

2 years agoDepend on both crates individually
Jonas Schievink [Tue, 31 Aug 2021 11:10:16 +0000 (13:10 +0200)]
Depend on both crates individually

2 years agoMerge #10092
bors[bot] [Tue, 31 Aug 2021 09:11:53 +0000 (09:11 +0000)]
Merge #10092

10092: feat: Improve `extract_struct_from_enum_variant` output r=matklad a=DropDemBits

Improves the struct generated by `extract_struct_from_enum_variant`.

Summary of changes:

- Indent the generated struct and enum to the same indent level
- Preserve comments & attributes from the enum variant (something I missed when doing the same thing for the variant fields)
- Use enum's visibility for fields without any visibility, instead of filling it in with `pub`

Co-authored-by: DropDemBits <r3usrlnd@gmail.com>
2 years agofeat: Use enum's visibility for extracted struct fields
DropDemBits [Tue, 31 Aug 2021 01:18:28 +0000 (21:18 -0400)]
feat: Use enum's visibility for extracted struct fields

2 years agofix: Keep comments & attrs from enum variant
DropDemBits [Tue, 31 Aug 2021 00:47:42 +0000 (20:47 -0400)]
fix: Keep comments & attrs from enum variant

2 years agofeat: Properly indent extracted struct and enum
DropDemBits [Mon, 30 Aug 2021 23:09:29 +0000 (19:09 -0400)]
feat: Properly indent extracted struct and enum

2 years agoFix DNF construction, add proptest
Jonas Schievink [Mon, 30 Aug 2021 20:26:35 +0000 (22:26 +0200)]
Fix DNF construction, add proptest

2 years agoMerge #10089
bors[bot] [Mon, 30 Aug 2021 19:35:00 +0000 (19:35 +0000)]
Merge #10089

10089: Fix minor mispelling r=bjorn3 a=NerdyPepper

`find_map` misspelt as `wind_map` in test identifier.

Co-authored-by: Akshay <nerdy@peppe.rs>
2 years agoMerge #10076
bors[bot] [Mon, 30 Aug 2021 18:55:18 +0000 (18:55 +0000)]
Merge #10076

10076: Use struct init shorthand when applicable in fill struct fields assist r=matklad a=nathanwhit

This PR tweaks the fill struct fields assist to use the struct init shorthand when a local variable with a matching name and type is in scope.

For example:
```rust
struct Foo {
    a: usize,
    b: i32,
    c: char,
}

fn main() {
    let a = 1;
    let b = 2;
    let c = 3;
    let foo = Foo { <|> };
}
```
Before we would insert
```rust
Foo {
    a: (),
    b: (),
    c: (),
}
```
now we would insert
```rust
Foo {
    a,
    b,
    c: ()
}
```

Co-authored-by: nathan.whitaker <nathan.whitaker01@gmail.com>
2 years agoAdd coverage mark for struct init shorthand test
nathan.whitaker [Mon, 30 Aug 2021 18:37:03 +0000 (14:37 -0400)]
Add coverage mark for struct init shorthand test

2 years agofix minor mispelling
Akshay [Mon, 30 Aug 2021 17:21:14 +0000 (22:51 +0530)]
fix minor mispelling

find_map misspelt as wind_map

2 years agoMerge #10088
bors[bot] [Mon, 30 Aug 2021 16:49:13 +0000 (16:49 +0000)]
Merge #10088

10088: feat: improve CPU usage r=matklad a=matklad

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agofeat: improve CPU usage
Aleksey Kladov [Mon, 30 Aug 2021 16:39:19 +0000 (19:39 +0300)]
feat: improve CPU usage

closes #9922

Turned out to be trivial after preliminary refactor.

The intended behavior is that we schedule cache priming once ws become
quiescent (that is, we fully load cargo project), and we continue to
rschedule it until it completes (priming might get cancelled by user
typing into a file).

2 years agointernal: make scheduling control flow more obvious
Aleksey Kladov [Mon, 30 Aug 2021 16:35:49 +0000 (19:35 +0300)]
internal: make scheduling control flow more obvious

There should be only one place where we need to check if we want to
start background activities.

2 years agointernal: improve consistency
Aleksey Kladov [Mon, 30 Aug 2021 16:24:31 +0000 (19:24 +0300)]
internal: improve consistency

Let's have only one place where we start delayed ops

2 years agointernal: more obviously correct code for cache priming progerss
Aleksey Kladov [Mon, 30 Aug 2021 16:18:48 +0000 (19:18 +0300)]
internal: more obviously correct code for cache priming progerss

It doesn't make sense for the prime_caches itself send begin/end events
-- the caller knows perfectly fine when they happen!

2 years agoMerge #10085
bors[bot] [Mon, 30 Aug 2021 12:57:39 +0000 (12:57 +0000)]
Merge #10085

10085: fix: avoid panic when parsing extern block r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agointernal: improve style
Aleksey Kladov [Mon, 30 Aug 2021 12:55:40 +0000 (15:55 +0300)]
internal: improve style

Group related stuff together, use only on path for parsing extern blocks
(they actually have modifiers).

Perhaps we should get rid of items_without_modifiers altogether? Better
to handle these kinds on diagnostics in validation layer...

2 years agofix: avoid panic when parsing extern block
Aleksey Kladov [Mon, 30 Aug 2021 12:40:47 +0000 (15:40 +0300)]
fix: avoid panic when parsing extern block

closes #10083

2 years agoMerge #10081
bors[bot] [Mon, 30 Aug 2021 09:50:16 +0000 (09:50 +0000)]
Merge #10081

10081: Fix error message r=lnicola a=digama0

I'm not entirely sure if the message is still correct, it seems to have survived a number of refactors, but it is mangled english anyway.

Co-authored-by: Mario Carneiro <di.gama@gmail.com>
2 years agofail -> failed
Mario Carneiro [Mon, 30 Aug 2021 09:47:10 +0000 (02:47 -0700)]
fail -> failed

2 years agoUpdate crates/hir_expand/src/db.rs
Mario Carneiro [Mon, 30 Aug 2021 09:43:13 +0000 (02:43 -0700)]
Update crates/hir_expand/src/db.rs

Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2 years agoFix error message
Mario Carneiro [Mon, 30 Aug 2021 09:36:21 +0000 (02:36 -0700)]
Fix error message

I'm not entirely sure if the message is still correct, it seems to have survived a number of refactors, but it is mangled english anyway.

2 years agoMerge #10005
bors[bot] [Mon, 30 Aug 2021 08:42:13 +0000 (08:42 +0000)]
Merge #10005

10005: Extend `CargoConfig.unset_test_crates`  r=matklad a=regexident

This is to allow for efficiently disabling `#[cfg(test)]` on all crates (by passing `unset_test_crates: UnsetTestCrates::All`) without having to first load the crate graph, when using rust-analyzer as a library.

(FYI: The change doesn't seem to be covered by any existing tests.)

Co-authored-by: Vincent Esche <regexident@gmail.com>
2 years agoMerge #10015
bors[bot] [Mon, 30 Aug 2021 08:34:49 +0000 (08:34 +0000)]
Merge #10015

10015: internal: more declarative re-indentation API r=matklad a=matklad

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agoMerge #10080
bors[bot] [Mon, 30 Aug 2021 07:58:59 +0000 (07:58 +0000)]
Merge #10080

10080: internal: don't shut up the compiler when it says the code's buggy r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agointernal: don't shut up the compiler when it says the code's buggy
Aleksey Kladov [Mon, 30 Aug 2021 07:53:59 +0000 (10:53 +0300)]
internal: don't shut up the compiler when it says the code's buggy

Wrapping state-modifying functions into a `catch_unwind` is wrong -- to
do retry after failure, you need to have transactional semantics!

2 years agoMerge #10079
bors[bot] [Mon, 30 Aug 2021 07:39:34 +0000 (07:39 +0000)]
Merge #10079

10079: internal: make upstream bug less annoying r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>