]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoMerge #8467
bors[bot] [Mon, 19 Apr 2021 04:54:04 +0000 (04:54 +0000)]
Merge #8467

8467: Adds impl Deref assist r=jhgg a=jhgg

This PR adds a new `generate_deref` assist that automatically generates a deref impl for a given struct field.

Check out this gif:

![2021-04-11_00-33-33](https://user-images.githubusercontent.com/5489149/114296006-b38e1000-9a5d-11eb-9112-807c01b8fd0a.gif)

--

I have a few Q's:
 - [x] Should I write more tests, if so, what precisely should I test for?
 - [x] I have an inline question on line 65, can someone provide guidance? :)
 - [x] I can implement this for `ast::TupleField` too. But should it be a separate assist fn, or should I try and jam both into the `generate_deref`?
 - [x] I want to follow this up with an assist on `impl $0Deref for T {` which would automatically generate a `DerefMut` impl that mirrors the Deref as well, however, I could probably use some pointers on how to do that, since I'll have to reach into the ast of `fn deref` to grab the field that it's referencing for the `DerefMut` impl.

Co-authored-by: jake <jh@discordapp.com>
3 years agoimplement field stuff too
jake [Mon, 19 Apr 2021 04:51:17 +0000 (21:51 -0700)]
implement field stuff too

3 years agoMerge #8569
bors[bot] [Sun, 18 Apr 2021 23:08:44 +0000 (23:08 +0000)]
Merge #8569

8569: Support inherent impls in unnamed consts r=jonas-schievink a=jonas-schievink

It turns out that some proc. macros not only generate *trait* impls wrapped in `const _: () = { ... };`, but inherent impls too. Even though it is questionable whether *custom derives* should produce non-trait impls, this is useful for procedural attribute macros once we support them.

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoCollect inherent impls in unnamed consts
Jonas Schievink [Sun, 18 Apr 2021 23:06:26 +0000 (01:06 +0200)]
Collect inherent impls in unnamed consts

3 years agoFix visibility of items in block modules
Jonas Schievink [Sun, 18 Apr 2021 23:06:04 +0000 (01:06 +0200)]
Fix visibility of items in block modules

3 years agoMerge #8564
bors[bot] [Sun, 18 Apr 2021 16:44:14 +0000 (16:44 +0000)]
Merge #8564

8564: Expand `global_asm!` to nothing r=jonas-schievink a=jonas-schievink

fixes https://github.com/rust-analyzer/rust-analyzer/issues/8563

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoExpand `global_asm!` to nothing
Jonas Schievink [Sun, 18 Apr 2021 16:43:45 +0000 (18:43 +0200)]
Expand `global_asm!` to nothing

3 years agoMerge #8561
bors[bot] [Sun, 18 Apr 2021 09:57:43 +0000 (09:57 +0000)]
Merge #8561

8561: Accept `E<error_number>` notation in doctests r=Veykril a=ChayimFriedman2

````
```compile_fail,E0000
```
````

The code was stolen from rustdoc at https://github.com/rust-lang/rust/blob/392ba2ba1a7d6c542d2459fb8133bebf62a4a423/src/librustdoc/html/markdown.rs#L866-L867

Co-authored-by: Chayim Refael Friedman <chayimfr@gmail.com>
3 years agoAccept `E<error_number>` notation in doctests
Chayim Refael Friedman [Sun, 18 Apr 2021 02:09:20 +0000 (05:09 +0300)]
Accept `E<error_number>` notation in doctests

```compile_fail,E0000
```

The code was stolen from rustdoc at https://github.com/rust-lang/rust/blob/392ba2ba1a7d6c542d2459fb8133bebf62a4a423/src/librustdoc/html/markdown.rs#L866-L867

3 years agoMerge #8560
bors[bot] [Sun, 18 Apr 2021 02:14:27 +0000 (02:14 +0000)]
Merge #8560

8560: Escape characters in doc comments in macros correctly r=jonas-schievink a=ChayimFriedman2

Previously they were escaped twice, both by `.escape_default()` and the debug view of strings (`{:?}`). This leads to things like newlines or tabs in documentation comments being `\\n`, but we unescape literals only once, ending up with `\n`.

This was hard to spot because CMark unescaped them (at least for `'` and `"`), but it did not do so in code blocks.

This also was the root cause of #7781. This issue was solved by using `.escape_debug()` instead of `.escape_default()`, but the real issue remained.
We can bring the `.escape_default()` back by now, however I didn't do it because it is probably slower than `.escape_debug()` (more work to do), and also in order to change the code the least.

Example (the keyword and primitive docs are `include!()`d at https://doc.rust-lang.org/src/std/lib.rs.html#570-578, and thus originate from macro):

Before:
![image](https://user-images.githubusercontent.com/24700207/115130096-40544300-9ff5-11eb-847b-969e7034e8a4.png)

After:
![image](https://user-images.githubusercontent.com/24700207/115130143-9cb76280-9ff5-11eb-9281-323746089440.png)

Co-authored-by: Chayim Refael Friedman <chayimfr@gmail.com>
3 years agoEscape characters in doc comments in macros correctly
Chayim Refael Friedman [Sun, 18 Apr 2021 00:16:38 +0000 (03:16 +0300)]
Escape characters in doc comments in macros correctly

Previously they were escaped twice, both by `.escape_default()` and the debug view of strings (`{:?}`). This leads to things like newlines or tabs in documentation comments being `\\n`, but we unescape literals only once, ending up with `\n`.

This was hard to spot because CMark unescaped them (at least for `'` and `"`), but it did not do so in code blocks.

This also was the root cause of #7781. This issue was solved by using `.escape_debug()` instead of `.escape_default()`, but the real issue remained.
We can bring the `.escape_default()` back by now, however I didn't do it because it is probably slower than `.escape_debug()` (more work to do), and also in order to change the code the least.

3 years agoMerge #8559
bors[bot] [Sat, 17 Apr 2021 19:37:59 +0000 (19:37 +0000)]
Merge #8559

8559: Add some more error messages to fixture failure cases r=Veykril a=Veykril

Follow up for #8557
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoAdd some more error messages to fixture failure cases
Lukas Wirth [Sat, 17 Apr 2021 19:34:14 +0000 (21:34 +0200)]
Add some more error messages to fixture failure cases

3 years agoMerge #8557
bors[bot] [Sat, 17 Apr 2021 14:51:42 +0000 (14:51 +0000)]
Merge #8557

8557: Add an error message to fixture errors r=Veykril a=yoshuawuyts

Improve the error message when folks forget to add an `$0` in one of the fixtures. Figuring this one out was 20 minutes down the drain for me, so figured I might as well make sure nobody else has to go through the same thing in the future. Thanks!

Co-authored-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
3 years agoAdd an error message to fixture errors
Yoshua Wuyts [Sat, 17 Apr 2021 14:39:03 +0000 (16:39 +0200)]
Add an error message to fixture errors

3 years agoMerge #8551
bors[bot] [Sat, 17 Apr 2021 08:00:52 +0000 (08:00 +0000)]
Merge #8551

8551: nail rowan version down r=lnicola a=drahnr

The different pre versions include breaking changes, which cause build failures for the users.

Co-authored-by: Bernhard Schuster <bernhard@ahoi.io>
3 years agonail rowan version down
Bernhard Schuster [Sat, 17 Apr 2021 07:31:54 +0000 (09:31 +0200)]
nail rowan version down

The different pre versions include breaking changes, which cause build failures for the users.

3 years agoMerge #8550
bors[bot] [Sat, 17 Apr 2021 06:34:07 +0000 (06:34 +0000)]
Merge #8550

8550: Handle extended key value attributes in mbe r=edwin0cheng a=edwin0cheng

fixes #8544

bors r+

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
3 years agoHandle extended key value attr in mbe
Edwin Cheng [Sat, 17 Apr 2021 06:31:52 +0000 (14:31 +0800)]
Handle extended key value attr in mbe

3 years agoMerge #8549
bors[bot] [Sat, 17 Apr 2021 01:35:22 +0000 (01:35 +0000)]
Merge #8549

8549: Fix `TestDB::module_at_position` with submodules r=jonas-schievink a=jonas-schievink

Found while looking into https://github.com/rust-analyzer/rust-analyzer/issues/8519

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoFix `TestDB::module_at_position` with submodules
Jonas Schievink [Sat, 17 Apr 2021 01:34:05 +0000 (03:34 +0200)]
Fix `TestDB::module_at_position` with submodules

3 years agoMerge #8546
bors[bot] [Fri, 16 Apr 2021 21:00:55 +0000 (21:00 +0000)]
Merge #8546

8546: Return CallInfo for unclosed call expressions r=Veykril a=Veykril

Closes #8522
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoReturn CallInfo for unclosed call expressions
Lukas Wirth [Fri, 16 Apr 2021 20:57:33 +0000 (22:57 +0200)]
Return CallInfo for unclosed call expressions

3 years agoMerge #8542
bors[bot] [Fri, 16 Apr 2021 20:52:56 +0000 (20:52 +0000)]
Merge #8542

8542: Include path in `unresolved-macro-call` diagnostic r=matklad a=jonas-schievink

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoMerge #8539
bors[bot] [Fri, 16 Apr 2021 17:54:47 +0000 (17:54 +0000)]
Merge #8539

8539:  fix: Do not propose inherent traits in flyimports and import assists r=flodiebold a=SomeoneToIgnore

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

I've went with a separate method approach, since the [highlighted code](https://github.com/rust-analyzer/rust-analyzer/issues/8520#issuecomment-819856337) has not`Type` and uses `Ty` to get his data, but the code I had to change has no access to `Ty` and has `Type` only.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
3 years agoMerge #8545
bors[bot] [Fri, 16 Apr 2021 17:32:02 +0000 (17:32 +0000)]
Merge #8545

8545: Fix primitive shadowing with inner items r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoFix primitive shadowing with inner items
Jonas Schievink [Fri, 16 Apr 2021 17:28:22 +0000 (19:28 +0200)]
Fix primitive shadowing with inner items

3 years agoMerge #8543
bors[bot] [Fri, 16 Apr 2021 15:47:43 +0000 (15:47 +0000)]
Merge #8543

8543: Assist fix: Fill match arms for a tuple of a single enum. r=Veykril a=iDawer

This is rather a small fix addressing an issue mentioned in https://github.com/rust-analyzer/rust-analyzer/issues/8493#issuecomment-818770670

Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
3 years agoInclude path in `unresolved-macro-call` diagnostic
Jonas Schievink [Fri, 16 Apr 2021 13:48:03 +0000 (15:48 +0200)]
Include path in `unresolved-macro-call` diagnostic

3 years agoFill match arms for a tuple of a single enum.
Dawer [Fri, 16 Apr 2021 12:22:11 +0000 (17:22 +0500)]
Fill match arms for a tuple of a single enum.

3 years agoExclude inherent traits from flyimports
Kirill Bulatov [Thu, 15 Apr 2021 20:31:42 +0000 (23:31 +0300)]
Exclude inherent traits from flyimports

3 years agoMerge #8536
bors[bot] [Thu, 15 Apr 2021 18:48:25 +0000 (18:48 +0000)]
Merge #8536

8536: change grammar r=kjeremy a=Milo123459

indexing -> Indexing
fetching -> Fetching
loading -> Loading
roots scanned -> Roots Scanned

Co-authored-by: Milo <50248166+Milo123459@users.noreply.github.com>
3 years agochange grammar
Milo [Thu, 15 Apr 2021 18:39:34 +0000 (19:39 +0100)]
change grammar

3 years agoMerge #8535
bors[bot] [Thu, 15 Apr 2021 17:46:10 +0000 (17:46 +0000)]
Merge #8535

8535: Fix markdown links r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoFix markdown links
Jonas Schievink [Thu, 15 Apr 2021 17:45:07 +0000 (19:45 +0200)]
Fix markdown links

3 years agoMerge #8534
bors[bot] [Thu, 15 Apr 2021 17:28:10 +0000 (17:28 +0000)]
Merge #8534

8534: Remove unneeded annotations from find_path tests r=jonas-schievink a=jonas-schievink

Addresses https://github.com/rust-analyzer/rust-analyzer/pull/8532#discussion_r614247375

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoRemove unneeded annotations from find_path tests
Jonas Schievink [Thu, 15 Apr 2021 17:24:09 +0000 (19:24 +0200)]
Remove unneeded annotations from find_path tests

3 years agoMerge #8510 #8533
bors[bot] [Thu, 15 Apr 2021 16:42:36 +0000 (16:42 +0000)]
Merge #8510 #8533

8510: Move cursor position when using item movers r=jonas-schievink a=jonas-schievink

This updates the cursor position when moving items around to stay in the same location within the moved node.

I changed the `moveItem` response to `SnippetTextEdit[]`, since that made more sense to me (the file was ignored by the client anyways, since the edits always apply to the current document). It also matches `onEnter`, which seems logical to me, but please let me know if this doesn't make sense.

There's still a bug in the client-side snippet code that will cause the cursor position to be slightly off when moving parameters in the same line (presumably we don't track the column correctly after deleting `$0`). Not really sure how to fix that immediately, but this PR should already be an improvement despite that bug.

8533: Fix typo in style guide r=jonas-schievink a=jonas-schievink

Fixes bold text rendering

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoFix typo in style guide
Jonas Schievink [Thu, 15 Apr 2021 16:38:52 +0000 (18:38 +0200)]
Fix typo in style guide

3 years agoMerge #8532
bors[bot] [Thu, 15 Apr 2021 16:32:53 +0000 (16:32 +0000)]
Merge #8532

8532: Make `find_path` tests adhere to style guide r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoMake find_path tests adhere to style guide
Jonas Schievink [Thu, 15 Apr 2021 16:32:19 +0000 (18:32 +0200)]
Make find_path tests adhere to style guide

3 years agoMerge #8529
bors[bot] [Thu, 15 Apr 2021 16:16:10 +0000 (16:16 +0000)]
Merge #8529

8529: minor: notify 5.0.0.pre7 r=kjeremy a=kjeremy

Fixes windows leak: https://github.com/notify-rs/notify/pull/298

Co-authored-by: kjeremy <kjeremy@gmail.com>
3 years agoUpdate license check
kjeremy [Thu, 15 Apr 2021 16:15:23 +0000 (12:15 -0400)]
Update license check

3 years agonotify 5.0.0.pre7
kjeremy [Thu, 15 Apr 2021 15:51:32 +0000 (11:51 -0400)]
notify 5.0.0.pre7

Fixes windows leak: https://github.com/notify-rs/notify/pull/298

3 years agoMerge #8526
bors[bot] [Thu, 15 Apr 2021 08:53:03 +0000 (08:53 +0000)]
Merge #8526

8526: fix: Do not show flyimports in trait or impl declarations r=SomeoneToIgnore a=SomeoneToIgnore

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

Removes autoimport suggestions for the case:

> inside trait definitions / impls (trait Trait {$0} / impl Foo {$0}), nothing except the fn, type and const keywords (and the full item completions for trait impls) should appear (currently many types and autoimport suggestions)

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
3 years agoDo not show flyimports in trait or impl declarations
Kirill Bulatov [Thu, 15 Apr 2021 08:50:47 +0000 (11:50 +0300)]
Do not show flyimports in trait or impl declarations

3 years agoMerge #8515
bors[bot] [Wed, 14 Apr 2021 20:53:27 +0000 (20:53 +0000)]
Merge #8515

8515: internal: Profile trait solving for all invocations r=flodiebold a=SomeoneToIgnore

Follow-up of https://github.com/rust-analyzer/rust-analyzer/pull/8514#issuecomment-819610492

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
3 years agoProfile trait solving for all invocations
Kirill Bulatov [Wed, 14 Apr 2021 16:11:17 +0000 (19:11 +0300)]
Profile trait solving for all invocations

3 years agoMerge #8514
bors[bot] [Wed, 14 Apr 2021 14:20:13 +0000 (14:20 +0000)]
Merge #8514

8514: Add more profiling spans into type inference r=matklad a=SomeoneToIgnore

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

I've added a minimal set of spans to remove `???` and showcase the underlying issue:

<img width="1552" alt="image" src="https://user-images.githubusercontent.com/2690773/114722983-f2181900-9d42-11eb-821d-9e93ded5f81f.png">

`db.trait_solve` reliably produces the same timings for the same input in the same place for me, despite supposedly being cached by Salsa.
In my perception, this is a bit odd, so I've decided to stop at this point and discuss it with people with better knowledge on the topic.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
3 years agoBetter places for spans
Kirill Bulatov [Wed, 14 Apr 2021 14:15:37 +0000 (17:15 +0300)]
Better places for spans

3 years agoWe need to go deeper
Kirill Bulatov [Wed, 14 Apr 2021 13:59:08 +0000 (16:59 +0300)]
We need to go deeper

3 years agoAdd a missing span
Kirill Bulatov [Wed, 14 Apr 2021 12:52:56 +0000 (15:52 +0300)]
Add a missing span

3 years agoMove cursor position when using item movers
Jonas Schievink [Tue, 13 Apr 2021 18:32:45 +0000 (20:32 +0200)]
Move cursor position when using item movers

3 years agoMerge #8507
bors[bot] [Tue, 13 Apr 2021 12:34:12 +0000 (12:34 +0000)]
Merge #8507

8507: internal: follow test style guide in typing.rs r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agointernal: follow test style guide in typing.rs
Jonas Schievink [Tue, 13 Apr 2021 12:31:05 +0000 (14:31 +0200)]
internal: follow test style guide in typing.rs

3 years agoMerge #8506
bors[bot] [Tue, 13 Apr 2021 12:23:37 +0000 (12:23 +0000)]
Merge #8506

8506: crossbeam-channel 0.5.1 r=kjeremy a=kjeremy

Fixes a potential memory leak in unbound channels.

Co-authored-by: kjeremy <kjeremy@gmail.com>
3 years agocrossbeam-channel 0.5.1
kjeremy [Tue, 13 Apr 2021 12:19:47 +0000 (08:19 -0400)]
crossbeam-channel 0.5.1

Fixes a potential memory leak in unbound channels.

3 years agoMerge #8504
bors[bot] [Tue, 13 Apr 2021 12:14:16 +0000 (12:14 +0000)]
Merge #8504

8504: decl_check: follow test style guide r=jonas-schievink a=jonas-schievink

changelog skip

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agodecl_check: follow test style guide
Jonas Schievink [Tue, 13 Apr 2021 12:13:35 +0000 (14:13 +0200)]
decl_check: follow test style guide

3 years agoMerge #8432
bors[bot] [Tue, 13 Apr 2021 12:02:26 +0000 (12:02 +0000)]
Merge #8432

8432: decl_check: consider outer scopes' allows r=jonas-schievink a=lf-

Fix #8417. Also makes it less noisy about no_mangle annotated stuff the
user can do nothing about.

Note: this still is broken with bitfield! macros. A repro in an ignore
test is included here. I believe this bug is elsewhere, and I don't
think I can work around it here.

I would like help filing the remaining bug, as it does actually affect
users, but I don't know how to describe the behaviour (or even if it
is unintended).

Co-authored-by: Jade <software@lfcode.ca>
3 years agoMerge #8354
bors[bot] [Tue, 13 Apr 2021 11:46:23 +0000 (11:46 +0000)]
Merge #8354

8354: Distinguishing between different operators in semantic highlighting r=matklad a=chetankhilosiya

Co-authored-by: Chetan Khilosiya <chetan.khilosiya@gmail.com>
3 years agoMerge #8415
bors[bot] [Tue, 13 Apr 2021 11:39:03 +0000 (11:39 +0000)]
Merge #8415

8415: Fix faulty assertion when extracting function with macro call r=matklad a=brandondong

**Reproduction:**
```rust
fn main() {
    let n = 1;
    let k = n * n;
    dbg!(n);
}
```
1. Select the second and third lines of the main function. Use the "Extract into function" code assist.
2. Panic occurs in debug, error is logged in release: "[ERROR ide_assists::handlers::extract_function] assertion failed: matches!(path, ast :: Expr :: PathExpr(_))".
3. Function generates successfully on release where the panic was bypassed.
```rust
fn fun_name(n: i32) {
    let k = n * n;
    dbg!(n);
}
```

**Cause:**
- The generated function will take `n` as a parameter. The extraction logic needs to search the usages of `n` to determine whether it is used mutably or not. The helper `path_element_of_reference` is called for each usage but the second usage is a macro call and fails the `Expr::PathExpr(_)` match assertion.
- The caller of `path_element_of_reference` does implicitly assume it to be a `Expr::PathExpr(_)` in how it looks at its parent node for determining whether it is used mutably. This logic will not work for macros.
- I'm not sure if there are any other cases besides macros where it could be something other than a `Expr::PathExpr(_)`. I tried various examples and could not find any.

**Fix:**
- Update assertion to include the macro case.
- Add a FIXME to properly handle checking if a macro usage requires mutable access. For now, return false instead of running the existing logic that is tailored for `Expr::PathExpr(_)`'s.

Co-authored-by: Brandon <brandondong604@hotmail.com>
3 years agoMerge #8489
bors[bot] [Tue, 13 Apr 2021 10:06:36 +0000 (10:06 +0000)]
Merge #8489

8489: Indent block expressions on enter r=matklad a=jonas-schievink

This improves on https://github.com/rust-analyzer/rust-analyzer/pull/8388 by also indenting the created block expression on enter.

![on enter](https://user-images.githubusercontent.com/1786438/114444123-cb38d600-9bce-11eb-8af2-8e8d1c0f9908.gif)

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoMerge #8500
bors[bot] [Tue, 13 Apr 2021 09:56:45 +0000 (09:56 +0000)]
Merge #8500

8500: internal: fix flakiness of accidentally quadratic test r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agointernal: fix flakiness of accidentally quadratic test
Aleksey Kladov [Tue, 13 Apr 2021 09:49:10 +0000 (12:49 +0300)]
internal: fix flakiness of accidentally quadratic test

3 years agoMerge #8499
bors[bot] [Tue, 13 Apr 2021 09:23:24 +0000 (09:23 +0000)]
Merge #8499

8499: internal: don't use `#[should_panic]` for tests r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agointernal: don't use `#[should_panic]` for tests
Aleksey Kladov [Tue, 13 Apr 2021 09:20:54 +0000 (12:20 +0300)]
internal: don't use `#[should_panic]` for tests

3 years agoMerge #8498
bors[bot] [Tue, 13 Apr 2021 09:09:24 +0000 (09:09 +0000)]
Merge #8498

8498: feat: improve performance by delaying computation of fixes for diagnostics r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agofeat: improve performance by delaying computation of fixes for diagnostics
Aleksey Kladov [Tue, 13 Apr 2021 08:48:12 +0000 (11:48 +0300)]
feat: improve performance by delaying computation of fixes for diagnostics

3 years agoEnsure that listing&resolving code actions use the same set of actions
Aleksey Kladov [Tue, 13 Apr 2021 08:27:00 +0000 (11:27 +0300)]
Ensure that listing&resolving code actions use the same set of actions

3 years agoaddress review feedback
Jade [Tue, 13 Apr 2021 08:20:00 +0000 (01:20 -0700)]
address review feedback

3 years agoMerge #8494
bors[bot] [Tue, 13 Apr 2021 07:59:36 +0000 (07:59 +0000)]
Merge #8494

8494: internal: unfork code paths for unresolved and resolved assist r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agointernal: unfork code paths for unresolved and resolved assist
Aleksey Kladov [Mon, 12 Apr 2021 20:08:56 +0000 (23:08 +0300)]
internal: unfork code paths for unresolved and resolved assist

3 years agoMerge #8496
bors[bot] [Tue, 13 Apr 2021 06:22:09 +0000 (06:22 +0000)]
Merge #8496

8496: Exclude nightly tag from git describe to fix version string r=lnicola a=lnicola

Otherwise if we run `git describe` on the release day we pick up the `nightly` tag from the previous release.

changelog fix

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
3 years agoExclude nightly tag from git describe to fix version string
Laurențiu Nicola [Tue, 13 Apr 2021 06:20:17 +0000 (09:20 +0300)]
Exclude nightly tag from git describe to fix version string

3 years agoAdd a cov_mark
Jonas Schievink [Mon, 12 Apr 2021 22:51:10 +0000 (00:51 +0200)]
Add a cov_mark

3 years agoSimplify multiline check
Jonas Schievink [Mon, 12 Apr 2021 19:41:44 +0000 (21:41 +0200)]
Simplify multiline check

3 years agoIndent block expressions on enter
Jonas Schievink [Mon, 12 Apr 2021 18:35:38 +0000 (20:35 +0200)]
Indent block expressions on enter

3 years agoMerge #8488
bors[bot] [Mon, 12 Apr 2021 18:26:23 +0000 (18:26 +0000)]
Merge #8488

8488: Fix typo: liner -> linear r=SomeoneToIgnore a=NieDzejkob

:see_no_evil:

Co-authored-by: Jakub Kądziołka <kuba@kadziolka.net>
3 years agoFix typo: liner -> linear
Jakub Kądziołka [Mon, 12 Apr 2021 18:20:25 +0000 (20:20 +0200)]
Fix typo: liner -> linear

:see_no_evil:

3 years agoMerge #8483
bors[bot] [Mon, 12 Apr 2021 16:29:56 +0000 (16:29 +0000)]
Merge #8483

8483: internal: clarify who a rls-2.0 wg r=edwin0cheng a=matklad

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agointernal: clarify who a rls-2.0 wg
Aleksey Kladov [Mon, 12 Apr 2021 16:06:07 +0000 (19:06 +0300)]
internal: clarify who a rls-2.0 wg

3 years agoMerge #8481
bors[bot] [Mon, 12 Apr 2021 14:58:44 +0000 (14:58 +0000)]
Merge #8481

8481: internal: prepare for lazy diagnostics r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agointernal: prepare for lazy diagnostics
Aleksey Kladov [Mon, 12 Apr 2021 14:58:01 +0000 (17:58 +0300)]
internal: prepare for lazy diagnostics

3 years agoMerge #8478
bors[bot] [Mon, 12 Apr 2021 13:20:01 +0000 (13:20 +0000)]
Merge #8478

8478: fix: don't spam repeated error messages when `cargo check` fails r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agofix: don't spam repeated error messages when `cargo check` fails
Aleksey Kladov [Mon, 12 Apr 2021 13:09:21 +0000 (16:09 +0300)]
fix: don't spam repeated error messages when `cargo check` fails

Conceptually, using a *message* here is wrong, because this is a
"status", rather than "point in time" thing. But statuses are an LSP
extension, while messages are stable. As a compromise, send message only
for more critical `metadata` failures, and only once per state change.

3 years agoMerge #8476
bors[bot] [Mon, 12 Apr 2021 12:32:55 +0000 (12:32 +0000)]
Merge #8476

8476: feat: avoid checking the whole project during initial loading r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agofeat: avoid checking the whole project during initial loading
Aleksey Kladov [Mon, 12 Apr 2021 08:04:36 +0000 (11:04 +0300)]
feat: avoid checking the whole project during initial loading

3 years agoAdd macro test
Brandon [Sun, 11 Apr 2021 18:12:02 +0000 (11:12 -0700)]
Add macro test

3 years agoMerge #8469
bors[bot] [Sun, 11 Apr 2021 10:08:30 +0000 (10:08 +0000)]
Merge #8469

8469: Remove assertion in impl collection r=flodiebold a=flodiebold

This condition should always be true for *valid* code, but of course
there might be invalid code or things that we can't currently resolve.

Fixes #8464.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
3 years agoRemove assertion in impl collection
Florian Diebold [Sun, 11 Apr 2021 09:42:54 +0000 (11:42 +0200)]
Remove assertion in impl collection

This condition should always be true for *valid* code, but of course
there might be invalid code or things that we can't currently resolve.

Fixes #8464.

3 years agoAdds impl Deref assist
jake [Sun, 11 Apr 2021 07:31:20 +0000 (00:31 -0700)]
Adds impl Deref assist

3 years agoMerge #8465
bors[bot] [Sat, 10 Apr 2021 23:42:26 +0000 (23:42 +0000)]
Merge #8465

8465: Include more info in assert r=jonas-schievink a=jonas-schievink

This helped find https://github.com/rust-analyzer/rust-analyzer/issues/8464

changelog skip

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoInclude more info in assert
Jonas Schievink [Sat, 10 Apr 2021 23:41:40 +0000 (01:41 +0200)]
Include more info in assert

3 years agoMerge #8463
bors[bot] [Sat, 10 Apr 2021 23:33:18 +0000 (23:33 +0000)]
Merge #8463

8463: Support macros in pattern position r=jonas-schievink a=jonas-schievink

This was fairly easy, because patterns are limited to bodies, so almost all changes were inside body lowering.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoSupport macros in pattern position
Jonas Schievink [Sat, 10 Apr 2021 21:12:02 +0000 (23:12 +0200)]
Support macros in pattern position

3 years agoMerge #8436
bors[bot] [Sat, 10 Apr 2021 21:35:05 +0000 (21:35 +0000)]
Merge #8436

8436: Fix extract function's mutability of variables outliving the body r=matklad a=brandondong

**Reproduction:**
```rust
fn main() {
    let mut k = 1;
    let mut j = 2;
    j += 1;
    k += j;
}
```
1. Select the first to third lines of the main function. Use the "Extract into function" code assist.
2. The output is the following which does not compile because the outlived variable `k` is declared as immutable:
```rust
fn main() {
    let (k, j) = fun_name();
    k += j;
}

fn fun_name() -> (i32, i32) {
    let mut k = 1;
    let mut j = 2;
    j += 1;
    (k, j)
}
```
3. We would instead expect the output to be:
```rust
fn main() {
    let (mut k, j) = fun_name();
    k += j;
}
```

**Fix:**
- Instead of declaring outlived variables as immutable unconditionally, check for any mutable usages outside of the extracted function.

Co-authored-by: Brandon <brandondong604@hotmail.com>
3 years agoMerge #8460
bors[bot] [Sat, 10 Apr 2021 18:34:59 +0000 (18:34 +0000)]
Merge #8460

8460: Revert "Rewrite `#[derive]` removal code to be based on AST" r=jonas-schievink a=jonas-schievink

It breaks some function-like proc macros: https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Proc.20macro.20expansion/near/233971916

It also uses attribute indices incorrectly, which causes insufficient attributes to be removed.

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoRevert "Rewrite `#[derive]` removal to be based on AST"
Jonas Schievink [Sat, 10 Apr 2021 18:30:28 +0000 (20:30 +0200)]
Revert "Rewrite `#[derive]` removal to be based on AST"

This reverts commit 7e78aebc8fbbb4043d62949681e4d700f1a2ec46.

3 years agoRevert "Use `pub(crate)`"
Jonas Schievink [Sat, 10 Apr 2021 18:30:24 +0000 (20:30 +0200)]
Revert "Use `pub(crate)`"

This reverts commit c51213c2e7de21b7e68e6773ca3be0cdfc7c18af.