Commit Graph

19092 Commits

Author SHA1 Message Date
bors[bot]
796bfccac4
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>
2021-09-02 17:14:23 +00:00
Lukas Wirth
0fee14bfdd When descending tokens don't bail on failed macro call expansions 2021-09-02 19:12:08 +02:00
bors[bot]
2aee17e556
Merge #10124
10124: fix: Use correct search scopes for macros r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-02 15:32:10 +00:00
Lukas Wirth
e2ede38d47 Use correct search scopes for macros 2021-09-02 17:30:55 +02:00
bors[bot]
48f84a7b60
Merge #10114
10114: fix: Deduplicate imports for qualify_path r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-01 19:53:10 +00:00
Lukas Wirth
8e8ea537ab Deduplicate imports for qualify_path 2021-09-01 21:51:28 +02:00
bors[bot]
93f3c173e1
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>
2021-09-01 17:21:05 +00:00
Jonas Schievink
bdba35cc93 fix: multi-token mapping aware find references 2021-09-01 19:19:16 +02:00
bors[bot]
81ab52c6ca
Merge #10109
10109: fix: Enable flyimport for ident patterns r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-01 14:17:47 +00:00
Lukas Wirth
40a2faee65 Enable flyimport for ident patterns 2021-09-01 16:13:53 +02:00
bors[bot]
1b8a294555
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>
2021-09-01 12:52:29 +00:00
Lukas Wirth
68bf359363 fix: make goto_implementation multi-token mapping aware 2021-09-01 14:51:37 +02:00
bors[bot]
25368d2430
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>
2021-09-01 09:26:10 +00:00
Lukas Wirth
8bbfd45d97 Minor fixes 2021-09-01 11:25:42 +02:00
bors[bot]
75acb19394
Merge #9405
9405: Fix extract_function with macro arg r=Veykril a=sasurau4

## Overview

Fix #9266 


Co-authored-by: Daiki Ihara <sasurau4@gmail.com>
2021-09-01 09:14:25 +00:00
Daiki Ihara
4d005e529b Fix extract_function with macro arg 2021-09-01 11:11:57 +02:00
bors[bot]
535f0726f1
Merge #10101
10101: internal: reduce coupling r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-31 16:15:44 +00:00
Aleksey Kladov
81602f8a5d 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.
2021-08-31 19:14:33 +03:00
bors[bot]
e8f0f234c3
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>
2021-08-31 16:04:54 +00:00
Aleksey Kladov
d8a3d6f378 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
2021-08-31 19:01:39 +03:00
bors[bot]
2c538e9c8c
Merge #10099
10099: minor: improve readability r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-31 13:58:16 +00:00
bors[bot]
aa1cdc0cce
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>
2021-08-31 12:47:33 +00:00
Aleksey Kladov
722a2a4690 minor: improve readability
naming, layout & comments help!
2021-08-31 15:46:00 +03:00
bors[bot]
4786a22787
Merge #10098
10098: minor: dead code r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-31 12:27:27 +00:00
Aleksey Kladov
f1222e8085 minor: dead code 2021-08-31 15:26:59 +03:00
bors[bot]
bda50a1b46
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>
2021-08-31 12:17:50 +00:00
Jonas Schievink
418b163a4b Allow inherent impl for arrays 2021-08-31 14:15:39 +02:00
Aleksey Kladov
51b955ec8a internal: simplify 2021-08-31 15:09:46 +03:00
Jonas Schievink
b1a4784c95 Augment panic context when resolving path 2021-08-31 13:42:46 +02:00
bors[bot]
f70086203b
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>
2021-08-31 11:39:34 +00:00
Aleksey Kladov
8dbf3832b2 internal: split database loading time in anaysis-stats into components 2021-08-31 14:38:52 +03:00
bors[bot]
545cdf955e
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>
2021-08-31 11:24:30 +00:00
Jonas Schievink
8c9de51fa3 Simplify int_in_range 2021-08-31 13:11:17 +02:00
Jonas Schievink
8969cbb22f Depend on both crates individually 2021-08-31 13:10:16 +02:00
bors[bot]
70dbf35712
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>
2021-08-31 09:11:53 +00:00
Oliver Cooper
0517247bbc Don't filter cargo tasks by scope
Fixes #9093
2021-08-31 20:35:22 +12:00
DropDemBits
3bafb5f025
feat: Use enum's visibility for extracted struct fields 2021-08-30 21:33:19 -04:00
DropDemBits
95bf89d3c8
fix: Keep comments & attrs from enum variant 2021-08-30 21:33:12 -04:00
DropDemBits
681efe6dcb
feat: Properly indent extracted struct and enum 2021-08-30 21:26:21 -04:00
Jonas Schievink
e6255356d2 Fix DNF construction, add proptest 2021-08-30 22:26:35 +02:00
bors[bot]
20f3792d10
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>
2021-08-30 19:35:00 +00:00
bors[bot]
02a3d898e4
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>
2021-08-30 18:55:18 +00:00
nathan.whitaker
e1d86a42fe Add coverage mark for struct init shorthand test 2021-08-30 14:37:03 -04:00
Akshay
e304a623ad fix minor mispelling
find_map misspelt as wind_map
2021-08-30 22:51:14 +05:30
bors[bot]
5c704f11d2
Merge #10088
10088: feat: improve CPU usage r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-30 16:49:13 +00:00
Aleksey Kladov
53d2050085 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).
2021-08-30 19:48:16 +03:00
Aleksey Kladov
9e0203bd69 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.
2021-08-30 19:39:08 +03:00
Aleksey Kladov
a59f344c4f internal: improve consistency
Let's have only one place where we start delayed ops
2021-08-30 19:24:31 +03:00
Aleksey Kladov
6317292cd5 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!
2021-08-30 19:18:48 +03:00
bors[bot]
bb1987b45e
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>
2021-08-30 12:57:39 +00:00