Commit graph

28424 commits

Author SHA1 Message Date
David Mládek
4d9346922a Clear diagnostics only after new ones were received 2024-05-17 01:30:01 +02:00
bors
83ba420431 Auto merge of #17243 - Veykril:static-lt-hir, r=Veykril
internal: Add StaticLifetime to hir API
2024-05-16 06:04:52 +00:00
Lukas Wirth
aaa5426fec internal: Add StaticLifetime to hir API 2024-05-16 08:02:51 +02:00
bors
b5626032bd Auto merge of #17241 - blyxyas:fix-typos, r=lnicola
Chore: Fix some typos

https://github.com/rust-lang/rust/pull/124948

> In RA we gladly take typo fixes, but for now we definitely want them in the upstream repository.
2024-05-15 17:00:46 +00:00
blyxyas
66f62836ae Fix typos 2024-05-15 18:55:27 +02:00
bors
d922999ec6 Auto merge of #17240 - Veykril:metrics-caching-fix, r=Veykril
Use actions/cache again in metrics CI

The other one overwrites the target cache again which we don't want
2024-05-15 13:27:20 +00:00
Lukas Wirth
abb3ed5db6 Use actions/cache again in metrics CI 2024-05-15 15:25:58 +02:00
bors
9bc68735aa Auto merge of #17239 - Veykril:metrics-caching, r=Veykril
internal: Key ignoring the job-id in metrics cache
2024-05-15 11:32:48 +00:00
Lukas Wirth
7d5fc43645 Key ignoring the job-id in metrics cache 2024-05-15 13:31:11 +02:00
bors
8772b865c9 Auto merge of #17238 - Veykril:metrics-caching, r=Veykril
Fix metrics workflow not actually updating the toolchain

The install won't persist across jobs
2024-05-15 10:57:26 +00:00
Lukas Wirth
aab1bd1a83 Fix metrics workflow not actually updating the toolchain 2024-05-15 12:54:24 +02:00
bors
6095cbf14d Auto merge of #17235 - Veykril:metrics-caching, r=Veykril
internal: Use Swatinem/rust-cache for metrics CI

Current metrics caching uses a base cache action, whereas I think the one we use for general ci works here as well. Saw this while noticing that our metrics CI is broken as it for some reason uses an outdated rust stable? (unsure why that is)
2024-05-15 09:36:33 +00:00
Lukas Wirth
2689867ee5 Bump Swatinem/rust-cache 2024-05-15 09:50:34 +02:00
Lukas Wirth
31aba7ac3c Use Swatinem/rust-cache for metrics CI 2024-05-15 09:49:42 +02:00
bors
c0732c9f0f Auto merge of #17232 - Veykril:build-scripts-keep-going, r=Veykril
fix: Don't emit --keep-going for custom build script commands

Might be the cause for https://github.com/rust-lang/rust-analyzer/issues/17231
2024-05-14 19:28:22 +00:00
Lukas Wirth
eac2e512a1 fix: Don't emit --keep-going for custom build script commands 2024-05-14 21:26:37 +02:00
bors
07d71c05c3 Auto merge of #17216 - Young-Flash:mod_with_path, r=Veykril
fix: extract mod to file should respect path attribute

close https://github.com/rust-lang/rust-analyzer/issues/17181
2024-05-14 14:29:00 +00:00
bors
77c7886283 Auto merge of #17227 - Veykril:build-deps-changed-hashes, r=Veykril
fix: Hash file contents to verify whether file actually changed

Fixes https://github.com/rust-lang/rust-analyzer/issues/16580
2024-05-14 10:48:18 +00:00
bors
52135cb510 Auto merge of #17228 - Veykril:stable-runnables-order, r=Veykril
internal: Sort computed runnables

Fixes https://github.com/rust-lang/rust-analyzer/issues/17223
2024-05-14 10:35:10 +00:00
Lukas Wirth
465ebbc102 internal: Sort computed runnables 2024-05-14 12:32:48 +02:00
Lukas Wirth
1ca97ba896 Hash file contents to verify whether file actually changed 2024-05-14 11:55:12 +02:00
bors
7afd8d8a1a Auto merge of #17225 - Veykril:expand-macro-interlocked, r=Veykril
Expand macro recursively expands both fp-like and attribute macros when intertwined
2024-05-14 09:22:04 +00:00
Lukas Wirth
793396c624 Track hashes for file contents 2024-05-14 11:21:04 +02:00
bors
d28111dce8 Auto merge of #17224 - Veykril:lock-bump, r=Veykril
Bump Cargo.lock
2024-05-14 08:59:34 +00:00
Lukas Wirth
580b8dab1a Expand macro recursively expands both fp-like and attribute macros intertwined 2024-05-14 10:58:18 +02:00
Lukas Wirth
2a4be8d1f7 Bump Cargo.lock 2024-05-14 10:57:02 +02:00
bors
b98690ba74 Auto merge of #17221 - Veykril:lazier-validation, r=Veykril
internal: Lazier macro parse tree validation
2024-05-13 15:16:46 +00:00
Lukas Wirth
caddcccea5 parse_macro_expansion_error almost never contains values so Option it 2024-05-13 17:02:08 +02:00
Lukas Wirth
56552f4839 Push macro-parsing error calculation out of fundamental queries 2024-05-13 16:56:26 +02:00
bors
40ab5e5f8c Auto merge of #17220 - Veykril:hov-lit, r=Veykril
fix: Improve confusing literal hovers
2024-05-13 10:58:29 +00:00
Lukas Wirth
5b696bac5c Don't render multi-line literal values 2024-05-13 12:56:02 +02:00
Lukas Wirth
a39c0493a1 Render literal escaping errors in hovers 2024-05-13 12:51:57 +02:00
bors
9db1258dbe Auto merge of #17203 - kilpkonn:collapse_terms, r=Veykril
Fix OOM caused by term search

The issue came from multi Cartesian product for exprs with many (25+) arguments, each having multiple options.
The solution is two fold:
### Avoid blowing up in Cartesian product
**Before the logic was:**
    1. Find expressions for each argument/param - there may be many
    2. Take the Cartesian product (which blows up in some cases)
    4. If there are more than 2 options throw them away by squashing them to `Many`
**Now the logic is:**
    1. Find expressions for each argument/param and squash them to `Many` if there are more than 2 as otherwise we are guaranteed to also have more than 2 after taking the product which means squashing them anyway.
    2. Take the Cartesian product on iterator
    3. Start consuming it one by one
    4. If there are more than 2 options throw them away by squashing them to `Many`  (same as before)

This is also why I had to update some tests as the expressions get squashed to many more eagerly.

### Use fuel to avoid long search times and high memory usage
Now all the tactics use `should_continue:  Fn() -> bool` to chech if they should keep iterating _(Similarly to chalk)_.
This reduces the search times by a magnitude, for example from ~139ms/hole to ~14ms/hole for `ripgrep` crate.
There are slightly less expressions found, but I think speed gain worth it for usability.
Also note that syntactic hits decreases more because of squashing so you simple need to run search multiple times to get full terms.
Also the worst case time (For example `nalgebra` crate cus it has tons of generics) has search times mostly under 200ms.

Benchmarks on `ripgrep` crate
Before:
```
Tail Expr syntactic hits: 291/1692 (17%)
Tail Exprs found: 1253/1692 (74%)
Term search avg time: 139ms
````
After:
```
Tail Expr syntactic hits: 239/1692 (14%)
Tail Exprs found: 1226/1692 (72%)
Term search avg time: 14ms
```
2024-05-13 10:30:12 +00:00
Lukas Wirth
253929f6ae Fix literal hovers being confusing and wrong for floats 2024-05-13 12:26:45 +02:00
bors
bf53c472ed Auto merge of #17188 - szabgab:patch-1, r=Veykril
use the repository field to link to the repository
2024-05-13 10:16:45 +00:00
bors
7aecf1ae35 Auto merge of #17187 - roife:fix-issue-17185, r=Veykril
fix: keep parentheses when the precedence of inner expr is lower than the outer one

fix #17185

Additionally, this PR simplifies some code in `apply_demorgan`.
2024-05-13 10:03:40 +00:00
bors
067d9d995b Auto merge of #17195 - Veykril:unsafe-attr, r=Veykril
Implement unsafe attribute parsing
2024-05-13 09:50:52 +00:00
Young-Flash
3e57aabf85 test: add test case extract_with_specified_path_attr 2024-05-12 11:48:17 +08:00
Young-Flash
0c13f0cd5b fix: extract mod to file should respect path attribute 2024-05-12 11:48:17 +08:00
bors
5bf2f85c80 Auto merge of #17208 - Wilfred:log_error_from_threads, r=Veykril
fix: Report both IO errors and main_loop errors

If rust-analyzer receives a malformed LSP request, the IO thread terminates with a meaningful error, but then closes the channel.

Once the channel has closed, the main_loop also terminates, but it only has RecvError and can't show a meaningful error. As a result, rust-analyzer would incorrectly claim that the client forgot to shutdown.

```
$ buggy_lsp_client | rust-analyzer
Error: client exited without proper shutdown sequence
```

Instead, include both error messages when the server shuts down.
2024-05-09 11:59:04 +00:00
bors
7d1b3a6607 Auto merge of #17207 - Wilfred:serde_invalid_data, r=lnicola
fix: Report all LSP protocol errors with invalid_data

Previously we did not use invalid_data for serde errors, making it harder to understand errors when the client sends malformed data to the server.
2024-05-09 09:44:40 +00:00
Wilfred Hughes
d993f9d1c9 fix: Report both IO errors and main_loop errors
If rust-analyzer receives a malformed LSP request, the IO thread
terminates with a meaningful error, but then closes the channel.

Once the channel has closed, the main_loop also terminates, but it
only has RecvError and can't show a meaningful error. As a result,
rust-analyzer would incorrectly claim that the client forgot to
shutdown.

```
$ buggy_lsp_client | rust-analyzer
Error: client exited without proper shutdown sequence
```

Instead, include both error messages when the server shuts down.
2024-05-08 16:53:30 -07:00
Wilfred Hughes
84fdb72525 fix: Report all LSP protocol errors with invalid_data
Previously we did not use invalid_data for serde errors, making it
harder to understand errors when the client sends malformed data to
the server.
2024-05-08 16:08:00 -07:00
Tavo Annus
ab18604309 Make term search fuel configurable 2024-05-08 19:46:33 +03:00
Tavo Annus
9e1adc76e5 Use unit of work as fuel instead of time 2024-05-07 22:13:27 +03:00
bors
9ec04ed43d Auto merge of #17192 - roife:fix-issue-17179, r=lnicola
Fix source_range for INT_NUMBER in completion

fix #17179.

Previously r-a use `TextRange::empty(self.position.offset)` as `source_range` for `INT_NUMBER`, so the `text_edit` would always be an insertion, which results in #17179.

This PR changed it by using `text_range` of `original_token` (same as `IDENT`).
2024-05-07 07:24:15 +00:00
Tavo Annus
d253617bba Add time based fuel to term search 2024-05-06 22:13:09 +03:00
Tavo Annus
c3ab435b54 Collapse term search exprs before Cartesian product to avoid OOM 2024-05-06 20:29:34 +03:00
Lukas Wirth
e1aeed3aed Implement unsafe attribute parsing 2024-05-06 12:11:29 +02:00
roife
435e83d9ad Fix source_range for INT_NUMBER in completion 2024-05-06 11:50:05 +08:00