bors[bot] [Sun, 19 Dec 2021 00:17:01 +0000 (00:17 +0000)]
Merge #11054
11054: fix #11049 by removing double trimming r=Veykril a=Heinenen
The `unwrap_trivial_block()` removes the braces around trivial blocks (as the name suggests). This violates the precondition of `update_expr_string()` which removes the first and the last non-whitespace character and thus expects braces to still exist around all blocks.
- we still build a plain VSIX, just in case
- we build the extension on every platform to make the release workflow arguably cleaner
- the Windows VSIX includes the PDB (but let's leave #10371 open until we change the Windows stand-alone release to a ZIP file)
- `npm` doesn't run if started from `xtask`, possibly something related to path mapping; I moved the `npm` calls outside, but..
- the `Patch` thingy doesn't work any more, so you'll end up with a dirty `package.json` of you run `cargo xtask --client-patch-version`; I don't think we should block on this
- there's an untested Alpine build; for better or worse, we special-case `musl` distros as `alpine`
- I tested this as much as I could, but not the publishing and nightly updates
- you can find some sample artifacts under https://github.com/lnicola/rust-analyzer/releases
- we can now run the server from the install location (is Code planning to switch to compressed extensions?), except on NixOS
- Code lets you install a VSIX for the wrong platform (with the results one would expect)
- I don't know what happens if we try to publish a VSIX without a target
This is a relatively risky, but we'll probably have to take our chances with it.
bors[bot] [Sat, 18 Dec 2021 18:32:20 +0000 (18:32 +0000)]
Merge #11047
11047: internal: Prepare Code extension for bundling r=lnicola a=lnicola
CC #10483
This is slightly ugly, but we'll be able to clean it up after ripping the download parts (unless we decide to temporarily drop support for the nightlies).
bors[bot] [Thu, 16 Dec 2021 13:26:16 +0000 (13:26 +0000)]
Merge #11030
11030: Add comma for "move if to guard" r=Veykril a=weirane
As I mentioned in #11017, there is a little issue in the implementation for if branch. This code
```rust
let y = match 92 {
x => {
if x == 0 {$0
false
}
}
_ => true,
};
```
will be transformed to
```rust
let y = match 92 {
x if x == 0 => false
_ => true,
};
```
a comma is missing after the false. I moved the fix from the code handling else branch to above.
bors[bot] [Wed, 15 Dec 2021 23:04:51 +0000 (23:04 +0000)]
Merge #11017
11017: Support "move if to guard" with an else branch r=Veykril a=weirane
Support the assist `move_arm_cond_to_match_guard` when there is an else branch.
I have two questions:
1. How to indent the first line of a match arm? `matcharm.indent()` doesn't seem to work. so I hard coded four spaces here:
https://github.com/weirane/rust-analyzer/blob/95a0de85d5d659e876e731725475f1c022719f31/crates/ide_assists/src/handlers/move_guard.rs#L162-L163
2. I find a little issue in the original implementation, this code
```rust
let y = match 92 {
x => {
if x == 0 {$0
false
}
}
_ => true,
};
```
will be transformed to
```rust
let y = match 92 {
x if x == 0 => false
_ => true,
};
```
a comma is missing after the `false`. Should I also fix that? Or this can go in a separate PR.
bors[bot] [Wed, 15 Dec 2021 22:00:51 +0000 (22:00 +0000)]
Merge #11029
11029: internal: Refactor release workflow to reduce duplication r=lnicola a=lnicola
This reduces duplication by using `matrix` and paves the way for https://github.com/rust-analyzer/rust-analyzer/issues/10483. The `musl` builder is unchanged because it uses a container.
~~We also get rid of the MacOS 11 SDK thing, which is from when most MacOS builders were on 10.~~ Or not, the default is still 10.15.
bors[bot] [Mon, 13 Dec 2021 18:49:06 +0000 (18:49 +0000)]
Merge #10998
10998: Add number representation assists r=Veykril a=errx
Reimplemented assists from this PR https://github.com/rust-analyzer/rust-analyzer/pull/3683 with current APIs.
![image](https://user-images.githubusercontent.com/462486/145726792-47700215-26f2-4fdc-9520-63d1487901e5.png)
![image](https://user-images.githubusercontent.com/462486/145726802-f528a2f7-9159-41d3-b459-fc3fae033e60.png)
I've decided not to add options about size of the groups so behaviour is similar to clippy's.
Minimal number length is also taken from clippy.
bors[bot] [Mon, 13 Dec 2021 15:43:12 +0000 (15:43 +0000)]
Merge #11000
11000: fix: insert whitespaces into assoc items for assist when macro generated r=Veykril a=Veykril
This is obviously only a temporary hack which still produces ugly looking items, but as long as the syntax is valid one can at least have rustfmt fix the formatting again.
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/6588
bors r+
bors[bot] [Sun, 12 Dec 2021 16:38:56 +0000 (16:38 +0000)]
Merge #10995
10995: internal: switch from trait-based TokenSource to simple struct of arrays r=matklad a=matklad
cc #10765
The idea here is to try to simplify the interface as best as we can. The original trait-based approach is a bit over-engineered and hard to debug. Here, we replace callback with just data. The next PR in series will replace the output `TreeSink` trait with data as well.
The biggest drawback here is that we now require to materialize all parser's input up-front. This is a bad fit for macro by example: when you parse `$e:expr`, you might consume only part of the input. However, today's trait-based solution doesn't really help -- we were already materializing the whole thing! So, let's keep it simple!
bors[bot] [Sat, 11 Dec 2021 22:58:49 +0000 (22:58 +0000)]
Merge #10951
10951: feat: assist to generate documentation templates r=Veykril a=numero-744
Closes #10878, #1915 and #4767
Full description is in #10878, better read [the tests](https://github.com/rust-analyzer/rust-analyzer/pull/10951/files#diff-7a64e2efb66b2625443340fcbc96d531baff12c17cc0aaf51885ea94f67de254R424) to understand what this feature does.
- [x] There is one remaining thing about non-`pub` functions, what do you think about it?
- [x] In this PR [empty examples are generated](https://github.com/rust-analyzer/rust-analyzer/pull/10951/files#diff-7a64e2efb66b2625443340fcbc96d531baff12c17cc0aaf51885ea94f67de254R99) for `trait` functions, but maybe no examples should be provided at all.
- [x] If there is already a documentation, add another one with a separator ([currently done](https://github.com/rust-analyzer/rust-analyzer/pull/10951/files#diff-7a64e2efb66b2625443340fcbc96d531baff12c17cc0aaf51885ea94f67de254R74)) or simply disable this assist?
- [x] I will check once more that the generated examples are correct (ie. they are easy to fill before that they are built and tested)
bors[bot] [Sat, 11 Dec 2021 14:58:07 +0000 (14:58 +0000)]
Merge #10956 #10986
10956: minor: Bump deps r=Veykril a=lnicola
bors r+
10986: fix: Fix lint completions not working for unclosed attributes r=Veykril a=Veykril
Fixes #10682
Uses keywords and nested `TokenTree`s as a heuristic to figure out when to stop parsing in case the attribute is unclosed which should work pretty well as attributes are usually followed by either of those.
bors r+
bors[bot] [Sat, 11 Dec 2021 14:49:29 +0000 (14:49 +0000)]
Merge #10877
10877: feat: make hightlighting linear r=matklad a=matklad
In https://youtu.be/qvIZZf5dmTE, we've noticed that AstIdMap does a
linear lookup when going from SyntaxNode to Id. This leads to
accidentally quadratic overall performance. Replace linear lookup with a
O(1) hashmap lookup.
Future work: don't duplicate `SyntaxNodePtr` in `AstIdMap` and switch to
"call site dependency injection" style storage (eg, store a
`HashSet<ErasedFileAstId>`).
See the explanation of the work here on YouTube :-)
As you can see from then benchmark results, this doesn't actually make analysis stats fastre. I am a bit mystified as to why this is happening to be honest.
bors[bot] [Sat, 11 Dec 2021 13:50:55 +0000 (13:50 +0000)]
Merge #10976
10976: fix: Show case-insensitive exact matches instead of fuzzy flyimport for short paths r=Veykril a=Veykril
And raise the fuzzy trigger from 2 to 3 chars. This way we keep the ability of flyimporting short names like `Rc`.
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/6917
bors r+