Commit graph

11051 commits

Author SHA1 Message Date
Laurențiu Nicola
6b187af337 Add profiling spans under cargo_to_crate_graph 2021-04-22 21:25:29 +03:00
Jonas Schievink
7b7d051e81 Add failing local items test 2021-04-21 17:57:45 +02:00
Comonad
09147c3303 Add support for fill match arms of boolean values
- Add support for boolean inside tuple
2021-04-21 19:33:45 +08:00
Lukas Wirth
3f7a086b4f Parse outer atttributes for RecordPatField 2021-04-21 11:08:15 +02:00
Aleksey Kladov
cdfe5a8be0 fix: no more Registering progress handler for token rustAnalyzer/Indexing failed. 2021-04-20 22:54:05 +03:00
bors[bot]
ad131049c4
Merge #8600
8600:  fix: no longer get stuck on windows r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-04-20 15:05:33 +00:00
Aleksey Kladov
1772eb0f1a fix: no longer get stuck on windows
reading both stdout & stderr is a common gotcha, you need to drain them
concurrently to avoid deadlocks. Not sure why I didn't do the right
thing from the start. Seems like I assumed the stderr is short? That's
not the case when cargo spams `compiling xyz` messages
2021-04-20 18:02:54 +03:00
bors[bot]
86c2bb3c5b
Merge #8602
8602: Fix panic in `replace_derive_with_manual_impl` r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-04-20 14:27:08 +00:00
Jonas Schievink
c0ad9b3581 Follow testing style guide 2021-04-20 16:26:07 +02:00
Jonas Schievink
6624158969 Fix panic in replace_derive_with_manual_impl 2021-04-20 16:25:24 +02:00
Jonas Schievink
d699371f5f "Inline variable" when on a use of the variable 2021-04-20 16:16:23 +02:00
bors[bot]
b6a7276c54
Merge #8586
8586: Replace SyntaxRewriter usage with ted in eager::eager_macro_recur r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-04-19 18:03:56 +00:00
Jonas Schievink
ec05186378 Add autoimport test with inner items 2021-04-19 19:53:29 +02:00
Jonas Schievink
59630977a5 Fix some find_path bugs around inner items 2021-04-19 19:50:11 +02:00
Lukas Wirth
952fc23694 Replace SyntaxRewriter with ted in exppand_macro::expand_macro_recur 2021-04-19 19:43:26 +02:00
Lukas Wirth
617cd7231c Remove SyntaxRewriter usage in eager::eager_macro_recur 2021-04-19 19:28:41 +02:00
bors[bot]
0741de87e7
Merge #8584
8584: internal: fix slightly broken test r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-04-19 16:04:44 +00:00
Aleksey Kladov
21f4588fc8 internal: fix slightly broken test 2021-04-19 18:57:47 +03:00
bors[bot]
fc709c8b21
Merge #8583
8583: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-04-19 15:55:29 +00:00
bors[bot]
2b5f35ca4b
Merge #8582
8582: Fix typo: comparision -> comparison r=kjeremy a=stanciuadrian

Closes #8576 

Co-authored-by: Adrian Stanciu <stanciu.adrian@gmail.com>
2021-04-19 15:47:18 +00:00
Adrian Stanciu
1c75d8975c Fix typo: comparision -> comparison 2021-04-19 18:44:38 +03:00
Lukas Wirth
c96c38edd3 Simplify 2021-04-19 17:11:30 +02:00
bors[bot]
6877e6e4da
Merge #8578
8578: fix: false positive about inner attrs in docs r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-04-19 14:37:54 +00:00
Aleksey Kladov
5f89a60f1a fix: false positive about inner attrs in docs
closes #8541
2021-04-19 17:11:49 +03:00
bors[bot]
6991b517f2
Merge #8577
8577: Support crates/module roots in external_docs r=Veykril a=Veykril

Fixes #8575
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-04-19 13:51:57 +00:00
Lukas Wirth
6142afeafd Support crates/module roots in external_docs 2021-04-19 15:50:04 +02:00
bors[bot]
e7a8977358
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>
2021-04-19 13:09:18 +00:00
bors[bot]
e4f7f1e1bd
Merge #8462
8462: Expand macros at type position r=jonas-schievink a=cynecx



Co-authored-by: cynecx <me@cynecx.net>
2021-04-19 13:01:30 +00:00
bors[bot]
3f1a220f32
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>
2021-04-19 11:39:45 +00:00
Lukas Wirth
2f62c0117a Check for rust doc code attributes like rustdoc does 2021-04-19 13:32:52 +02:00
bors[bot]
65dd942fa1
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>
2021-04-19 11:32:22 +00:00
Dawer
9222d3b0fb Unindent test according to the style guide. 2021-04-19 16:24:09 +05:00
Lukas Wirth
8a959497b1 Don't require all doc fences to be valid for identifying rust code 2021-04-19 11:41:45 +02:00
bors[bot]
75bf832899
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>
2021-04-19 07:57:40 +00:00
bors[bot]
3f432730df
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>
2021-04-19 04:54:04 +00:00
jake
3d1ca786f6 implement field stuff too 2021-04-18 21:51:17 -07:00
Jonas Schievink
20c27dbdbe Collect inherent impls in unnamed consts 2021-04-19 01:06:26 +02:00
Jonas Schievink
b777d46ae6 Fix visibility of items in block modules 2021-04-19 01:06:04 +02:00
Lukas Wirth
493aaa1403 Better visualise control flow for change_annotation_support" 2021-04-19 00:14:55 +02:00
cynecx
f0507ab7c6 hir_ty: cleanups and extend infinitely_recursive_macro_type test 2021-04-18 20:18:48 +02:00
cynecx
6ed2fd233b hir_ty: keep body::Expander in TyLoweringContext 2021-04-18 19:56:13 +02:00
bors[bot]
d39873e88b
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>
2021-04-18 16:44:14 +00:00
Jonas Schievink
ae84a71e4a Expand global_asm! to nothing 2021-04-18 18:43:45 +02:00
cynecx
3d39e77003 hir_def: various cleanups 2021-04-18 18:35:45 +02:00
Dawer
8d588efc2b Return to the status quo in #8129 2021-04-18 20:17:30 +05:00
Dawer
51d65caed4 Prevent adding useless match arms 2021-04-18 16:54:09 +05:00
Lukas Wirth
c447a795ab Prevent being able to rename items that are not part of the workspace 2021-04-18 12:44:00 +02:00
bors[bot]
e8e145f13c
Merge #8561
8561: Accept `E<error_number>` notation in doctests r=Veykril a=ChayimFriedman2

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

The code was stolen from rustdoc at 392ba2ba1a/src/librustdoc/html/markdown.rs (L866-L867)

Co-authored-by: Chayim Refael Friedman <chayimfr@gmail.com>
2021-04-18 09:57:43 +00:00
Chayim Refael Friedman
6c287e1504 Accept E<error_number> notation in doctests
```compile_fail,E0000
```

The code was stolen from rustdoc at 392ba2ba1a/src/librustdoc/html/markdown.rs (L866-L867)
2021-04-18 06:15:40 +03:00
bors[bot]
2ace128dd4
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>
2021-04-18 02:14:27 +00:00