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

8502: internal: document review requesting etiquette r=matklad a=matklad

* don't feel obliged to quickly review every PR assigned to you
* so that other folks can notify you about interesting PRs without
  thinking to much about creating additional work for you

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoMerge #8524 #8527
bors[bot] [Mon, 19 Apr 2021 13:09:18 +0000 (13:09 +0000)]
Merge #8524 #8527

8524: Fix extract function with partial block selection r=matklad a=brandondong

**Reproduction:**
```rust
fn foo() {
    let n = 1;
    let mut v = $0n * n;$0
    v += 1;
}
```
1. Select the snippet ($0) and use the "Extract into function" assist.
2. Extracted function is incorrect and does not compile:
```rust
fn foo() {
    let n = 1;
    let mut v = fun_name(n);
    v += 1;
}

fn fun_name(n: i32) {}
```
3. Omitting the ending semicolon from the selection fixes the extracted function:
```rust
fn fun_name(n: i32) -> i32 {
    n * n
}
```

**Cause:**
- When `extraction_target` uses a block extraction (semicolon case) instead of an expression extraction (no semicolon case), the user selection is directly used as the TextRange.
- However, the existing function extraction logic for blocks requires that the TextRange spans from start to end of complete statements to work correctly.
- For example:
```rust
fn foo() {
    let m = 2;
    let n = 1;
    let mut v = m $0* n;
    let mut w = 3;$0
    v += 1;
    w += 1;
}
```
produces
```rust
fn foo() {
    let m = 2;
    let n = 1;
    let mut v = m let mut w = fun_name(n);
    v += 1;
    w += 1;
}

fn fun_name(n: i32) -> i32 {
    let mut w = 3;
    w
}
```
- The user selected TextRange is directly replaced by the function call which is now in the middle of another statement. The extracted function body only contains statements that were fully covered by the TextRange and so the `* n` code is deleted. The logic for calculating variable usage and outlived variables for the function parameters and return type respectively search within the TextRange and so do not include `m` or `v`.

**Fix:**
- Only extract full statements when using block extraction. If a user selected part of a statement, extract that full statement.

8527: Switch introduce_named_lifetime assist to use mutable syntax tree  r=matklad a=iDawer

This extends `GenericParamsOwnerEdit` trait with `get_or_create_generic_param_list` method

Co-authored-by: Brandon <brandondong604@hotmail.com>
Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
3 years agoUpdate docs/dev/README.md
Aleksey Kladov [Tue, 13 Apr 2021 11:53:02 +0000 (14:53 +0300)]
Update docs/dev/README.md

Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
3 years agointernal: document review requesting etiquette
Aleksey Kladov [Tue, 13 Apr 2021 11:13:50 +0000 (14:13 +0300)]
internal: document review requesting etiquette

* don't feel obliged to quickly review every PR assigned to you
* so that other folks can notify you about interesting PRs without
  thinking to much about creating additional work for you

3 years agoMerge #8462
bors[bot] [Mon, 19 Apr 2021 13:01:30 +0000 (13:01 +0000)]
Merge #8462

8462: Expand macros at type position r=jonas-schievink a=cynecx

Co-authored-by: cynecx <me@cynecx.net>
3 years agoMerge #8574
bors[bot] [Mon, 19 Apr 2021 11:39:45 +0000 (11:39 +0000)]
Merge #8574

8574: Check for rust doc code attributes like rustdoc does r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoCheck for rust doc code attributes like rustdoc does
Lukas Wirth [Mon, 19 Apr 2021 11:20:37 +0000 (13:20 +0200)]
Check for rust doc code attributes like rustdoc does

3 years agoMerge #8565
bors[bot] [Mon, 19 Apr 2021 11:32:22 +0000 (11:32 +0000)]
Merge #8565

8565: Fill match arms assist: add remaining arms for tuple of enums r=iDawer a=iDawer

Fix for #8493

However, the assist is still flaky and does not use `hir_ty::diagnostics::match_check`

Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
3 years agoUnindent test according to the style guide.
Dawer [Mon, 19 Apr 2021 11:24:09 +0000 (16:24 +0500)]
Unindent test according to the style guide.

3 years agoDon't require all doc fences to be valid for identifying rust code
Lukas Wirth [Mon, 19 Apr 2021 09:41:45 +0000 (11:41 +0200)]
Don't require all doc fences to be valid for identifying rust code

3 years agoMerge #8540
bors[bot] [Mon, 19 Apr 2021 07:57:40 +0000 (07:57 +0000)]
Merge #8540

8540: Prevent being able to rename items that are not part of the workspace r=Veykril a=Veykril

This change causes renames that happen on items coming from crates outside the workspace to fail. I believe this should be the right approach, but usage of cargo's workspace might not be entirely correct for preventing these kinds of refactoring from touching things they shouldn't. I'm not entirely sure?

cc #6623, this is one of the bigger footguns when it comes to refactoring, especially in combination with import aliases people tend to rename items coming from a crates dependency which this prevents.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoMerge #8572
bors[bot] [Mon, 19 Apr 2021 06:09:48 +0000 (06:09 +0000)]
Merge #8572

8572: minor: update bug report template r=lnicola a=lnicola

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
3 years agoUpdate bug report template
Laurențiu Nicola [Mon, 19 Apr 2021 06:06:04 +0000 (09:06 +0300)]
Update bug report template

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 agoBetter visualise control flow for change_annotation_support"
Lukas Wirth [Sun, 18 Apr 2021 22:14:21 +0000 (00:14 +0200)]
Better visualise control flow for change_annotation_support"

3 years agohir_ty: cleanups and extend infinitely_recursive_macro_type test
cynecx [Sun, 18 Apr 2021 18:18:48 +0000 (20:18 +0200)]
hir_ty: cleanups and extend infinitely_recursive_macro_type  test

3 years agohir_ty: keep body::Expander in TyLoweringContext
cynecx [Sun, 18 Apr 2021 17:56:13 +0000 (19:56 +0200)]
hir_ty: keep body::Expander in TyLoweringContext

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 agohir_def: various cleanups
cynecx [Sun, 18 Apr 2021 16:35:45 +0000 (18:35 +0200)]
hir_def: various cleanups

3 years agoReturn to the status quo in #8129
Dawer [Sun, 18 Apr 2021 15:17:30 +0000 (20:17 +0500)]
Return to the status quo in #8129

3 years agoPrevent adding useless match arms
Dawer [Sun, 18 Apr 2021 11:43:12 +0000 (16:43 +0500)]
Prevent adding useless match arms

3 years agoUpdate lsp-extensions docs
Lukas Wirth [Sun, 18 Apr 2021 10:50:44 +0000 (12:50 +0200)]
Update lsp-extensions docs

3 years agoPrevent being able to rename items that are not part of the workspace
Lukas Wirth [Fri, 16 Apr 2021 15:31:47 +0000 (17:31 +0200)]
Prevent being able to rename items that are not part of the workspace

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 agohir_def: refactor expand_macro_type and cleanups
cynecx [Sat, 17 Apr 2021 15:38:38 +0000 (17:38 +0200)]
hir_def: refactor expand_macro_type and cleanups

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 agohir_def: ignore ast::Type in file_item_tree query
cynecx [Wed, 14 Apr 2021 00:36:05 +0000 (02:36 +0200)]
hir_def: ignore ast::Type in file_item_tree query

3 years agohir_ty: deal with TypeRef::Macro in HirFormatter
cynecx [Mon, 12 Apr 2021 14:24:48 +0000 (16:24 +0200)]
hir_ty: deal with TypeRef::Macro in HirFormatter

3 years agohir_ty: Expand macros at type position
cynecx [Sat, 10 Apr 2021 15:49:12 +0000 (17:49 +0200)]
hir_ty: Expand macros at type position

3 years agoTest fill-match-arms assist: partial with wildcards
Dawer [Sat, 17 Apr 2021 10:20:29 +0000 (15:20 +0500)]
Test fill-match-arms assist: partial with wildcards

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 agoFill partial match arms for a tuple of enums
Dawer [Fri, 16 Apr 2021 20:09:09 +0000 (01:09 +0500)]
Fill partial match arms for a tuple of enums

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 agoFinish GenericParamsOwnerEdit impls
Dawer [Thu, 15 Apr 2021 10:57:45 +0000 (15:57 +0500)]
Finish GenericParamsOwnerEdit impls

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 agoFix extract function with partial block selection
Brandon [Wed, 14 Apr 2021 04:07:52 +0000 (21:07 -0700)]
Fix extract function with partial block selection

3 years agoSwitch introduce_named_lifetime assist to use mutable syntax tree
Dawer [Wed, 14 Apr 2021 20:56:19 +0000 (01:56 +0500)]
Switch introduce_named_lifetime assist to use mutable syntax tree

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