Commit graph

19863 commits

Author SHA1 Message Date
Terry Sun
3bbd61d674 fixup! delay to_string() until assist is called 2021-10-27 10:46:25 -07:00
bors[bot]
9d1f15086a
Merge #10649
10649: internal: Remove `CompletionKind` in favor of `CompletionItemKind` r=Veykril a=Veykril

and move some more tests around
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-27 15:38:42 +00:00
Anatol Ulrich
1ac35532c4 remove TODO comment 2021-10-27 17:26:38 +02:00
Anatol Ulrich
df9fb9b159 re-introduce always! 2021-10-27 17:25:42 +02:00
Lukas Wirth
0468b11de7 Remove CompletionKind in favor of CompletionItemKind 2021-10-27 17:23:43 +02:00
Anatol Ulrich
28c73f8374 unwrap-- 2021-10-27 17:23:23 +02:00
Anatol Ulrich
4a1a5ff54e fix logic error: alias detection was too lenient 2021-10-27 17:20:12 +02:00
Lukas Wirth
722489e3ff Remove filtered completion list usage in completion tests 2021-10-27 16:53:39 +02:00
Anatol Ulrich
6cd15c296d wip 2021-10-27 15:40:49 +02:00
Anatol Ulrich
8d3ac328ee remove resolved TODO questions 2021-10-27 15:40:30 +02:00
Anatol Ulrich
f244ed6a1a doxx 2021-10-27 04:46:02 +02:00
Anatol Ulrich
2e0610e64e one down 2021-10-27 04:42:58 +02:00
Anatol Ulrich
95199ac30b make imports less odd 2021-10-27 04:36:32 +02:00
Anatol Ulrich
6decfceae1 WIP: fix: make rename multi-token mapping aware 2021-10-27 04:31:14 +02:00
Terry Sun
6abdbdd0c9 fixup! narrow range; method calls; check for only one type 2021-10-26 17:50:25 -07:00
bors[bot]
dd43f3f2d1
Merge #10642
10642: minor: Add dummy impls for `trace_macros` and `log_syntax` r=Veykril a=Veykril

Both of these are macros for debugging macros and as such don't really need an implementation for us.
Closes https://github.com/rust-analyzer/rust-analyzer/issues/2212
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-26 18:55:42 +00:00
Lukas Wirth
54e6583f53 Add dummy impls for trace_macros and log_syntax 2021-10-26 20:52:38 +02:00
bors[bot]
a3830dfd3b
Merge #10641
10641: fix: make `expand_macro` multi-token mapping aware r=spookyvision a=spookyvision



Co-authored-by: Anatol Ulrich <anatol.ulrich@ferrous-systems.com>
Co-authored-by: Anatol Ulrich <45840+spookyvision@users.noreply.github.com>
2021-10-26 18:18:22 +00:00
Anatol Ulrich
b42093915a
Update crates/ide/src/expand_macro.rs
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-26 20:17:47 +02:00
Anatol Ulrich
e6913be47b fix test 2021-10-26 20:15:25 +02:00
Anatol Ulrich
04f2eb0fba wording 2021-10-26 20:10:09 +02:00
Anatol Ulrich
3f82989153 fix: make expand_macro multi-token mapping aware 2021-10-26 20:09:14 +02:00
bors[bot]
c48730cb72
Merge #10639 #10640
10639: fix: make `goto_declaration` multi-token mapping aware r=Veykril a=spookyvision



10640: assume valid identifier r=Veykril a=spookyvision

improve https://github.com/rust-analyzer/rust-analyzer/pull/10637/ by always returning `Some(potentially_empty_vec)` instead of `None` in the empty case

Co-authored-by: Anatol Ulrich <anatol.ulrich@ferrous-systems.com>
2021-10-26 17:51:33 +00:00
Anatol Ulrich
53be26df50 assume valid identifier 2021-10-26 19:33:50 +02:00
Anatol Ulrich
d8ed15b6a6 fix: make goto_declaration multi-token mapping aware 2021-10-26 19:31:49 +02:00
bors[bot]
ba2b599131
Merge #10592
10592: Fix: only shows one # when we encounter ## r=Veykril a=dzvon

Fixes #10584

Co-authored-by: Dezhi Wu <wu543065657@163.com>
2021-10-26 13:17:13 +00:00
Dezhi Wu
31af94b73a perf: avoid allocating by just slicing.
Signed-off-by: Dezhi Wu <wu543065657@163.com>
2021-10-26 20:59:48 +08:00
bors[bot]
ee1d6cffbf
Merge #10637
10637: fix: make `goto_type_definition` multi-token mapping aware r=Veykril a=spookyvision



Co-authored-by: Anatol Ulrich <anatol.ulrich@ferrous-systems.com>
2021-10-26 10:46:33 +00:00
Anatol Ulrich
c69879423e fix imports 2021-10-26 12:34:40 +02:00
Anatol Ulrich
686f8fbea3 simplify 2021-10-26 12:21:18 +02:00
Anatol Ulrich
2490807ca5 fix: make goto_type_definition multi-token mapping aware 2021-10-25 23:43:58 +02:00
bors[bot]
ed39b45e8d
Merge #10635
10635: fix: fix extract_variable not working on macro_call r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-25 19:47:41 +00:00
Lukas Wirth
a2365ea18a fix: fix extract_variable not working on macro_call 2021-10-25 21:46:44 +02:00
bors[bot]
e4ca952be6
Merge #10633
10633: fix: Implement most proc_macro span handling for other ABIs r=Veykril a=Veykril

Follow up to #10378
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-25 15:33:41 +00:00
bors[bot]
aa04d3eb4f
Merge #10634
10634: minor: Drop resolver and `authors` manifest entry in `limit` r=lnicola a=lnicola

The new resolver is on by default in the 2021 edition,

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-10-25 15:13:34 +00:00
Laurențiu Nicola
0e0ad0377c Drop resolver and authors manifest entries 2021-10-25 18:12:40 +03:00
Lukas Wirth
d2b8ca9b52 fix: Implement most proc_macro span handling for other ABIs 2021-10-25 16:43:49 +02:00
bors[bot]
142b6dc650
Merge #10631
10631: fix: Fix postfix completions panicking r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10243, I couldn't reproduce the panic with the given snippet, but this change should still guard against it.
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-25 13:24:07 +00:00
Lukas Wirth
a932935d4e Fix postfix completions panicking 2021-10-25 15:22:29 +02:00
bors[bot]
e81e3c3980
Merge #10630
10630: fix: Don't ask the user to reload when chaning HoverAction configs in VSCode r=Veykril a=Veykril

To my knowledge, all of these are re-read on hover requests so there is no longer a reason to reload when changing these.
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-25 12:50:17 +00:00
Lukas Wirth
4c582ffe9f Don't ask the user to reload when chaning HoverAction configs in VSCode 2021-10-25 14:48:36 +02:00
Terry Sun
324d7d33e8 Add assist for replacing turbofish with explicit type.
Converts `::<_>` to an explicit type assignment.

```
let args = args.collect::<Vec<String>>();
```
->
```
let args: Vec<String> = args.collect();
```

Closes #10285
2021-10-24 17:38:45 -07:00
bors[bot]
1f47693e02
Merge #10624
10624: minor: revert edition change in test r=lnicola a=lnicola

Fixes https://github.com/rust-analyzer/rust-analyzer/pull/10607#discussion_r734963606

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-10-24 11:53:51 +00:00
Laurențiu Nicola
f0ad6fa68b Revert edition change in test 2021-10-24 14:52:42 +03:00
Aleksey Kladov
485c5e6717 internal: remove unused dollars 2021-10-23 20:44:35 +03:00
Aleksey Kladov
5a83d1be66 internal: replace L_DOLLAR/R_DOLLAR with parenthesis hack
The general problem we are dealing with here is this:

```
macro_rules! thrice {
    ($e:expr) => { $e * 3}
}

fn main() {
    let x = thrice!(1 + 2);
}
```

we really want this to print 9 rather than 7.

The way rustc solves this is rather ad-hoc. In rustc, token trees are
allowed to include whole AST fragments, so 1+2 is passed through macro
expansion as a single unit. This is a significant violation of token
tree model.

In rust-analyzer, we intended to handle this in a more elegant way,
using token trees with "invisible" delimiters. The idea was is that we
introduce a new kind of parenthesis, "left $"/"right $", and let the
parser intelligently handle this.

The idea was inspired by the relevant comment in the proc_macro crate:

https://doc.rust-lang.org/stable/proc_macro/enum.Delimiter.html#variant.None

> An implicit delimiter, that may, for example, appear around tokens
> coming from a “macro variable” $var. It is important to preserve
> operator priorities in cases like $var * 3 where $var is 1 + 2.
> Implicit delimiters might not survive roundtrip of a token stream
> through a string.

Now that we are older and wiser, we conclude that the idea doesn't work.

_First_, the comment in the proc-macro crate is wishful thinking. Rustc
currently completely ignores none delimiters. It solves the (1 + 2) * 3
problem by having magical token trees which can't be duplicated:

* https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/TIL.20that.20token.20streams.20are.20magic
* https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Handling.20of.20Delimiter.3A.3ANone.20by.20the.20parser

_Second_, it's not like our implementation in rust-analyzer works. We
special-case expressions (as opposed to treating all kinds of $var
captures the same) and we don't know how parser error recovery should
work with these dollar-parenthesis.

So, in this PR we simplify the whole thing away by not pretending that
we are doing something proper and instead just explicitly special-casing
expressions by wrapping them into real `()`.

In the future, to maintain bug-parity with `rustc` what we are going to
do is probably adding an explicit `CAPTURED_EXPR` *token* which we can
explicitly account for in the parser.

If/when rustc starts handling delimiter=none properly, we'll port that
logic as well, in addition to special handling.
2021-10-23 20:44:31 +03:00
bors[bot]
9d33d05d85
Merge #10617
10617: Set MSRV r=Veykril a=lnicola

Set the MSRV to `1.56` since we're already on the 2021 edition and building with older version fails.

From now on, there'll be a change in behavior: `xtask install` used to warn on old toolchains, but now the user will get an error. This isn't so bad because:

 - the check in `xtask install` wasn't always working (because sometimes `xtask` itself required a newer toolchain)
 - we generally bump the required version for a reason (when using a newer feature). We might forget to bump it, but when we do, older toolchains won't work

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-10-23 13:30:32 +00:00
Laurențiu Nicola
8457ae34bd Set MSRV 2021-10-23 15:07:11 +03:00
bors[bot]
fe7c516084
Merge #10602
10602: Add qualify method call assist r=Veykril a=qepasa

This adds `qualify_method_call` assist that allows to replace a method (or trait) call that resolves with its fully qualified path.

For example, for stuct method:
```rust
struct Foo;
impl Foo {
    fn foo(&self) {}
}
```
```
let foo = Foo {};
foo.fo$0o();
```

becomes
```rust
let foo = Foo {};
Foo::foo(&foo);
```

for a trait method:

```rust
struct Foo;
trait FooTrait {
    fn foo(&self) {}
}
impl FooTrait for Foo {
    fn foo(&self) {}
}
```
following call:
```rust
let foo = Foo {};
foo.fo$0o();
```

becomes:
```rust
let foo = Foo {};
FooTrait::foo(&foo);
```

fixes #10453 

Co-authored-by: Paweł Palenica <pawelpalenica11@gmail.com>
2021-10-23 08:34:51 +00:00
bors[bot]
a75353e8ac
Merge #9939
9939: feat: Adding extract_module assist r=Veykril a=feniljain

Should solve https://github.com/rust-analyzer/rust-analyzer/issues/9591

Co-authored-by: vi_mi <fenil.jain2018@vitstudent.ac.in>
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-10-22 09:29:16 +00:00