]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoReplace some String usages with SmolStr in completions
Lukas Wirth [Fri, 5 Nov 2021 11:30:39 +0000 (12:30 +0100)]
Replace some String usages with SmolStr in completions

2 years agoReplace more Name::to_string usages with Name::to_smol_str
Lukas Wirth [Thu, 4 Nov 2021 17:12:05 +0000 (18:12 +0100)]
Replace more Name::to_string usages with Name::to_smol_str

2 years agoMerge #10645
bors[bot] [Thu, 4 Nov 2021 16:31:16 +0000 (16:31 +0000)]
Merge #10645

10645: fix: make `rename` multi-token mapping aware r=Veykril a=spookyvision

Co-authored-by: Anatol Ulrich <anatol.ulrich@ferrous-systems.com>
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
Co-authored-by: Anatol Ulrich <45840+spookyvision@users.noreply.github.com>
2 years agoMerge #10691
bors[bot] [Thu, 4 Nov 2021 05:52:05 +0000 (05:52 +0000)]
Merge #10691

10691: minor: Use array `into_iter` in more places r=lnicola a=lnicola

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoUse array into_iter in more places
Laurențiu Nicola [Wed, 3 Nov 2021 12:21:46 +0000 (14:21 +0200)]
Use array into_iter in more places

2 years agoMerge #10686
bors[bot] [Wed, 3 Nov 2021 20:23:14 +0000 (20:23 +0000)]
Merge #10686

10686: internal: Add `Semantics::original_ast_node` for upmapping nodes out of macro files r=Veykril a=Veykril

Fixes trying to insert imports into macro expanded files which then do text edits on very wrong text ranges.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoAdd Semantics::original_ast_node for upmapping nodes out of macro files
Lukas Wirth [Wed, 3 Nov 2021 20:12:36 +0000 (21:12 +0100)]
Add Semantics::original_ast_node for upmapping nodes out of macro files

2 years agoMerge #10680
bors[bot] [Wed, 3 Nov 2021 16:19:42 +0000 (16:19 +0000)]
Merge #10680

10680: implement Literal::from_str r=jonas-schievink a=spookyvision

this apparently fixes RTIC 0.6's
```rust
#[rtic::app]
mod app {}
```

Co-authored-by: Anatol Ulrich <anatol.ulrich@ferrous-systems.com>
2 years agoimplement Literal::from_str
Anatol Ulrich [Tue, 2 Nov 2021 20:42:17 +0000 (21:42 +0100)]
implement Literal::from_str

2 years agoMerge #10667
bors[bot] [Wed, 3 Nov 2021 14:50:39 +0000 (14:50 +0000)]
Merge #10667

10667: internal: Expose version string of crates from HIR r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoUpdate crates/text_edit/src/lib.rs
Anatol Ulrich [Wed, 3 Nov 2021 14:44:46 +0000 (15:44 +0100)]
Update crates/text_edit/src/lib.rs

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoUpdate crates/ide/src/rename.rs
Anatol Ulrich [Wed, 3 Nov 2021 14:44:32 +0000 (15:44 +0100)]
Update crates/ide/src/rename.rs

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoExpose version string of crates fom HIR
Lukas Wirth [Sat, 30 Oct 2021 14:17:04 +0000 (16:17 +0200)]
Expose version string of crates fom HIR

2 years agoMerge #10596
bors[bot] [Wed, 3 Nov 2021 14:02:10 +0000 (14:02 +0000)]
Merge #10596

10596: internal: Set server status to warning when proc-macro sources change r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10027
![image](https://user-images.githubusercontent.com/3757771/138102552-208d3edf-a843-49e6-9f48-1e911f54a4ba.png)

It feels wrong using the database in this part of the code, but this was the only way to figure out whether a file belongs to a proc-macro that I could think of.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoAdd disjoint check back in TextEdit::union
Lukas Wirth [Wed, 3 Nov 2021 13:42:15 +0000 (14:42 +0100)]
Add disjoint check back in TextEdit::union

2 years agoforgot a dbg
Anatol Ulrich [Wed, 3 Nov 2021 13:21:29 +0000 (14:21 +0100)]
forgot a dbg

2 years agoMerge #10683
bors[bot] [Wed, 3 Nov 2021 07:40:23 +0000 (07:40 +0000)]
Merge #10683

10683: minor: Use `.into_iter()` method on array to avoid dereference r=lnicola a=arzg

Arguably it’s nicer to just use `.into_iter()` instead of iterating over references which are immediately dereferenced.

I also changed the use of `String::from` to `.to_string()` because the latter has around twenty times more usages in rust-analyzer.

Co-authored-by: Aramis Razzaghipour <aramisnoah@gmail.com>
2 years agoUse `.into_iter()` method on array to avoid dereference
Aramis Razzaghipour [Wed, 3 Nov 2021 05:13:47 +0000 (16:13 +1100)]
Use `.into_iter()` method on array to avoid dereference

2 years agoaccept identical Indels when merging; add rename test case
Anatol Ulrich [Tue, 2 Nov 2021 20:38:38 +0000 (21:38 +0100)]
accept identical Indels when merging; add rename test case

2 years agoMerge #10672
bors[bot] [Sun, 31 Oct 2021 10:16:59 +0000 (10:16 +0000)]
Merge #10672

10672: feat: upgrade ubuntu builders r=matklad a=matklad

For `-gnu` triples, use 20.04, the current LTS. This upgrades the
required version of glibc. For musl, just use `latest` as, presumably,
we don't care about glibc version in that case.

Hopefully, this unbreaks nightly publishing!

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agominor: group -gnu builders together
Aleksey Kladov [Sun, 31 Oct 2021 10:07:30 +0000 (13:07 +0300)]
minor: group -gnu builders together

2 years agofeat: upgrade ubuntu builders
Aleksey Kladov [Sun, 31 Oct 2021 10:05:40 +0000 (13:05 +0300)]
feat: upgrade ubuntu builders

For `-gnu` triples, use 20.04, the current LTS. This upgrades the
required version of glibc. For musl, just use `latest` as, presumably,
we don't care about glibc version in that case.

2 years agoMerge #10671
bors[bot] [Sun, 31 Oct 2021 08:50:24 +0000 (08:50 +0000)]
Merge #10671

10671: minor: Run apt-get update for AArch64 builds r=lnicola a=lnicola

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoRun apt-get update for AArch64 builds
Laurențiu Nicola [Sun, 31 Oct 2021 08:49:43 +0000 (10:49 +0200)]
Run apt-get update for AArch64 builds

2 years agoMerge #10668
bors[bot] [Sat, 30 Oct 2021 14:42:53 +0000 (14:42 +0000)]
Merge #10668

10668: fix: Fix for-loop expressions breaking with BlockExpr iterable r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoFix for-loop expressions breaking with BlockExpr iterable
Lukas Wirth [Sat, 30 Oct 2021 14:37:32 +0000 (16:37 +0200)]
Fix for-loop expressions breaking with BlockExpr iterable

2 years agoSet server status to warning when proc-macro sources change
Lukas Wirth [Wed, 20 Oct 2021 13:29:50 +0000 (15:29 +0200)]
Set server status to warning when proc-macro sources change

2 years agoMerge #10663
bors[bot] [Sat, 30 Oct 2021 06:03:26 +0000 (06:03 +0000)]
Merge #10663

10663: minor: Bump `object` avoid a duplicate dependency r=lnicola a=lnicola

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoBump object avoid a duplicate dependency
Laurențiu Nicola [Sat, 30 Oct 2021 06:02:45 +0000 (09:02 +0300)]
Bump object avoid a duplicate dependency

2 years agoMerge #10650
bors[bot] [Fri, 29 Oct 2021 20:27:51 +0000 (20:27 +0000)]
Merge #10650

10650: minor: Bump deps r=lnicola a=lnicola

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoBump chalk
Laurențiu Nicola [Wed, 27 Oct 2021 15:12:30 +0000 (18:12 +0300)]
Bump chalk

2 years agoBump some deps
Laurențiu Nicola [Wed, 27 Oct 2021 15:10:58 +0000 (18:10 +0300)]
Bump some deps

2 years agoMerge #10662
bors[bot] [Fri, 29 Oct 2021 16:16:13 +0000 (16:16 +0000)]
Merge #10662

10662: Fix Plaintext textDocument/hover r=Veykril a=vsrs

Relates to #10028

Note: the PR corrects only invalid content kind, not formatting.

Co-authored-by: vsrs <vit@conrlab.com>
2 years agoFix Plaintext textDocument/hover
vsrs [Fri, 29 Oct 2021 15:22:48 +0000 (18:22 +0300)]
Fix Plaintext textDocument/hover

2 years agoMerge #10648
bors[bot] [Fri, 29 Oct 2021 13:13:12 +0000 (13:13 +0000)]
Merge #10648

10648: fix: Don't discard attributed items when a proc-macro unexpectedly fails to expand r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoDon't discard attributed items when a proc-macro unexpectedly fails to expand
Lukas Wirth [Wed, 27 Oct 2021 12:35:58 +0000 (14:35 +0200)]
Don't discard attributed items when a proc-macro unexpectedly fails to expand

2 years agoMerge #10657
bors[bot] [Fri, 29 Oct 2021 13:01:49 +0000 (13:01 +0000)]
Merge #10657

10657: feat: Make unqualified derive attributes flyimportable r=Veykril a=Veykril

![UuwpKODbpB](https://user-images.githubusercontent.com/3757771/139436613-1e6eb8fd-f591-4fca-9383-ff7408ee9b18.gif)
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10052

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agofeat: Make unqualified derive attributes flyimportable
Lukas Wirth [Thu, 28 Oct 2021 17:19:30 +0000 (19:19 +0200)]
feat: Make unqualified derive attributes flyimportable

2 years agoMerge #10595
bors[bot] [Fri, 29 Oct 2021 10:40:43 +0000 (10:40 +0000)]
Merge #10595

10595: internal: Fix a format error r=Veykril a=dzvon

Fixes #10581

Co-authored-by: Dezhi Wu <wu543065657@163.com>
2 years agoFix: correct markdown link form.
Dezhi Wu [Fri, 29 Oct 2021 10:25:32 +0000 (18:25 +0800)]
Fix: correct markdown link form.

2 years agoFix: use a concise way to change link form when generating package.json
Dezhi Wu [Fri, 29 Oct 2021 02:00:10 +0000 (10:00 +0800)]
Fix: use a concise way to change link form when generating package.json

2 years agoMerge #10656
bors[bot] [Thu, 28 Oct 2021 16:49:55 +0000 (16:49 +0000)]
Merge #10656

10656: fix: Enable auto-import and qualify-path in derive attributes r=Veykril a=Veykril

cc https://github.com/rust-analyzer/rust-analyzer/issues/10052

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoEnable auto-import and qualify-path in derive attributes
Lukas Wirth [Thu, 28 Oct 2021 16:40:38 +0000 (18:40 +0200)]
Enable auto-import and qualify-path in derive attributes

2 years agoMerge #10654
bors[bot] [Thu, 28 Oct 2021 15:08:33 +0000 (15:08 +0000)]
Merge #10654

10654: internal: Refactor ide handling for paths in derive inputs r=Veykril a=Veykril

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoRefactor ide handling for paths in derive inputs
Lukas Wirth [Thu, 28 Oct 2021 14:13:37 +0000 (16:13 +0200)]
Refactor ide handling for paths in derive inputs

2 years agoMerge #10623
bors[bot] [Thu, 28 Oct 2021 10:32:13 +0000 (10:32 +0000)]
Merge #10623

10623: internal: replace L_DOLLAR/R_DOLLAR with parenthesis hack r=matklad a=matklad

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.

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agoFix: transform the asciidoc form link to markdown style when generating the package...
Dezhi Wu [Thu, 28 Oct 2021 02:13:43 +0000 (10:13 +0800)]
Fix: transform the asciidoc form link to markdown style when generating the package.json

2 years agoMerge #10629
bors[bot] [Wed, 27 Oct 2021 21:40:28 +0000 (21:40 +0000)]
Merge #10629

10629: Add assist for replacing turbofish with explicit type. r=Veykril a=terrynsun

Converts `::<_>` to an explicit type assignment.

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

Closes #10285

Co-authored-by: Terry Sun <terrynsun@gmail.com>
2 years agofixup! rustfmt
Terry Sun [Wed, 27 Oct 2021 17:58:31 +0000 (10:58 -0700)]
fixup! rustfmt

2 years agofixup! delay to_string() until assist is called
Terry Sun [Wed, 27 Oct 2021 17:46:25 +0000 (10:46 -0700)]
fixup! delay to_string() until assist is called

2 years agoMerge #10649
bors[bot] [Wed, 27 Oct 2021 15:38:42 +0000 (15:38 +0000)]
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>
2 years agoremove TODO comment
Anatol Ulrich [Wed, 27 Oct 2021 15:26:38 +0000 (17:26 +0200)]
remove TODO comment

2 years agore-introduce `always!`
Anatol Ulrich [Wed, 27 Oct 2021 15:25:37 +0000 (17:25 +0200)]
re-introduce `always!`

2 years agoRemove `CompletionKind` in favor of `CompletionItemKind`
Lukas Wirth [Wed, 27 Oct 2021 15:18:42 +0000 (17:18 +0200)]
Remove `CompletionKind` in favor of `CompletionItemKind`

2 years agounwrap--
Anatol Ulrich [Wed, 27 Oct 2021 15:23:23 +0000 (17:23 +0200)]
unwrap--

2 years agofix logic error: alias detection was too lenient
Anatol Ulrich [Wed, 27 Oct 2021 15:20:12 +0000 (17:20 +0200)]
fix logic error: alias detection was too lenient

2 years agoRemove filtered completion list usage in completion tests
Lukas Wirth [Wed, 27 Oct 2021 14:24:42 +0000 (16:24 +0200)]
Remove filtered completion list usage in completion tests

2 years agowip
Anatol Ulrich [Wed, 27 Oct 2021 13:40:49 +0000 (15:40 +0200)]
wip

2 years agoremove resolved TODO questions
Anatol Ulrich [Wed, 27 Oct 2021 13:40:00 +0000 (15:40 +0200)]
remove resolved TODO questions

2 years agodoxx
Anatol Ulrich [Wed, 27 Oct 2021 02:46:02 +0000 (04:46 +0200)]
doxx

2 years agoone down
Anatol Ulrich [Wed, 27 Oct 2021 02:42:58 +0000 (04:42 +0200)]
one down

2 years agomake imports less odd
Anatol Ulrich [Wed, 27 Oct 2021 02:36:32 +0000 (04:36 +0200)]
make imports less odd

2 years agoWIP: fix: make `rename` multi-token mapping aware
Anatol Ulrich [Wed, 27 Oct 2021 02:31:14 +0000 (04:31 +0200)]
WIP: fix: make `rename` multi-token mapping aware

2 years agofixup! narrow range; method calls; check for only one type
Terry Sun [Wed, 27 Oct 2021 00:48:01 +0000 (17:48 -0700)]
fixup! narrow range; method calls; check for only one type

2 years agoMerge #10642
bors[bot] [Tue, 26 Oct 2021 18:55:42 +0000 (18:55 +0000)]
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>
2 years agoAdd dummy impls for `trace_macros` and `log_syntax`
Lukas Wirth [Tue, 26 Oct 2021 18:52:38 +0000 (20:52 +0200)]
Add dummy impls for `trace_macros` and `log_syntax`

2 years agoMerge #10641
bors[bot] [Tue, 26 Oct 2021 18:18:22 +0000 (18:18 +0000)]
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>
2 years agoUpdate crates/ide/src/expand_macro.rs
Anatol Ulrich [Tue, 26 Oct 2021 18:17:47 +0000 (20:17 +0200)]
Update crates/ide/src/expand_macro.rs

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agofix test
Anatol Ulrich [Tue, 26 Oct 2021 18:15:25 +0000 (20:15 +0200)]
fix test

2 years agowording
Anatol Ulrich [Tue, 26 Oct 2021 18:10:09 +0000 (20:10 +0200)]
wording

2 years agofix: make `expand_macro` multi-token mapping aware
Anatol Ulrich [Tue, 26 Oct 2021 18:09:14 +0000 (20:09 +0200)]
fix: make `expand_macro` multi-token mapping aware

2 years agoMerge #10639 #10640
bors[bot] [Tue, 26 Oct 2021 17:51:33 +0000 (17:51 +0000)]
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>
2 years agoassume valid identifier
Anatol Ulrich [Tue, 26 Oct 2021 17:33:50 +0000 (19:33 +0200)]
assume valid identifier

2 years agofix: make `goto_declaration` multi-token mapping aware
Anatol Ulrich [Tue, 26 Oct 2021 17:31:49 +0000 (19:31 +0200)]
fix: make `goto_declaration` multi-token mapping aware

2 years agoMerge #10592
bors[bot] [Tue, 26 Oct 2021 13:17:13 +0000 (13:17 +0000)]
Merge #10592

10592: Fix: only shows one # when we encounter ## r=Veykril a=dzvon

Fixes #10584

Co-authored-by: Dezhi Wu <wu543065657@163.com>
2 years agoperf: avoid allocating by just slicing.
Dezhi Wu [Tue, 26 Oct 2021 12:55:58 +0000 (20:55 +0800)]
perf: avoid allocating by just slicing.

Signed-off-by: Dezhi Wu <wu543065657@163.com>
2 years agoMerge #10637
bors[bot] [Tue, 26 Oct 2021 10:46:33 +0000 (10:46 +0000)]
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>
2 years agofix imports
Anatol Ulrich [Tue, 26 Oct 2021 10:34:40 +0000 (12:34 +0200)]
fix imports

2 years agosimplify
Anatol Ulrich [Tue, 26 Oct 2021 10:21:18 +0000 (12:21 +0200)]
simplify

2 years agofix: make `goto_type_definition` multi-token mapping aware
Anatol Ulrich [Mon, 25 Oct 2021 21:43:58 +0000 (23:43 +0200)]
fix: make `goto_type_definition` multi-token mapping aware

2 years agoMerge #10635
bors[bot] [Mon, 25 Oct 2021 19:47:41 +0000 (19:47 +0000)]
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>
2 years agofix: fix extract_variable not working on macro_call
Lukas Wirth [Mon, 25 Oct 2021 16:28:15 +0000 (18:28 +0200)]
fix: fix extract_variable not working on macro_call

2 years agoMerge #10633
bors[bot] [Mon, 25 Oct 2021 15:33:41 +0000 (15:33 +0000)]
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>
2 years agoMerge #10634
bors[bot] [Mon, 25 Oct 2021 15:13:34 +0000 (15:13 +0000)]
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>
2 years agoDrop resolver and authors manifest entries
Laurențiu Nicola [Mon, 25 Oct 2021 15:09:34 +0000 (18:09 +0300)]
Drop resolver and authors manifest entries

2 years agofix: Implement most proc_macro span handling for other ABIs
Lukas Wirth [Mon, 25 Oct 2021 14:43:04 +0000 (16:43 +0200)]
fix: Implement most proc_macro span handling for other ABIs

2 years agoMerge #10631
bors[bot] [Mon, 25 Oct 2021 13:24:07 +0000 (13:24 +0000)]
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>
2 years agoFix postfix completions panicking
Lukas Wirth [Mon, 25 Oct 2021 13:22:29 +0000 (15:22 +0200)]
Fix postfix completions panicking

2 years agoMerge #10630
bors[bot] [Mon, 25 Oct 2021 12:50:17 +0000 (12:50 +0000)]
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>
2 years agoDon't ask the user to reload when chaning HoverAction configs in VSCode
Lukas Wirth [Mon, 25 Oct 2021 12:48:36 +0000 (14:48 +0200)]
Don't ask the user to reload when chaning HoverAction configs in VSCode

2 years agoAdd assist for replacing turbofish with explicit type.
Terry Sun [Sun, 24 Oct 2021 20:34:02 +0000 (13:34 -0700)]
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

2 years agoMerge #10624
bors[bot] [Sun, 24 Oct 2021 11:53:51 +0000 (11:53 +0000)]
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>
2 years agoRevert edition change in test
Laurențiu Nicola [Sun, 24 Oct 2021 11:52:42 +0000 (14:52 +0300)]
Revert edition change in test

2 years agointernal: remove unused dollars
Aleksey Kladov [Sat, 23 Oct 2021 17:43:45 +0000 (20:43 +0300)]
internal: remove unused dollars

2 years agointernal: replace L_DOLLAR/R_DOLLAR with parenthesis hack
Aleksey Kladov [Sat, 23 Oct 2021 17:08:42 +0000 (20:08 +0300)]
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.

2 years agoMerge #10617
bors[bot] [Sat, 23 Oct 2021 13:30:32 +0000 (13:30 +0000)]
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>
2 years agoSet MSRV
Laurențiu Nicola [Sat, 23 Oct 2021 12:07:11 +0000 (15:07 +0300)]
Set MSRV

2 years agoMerge #10602
bors[bot] [Sat, 23 Oct 2021 08:34:51 +0000 (08:34 +0000)]
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>
2 years agoMerge #9939
bors[bot] [Fri, 22 Oct 2021 09:29:16 +0000 (09:29 +0000)]
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>
2 years agofix: making tests compatible with new trimmed sel_range
vi_mi [Fri, 22 Oct 2021 08:55:47 +0000 (08:55 +0000)]
fix: making tests compatible with new trimmed sel_range