Commit graph

19863 commits

Author SHA1 Message Date
Lukas Wirth
addd93ed9a Don't search for root nodes unnecessarily 2021-11-05 15:52:10 +01:00
Lukas Wirth
8dad1b9228 Don't check items for macro calls if they have no attributes 2021-11-05 14:50:10 +01:00
Lukas Wirth
af4d244462 Cache ast::MacroCalls to their expansions in Semantics::descend_into_macros_impl 2021-11-05 14:25:47 +01:00
bors[bot]
962be38004
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>
2021-11-04 16:31:16 +00:00
bors[bot]
c96481e25f
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>
2021-11-04 05:52:05 +00:00
Laurențiu Nicola
139bf9b4e1 Use array into_iter in more places 2021-11-04 07:51:20 +02:00
bors[bot]
a8247685cf
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>
2021-11-03 20:23:14 +00:00
Lukas Wirth
96db0d8bdd Add Semantics::original_ast_node for upmapping nodes out of macro files 2021-11-03 21:12:36 +01:00
bors[bot]
9ee855bcc5
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>
2021-11-03 16:19:42 +00:00
Anatol Ulrich
a6df2b16df implement Literal::from_str 2021-11-03 16:50:43 +01:00
bors[bot]
0bd2d234a2
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>
2021-11-03 14:50:39 +00:00
Anatol Ulrich
e8416bb644
Update crates/text_edit/src/lib.rs
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-03 15:44:46 +01:00
Anatol Ulrich
83927e08a8
Update crates/ide/src/rename.rs
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-03 15:44:32 +01:00
Lukas Wirth
52f5af7165 Expose version string of crates fom HIR 2021-11-03 15:40:06 +01:00
bors[bot]
53b5b2fdaa
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>
2021-11-03 14:02:10 +00:00
Lukas Wirth
9025f51118 Add disjoint check back in TextEdit::union 2021-11-03 14:42:15 +01:00
Anatol Ulrich
7581ba3f30 forgot a dbg 2021-11-03 14:21:29 +01:00
bors[bot]
71f5dae4b6
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>
2021-11-03 07:40:23 +00:00
Aramis Razzaghipour
16d38ec8b8
Use .into_iter() method on array to avoid dereference 2021-11-03 16:13:47 +11:00
Anatol Ulrich
9bce4d6696 accept identical Indels when merging; add rename test case 2021-11-02 21:38:38 +01:00
bors[bot]
04f03a360a
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>
2021-10-31 10:16:59 +00:00
Aleksey Kladov
045be6545f minor: group -gnu builders together 2021-10-31 13:16:36 +03:00
Aleksey Kladov
a4b40e60cb 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.
2021-10-31 13:16:36 +03:00
bors[bot]
eb32b60dc7
Merge #10671
10671: minor: Run apt-get update for AArch64 builds r=lnicola a=lnicola



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-10-31 08:50:24 +00:00
Laurențiu Nicola
d6c162e40f Run apt-get update for AArch64 builds 2021-10-31 10:49:43 +02:00
bors[bot]
7765c1a94f
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>
2021-10-30 14:42:53 +00:00
Lukas Wirth
c93983e76f Fix for-loop expressions breaking with BlockExpr iterable 2021-10-30 16:37:32 +02:00
Lukas Wirth
1d80302b76 Set server status to warning when proc-macro sources change 2021-10-30 14:49:32 +02:00
bors[bot]
3ad83cc08d
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>
2021-10-30 06:03:26 +00:00
Laurențiu Nicola
80f9afa1ec Bump object avoid a duplicate dependency 2021-10-30 09:02:45 +03:00
bors[bot]
103bef178c
Merge #10650
10650: minor: Bump deps r=lnicola a=lnicola



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-10-29 20:27:51 +00:00
Laurențiu Nicola
d0a99ad54e Bump chalk 2021-10-29 23:26:59 +03:00
Laurențiu Nicola
79d3f61590 Bump some deps 2021-10-29 23:26:58 +03:00
bors[bot]
8c078147b5
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>
2021-10-29 16:16:13 +00:00
vsrs
2f862cd6fe Fix Plaintext textDocument/hover 2021-10-29 18:23:47 +03:00
bors[bot]
b9fa37f5b4
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>
2021-10-29 13:13:12 +00:00
Lukas Wirth
98cff6572d Don't discard attributed items when a proc-macro unexpectedly fails to expand 2021-10-29 15:10:44 +02:00
bors[bot]
78108235d5
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>
2021-10-29 13:01:49 +00:00
Lukas Wirth
ebd63ec1cf feat: Make unqualified derive attributes flyimportable 2021-10-29 14:51:26 +02:00
bors[bot]
057558b756
Merge #10595
10595: internal: Fix a format error r=Veykril a=dzvon

Fixes #10581

Co-authored-by: Dezhi Wu <wu543065657@163.com>
2021-10-29 10:40:43 +00:00
Dezhi Wu
74396d27c0 Fix: correct markdown link form. 2021-10-29 18:25:32 +08:00
Dezhi Wu
097d527cbd Fix: use a concise way to change link form when generating package.json 2021-10-29 10:00:10 +08:00
bors[bot]
b025bd6e7d
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>
2021-10-28 16:49:55 +00:00
Lukas Wirth
7fdbdc4ab2 Enable auto-import and qualify-path in derive attributes 2021-10-28 18:40:38 +02:00
bors[bot]
166c0ac0de
Merge #10654
10654: internal: Refactor ide handling for paths in derive inputs r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-28 15:08:33 +00:00
Lukas Wirth
3018ffd85e Refactor ide handling for paths in derive inputs 2021-10-28 16:47:19 +02:00
bors[bot]
f4ba64ee2a
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>
2021-10-28 10:32:13 +00:00
Dezhi Wu
ffc6cdd871 Fix: transform the asciidoc form link to markdown style when generating the package.json 2021-10-28 10:13:43 +08:00
bors[bot]
210a1d5ece
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>
2021-10-27 21:40:28 +00:00
Terry Sun
d800a1bc93 fixup! rustfmt 2021-10-27 10:58:31 -07:00