Commit Graph

27301 Commits

Author SHA1 Message Date
Johann Hemmann
f913d4f4b7 Refactor if-else 2024-01-18 12:59:43 +01:00
Johann Hemmann
b599de193f Refactor macro_call to be consistent with other functions 2024-01-18 12:50:36 +01:00
Ali Bektas
21020919e3 v2 2024-01-18 12:09:23 +01:00
bors
1ab8c7fd27 Auto merge of #16349 - Young-Flash:use_error_recovery, r=Veykril
fix: add error recovery for use_tree_list parsing

This PR adds error recovery for USE_TREE_LIST parsing, avoid the wrong USE_TREE_LIST making the rest parsing incorrectly.

before

![before](https://github.com/rust-lang/rust-analyzer/assets/71162630/c6643690-f25c-4ad9-93d9-e661ba5b1dc3)

after

![after](https://github.com/rust-lang/rust-analyzer/assets/71162630/30a58c40-2711-48d2-b2e5-fb208fc8636c)

close https://github.com/rust-lang/rust-analyzer/issues/16227
2024-01-18 09:52:37 +00:00
Lukas Wirth
507448652a Fix rename test fixtures not accounting for multi file edits 2024-01-18 10:47:02 +01:00
Young-Flash
0bf986d718 add test case with marco reference 2024-01-18 17:43:44 +08:00
Young-Flash
bd26403130 fix panic with reference in macro 2024-01-18 17:43:15 +08:00
Young-Flash
1c61326ca0 add use_tree_completion test 2024-01-18 17:35:01 +08:00
Matthias Krüger
7d4980a4d8 Rollup merge of #119172 - nnethercote:earlier-NulInCStr, r=petrochenkov
Detect `NulInCStr` error earlier.

By making it an `EscapeError` instead of a `LitError`. This makes it like the other errors produced when checking string literals contents, e.g. for invalid escape sequences or bare CR chars.

NOTE: this means these errors are issued earlier, before expansion, which changes behaviour. It will be possible to move the check back to the later point if desired. If that happens, it's likely that all the string literal contents checks will be delayed together.

One nice thing about this: the old approach had some code in `report_lit_error` to calculate the span of the nul char from a range. This code used a hardwired `+2` to account for the `c"` at the start of a C string literal, but this should have changed to a `+3` for raw C string literals to account for the `cr"`, which meant that the caret in `cr"` nul error messages was one short of where it should have been. The new approach doesn't need any of this and avoids the off-by-one error.

r? ```@fee1-dead```
2024-01-18 10:34:17 +01:00
bors
2dfa9b86d0 Auto merge of #16384 - Veykril:smolstr, r=Veykril
minor: Make use of some new `SmolStr` improvements
2024-01-18 09:30:45 +00:00
bors
8bb500aaac Auto merge of #16395 - roife:internal/speed-up-LineEndings-with-memchr, r=Veykril
internal: speedup LineEndings calculation using 'memchr'

See https://github.com/rust-lang/rust-analyzer/issues/13538
2024-01-18 09:18:41 +00:00
roife
04ce4ce440 internal: speedup LineEndings calculation using 'memchr' 2024-01-18 17:03:29 +08:00
Weihang Lo
6231ca5f5e fix(rust-analyzer): use new pkgid spec to compare
Starting from cargo#13311, Cargo's compiler artifact message
uses Package ID specification as package's identifier format.
2024-01-18 07:01:29 +00:00
Ali Bektas
9bd9a17ce5 Add a new config to allow renaming of non-local items
With #15656 we started disallowing renaming of non-local items.
Although this makes sense there are some false positives that
impacted users' workflows. So this config aims to mitigate this
by giving users the liberty to disable this feature.
2024-01-18 00:26:22 +01:00
davidsemakula
7db4117156 respect "one" import granularity config in merge imports assist 2024-01-18 01:44:57 +03:00
davidsemakula
4f176b3f7f update import granularity config and docs 2024-01-18 01:44:57 +03:00
davidsemakula
57d4b5bb0f add "one" import granularity 2024-01-18 01:44:57 +03:00
bors
9d9b34354d Auto merge of #16389 - davidsemakula:order-use-tree-raw-ident, r=lnicola
internal: properly order raw idents when ordering use trees

Follow up to #16352 to properly order raw identifiers.
2024-01-17 20:23:21 +00:00
davidsemakula
84a3b52a10 properly order raw idents when ordering use trees 2024-01-17 21:46:19 +03:00
bors
a19372f334 Auto merge of #16387 - lnicola:metrics-sysroot, r=Veykril
internal: Fix sysroot metadata in metrics

CC https://github.com/rust-lang/rust-analyzer/pull/16380#issuecomment-1895550254
2024-01-17 17:30:52 +00:00
Laurențiu Nicola
27b0636745 Fix sysroot metadata in metrics 2024-01-17 19:16:32 +02:00
Lukas Wirth
83591268ab minor: Make use of some new SmolStr improvements 2024-01-17 13:47:15 +01:00
bors
5b62ebc23f Auto merge of #16383 - Veykril:progress, r=Veykril
fix: Fix progress reporting getting stuck

Fixes https://github.com/rust-lang/rust-analyzer/issues/16382
2024-01-17 12:24:43 +00:00
Lukas Wirth
0bdbf497b6 fix: Fix progress reporting getting stuck 2024-01-17 13:23:00 +01:00
bors
c820980648 Auto merge of #16314 - Urhengulas:macro_rule-as-macro-name, r=Veykril
`macro_rules` as macro name

This PR makes RA parse `macro_rules! {}` (note the missing identifier) as a `MACRO_CALL` instead of `MACRO_RULES`.

Fixes #15969.
2024-01-17 12:04:14 +00:00
Johann Hemmann
76c67dd229 Fix test 2024-01-17 12:49:58 +01:00
Johann Hemmann
5916da2c29 Handle macro_rules! as MACRO_CALL
It's a call of the third token is neither IDENT or TRY
2024-01-17 12:07:17 +01:00
bors
2b02df27c5 Auto merge of #16380 - Veykril:sysroot-ci, r=Veykril
Run metadata on sysroot for CI metrics
2024-01-17 09:33:14 +00:00
bors
f4fec4ff65 Auto merge of #16378 - roife:fix/issue-15470, r=Veykril
fix: better handling of SelfParam in assist 'inline_call'

fix #15470.

The current `inline_call` directly translates `&self` into `let ref this = ...;` and `&mut self` into `let ref mut this = ...;`. However, it does not handle some complex scenarios.

This PR addresses the following transformations (assuming the receiving object is `obj`):

- `self`: `let this = obj`
- `mut self`: `let mut this = obj`
- `&self`: `let this = &obj`
- `&mut self`
  + If `obj` is `let mut obj = ...`, use a mutable reference: `let this = &mut obj`
  + If `obj` is `let obj = &mut ...;`, perform a reborrow: `let this = &mut *obj`
2024-01-17 08:43:13 +00:00
Lukas Wirth
21723cb051 Run metadata on sysroot for CI metrics 2024-01-17 09:43:04 +01:00
roife
920e99aacb test: add tests for variant kinds of SelfParam in inline_call 2024-01-17 14:19:57 +08:00
roife
d48498f360 fix: better handling of SelfParam in inline_call 2024-01-17 13:49:07 +08:00
bors
03336460fc Auto merge of #16375 - Veykril:hover-notable, r=Veykril
feat: Goto type actions for notable trait hovers

Follow up to https://github.com/rust-lang/rust-analyzer/pull/16374
2024-01-16 19:18:56 +00:00
Lukas Wirth
0a75a8c061 Notable traits for type info hovers 2024-01-16 20:15:31 +01:00
Lukas Wirth
ffeaee84af Goto type actions for notable trait hovers 2024-01-16 19:59:55 +01:00
bors
7777a81b69 Auto merge of #16374 - Veykril:hover-notable, r=Veykril
feat: Show notable trait impls on hover
2024-01-16 18:18:52 +00:00
Lukas Wirth
82e8355492 feat: Show notable trait impls on hover 2024-01-16 19:17:33 +01:00
roife
7c94c29648 fix: make let_stmts inserted in inline_call correctly indented 2024-01-16 21:42:29 +08:00
bors
e2df3f2ad6 Auto merge of #16370 - Veykril:hover-lit, r=Veykril
feat: Hover for literals showing additional value information
2024-01-16 13:30:11 +00:00
Lukas Wirth
384488c157 feat: Hover for literals showing additional value information 2024-01-16 14:28:47 +01:00
bors
e7a8d21a52 Auto merge of #16369 - Veykril:simplify, r=Veykril
minor: Simplify
2024-01-16 12:37:47 +00:00
Lukas Wirth
6584e63506 minor: Simplify 2024-01-16 13:36:07 +01:00
bors
0a8c7841e0 Auto merge of #16352 - davidsemakula:rustfmt-import-sort-algo, r=Veykril
internal: Follow rustfmt's algorithm for ordering imports when ordering and merging use trees

Updates use tree ordering and merging utilities to follow rustfmt's algorithm for ordering imports.
The [rustfmt implementation](6356fca675/src/imports.rs) was used as reference.
2024-01-16 11:23:03 +00:00
bors
63c4e6993f Auto merge of #16367 - Veykril:value-ty, r=Veykril
fix: Make `value_ty` query fallible
2024-01-16 11:11:31 +00:00
Lukas Wirth
8f4f5a6cce fix: Make value_ty query fallible 2024-01-16 12:09:40 +01:00
davidsemakula
1f91c487a2 move is_upper_snake_case to stdx 2024-01-16 13:37:22 +03:00
davidsemakula
5b2a2bc3fb remove unnecessary ref patterns 2024-01-16 13:26:49 +03:00
bors
2d5ce888de Auto merge of #16366 - Veykril:transp-queries, r=Veykril
internal: Make data queries transparent over their diagnostics variant

And a few other QoL things
2024-01-16 10:09:05 +00:00
Lukas Wirth
35e05e07fb Bump smol_str 2024-01-16 11:07:45 +01:00
Lukas Wirth
f675b5ead8 Don't early exit on panics in rustc_tests command 2024-01-16 11:05:50 +01:00