Alex Kladov
87315ef5c3
Apply suggestions from code review
...
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2023-01-13 11:57:02 +00:00
bors
15fb082cc1
Auto merge of #13753 - kdy1:limit, r=lnicola
...
fix: Increase token limit of proc macro
Fixes #13738
[The swc project](https://swc.rs ) has lots of type definitions, and the current limit is too low for the ECMAScript/CSS visitors.
[rustdoc](https://rustdoc.swc.rs/swc_ecma_visit )
---
With this fix, the rust-analyzer shows trait-related actions.
<img width="1840" alt="image" src="https://user-images.githubusercontent.com/29931815/206839269-d7a04589-7dba-449b-ad0b-1f69d52bd039.png ">
2023-01-13 11:45:50 +00:00
Aleksey Kladov
aa73366b0b
internal: explain the idea behind rust-project.json
2023-01-13 11:44:02 +00:00
bors
cdbe025232
Auto merge of #13922 - danieleades:loop-that-never-loops, r=lnicola
...
minor: loop-that-never-loops
closes #13921
2023-01-13 11:23:51 +00:00
Neel Yadav
9721505bf1
Fix panicking Option unwraping in match arm analysis
2023-01-12 22:33:58 -06:00
bors
fb39efe26c
Auto merge of #13934 - Veykril:unlinked-file-inline-modules, r=Veykril
...
feat: Make unlinked_file diagnostic quickfixes work for inline modules
Finally got myself to fix this, bothered me quite a bit that this never worked
![Code_Qe3WlMvt5Q](https://user-images.githubusercontent.com/3757771/211927799-023e48ee-7cdd-4dd7-8e25-a23eddc7d897.gif )
(Just gotta fix up the indentation still)
2023-01-12 15:25:12 +00:00
Daniel Eades
c4b36b64aa
remove recursive 'Display' implementations
2023-01-12 11:53:45 +00:00
Daniel Eades
7413a9954f
interior-mutable types should be 'static' rather than 'const
2023-01-12 10:48:10 +00:00
Lukas Wirth
14777ce751
fix indentation of unlinked_file quickfix
2023-01-12 11:24:44 +01:00
Roland Fredenhagen
03bc46f96b
Convert pub to pub(crate)
2023-01-12 09:54:48 +01:00
Roland Fredenhagen
6f201cfc56
Assist: desugar doc-comment
2023-01-12 02:28:13 +01:00
Lukas Wirth
5214a98d9c
Simplify
2023-01-11 23:04:35 +01:00
Lukas Wirth
1ce3e820dc
feat: Make unlinked_file diagnostic quickfixes work for inline modules
2023-01-11 22:39:05 +01:00
Lukas Wirth
bb4e272d8a
Refine search for const and function assoc items
2023-01-11 17:10:04 +01:00
daniel.eades
a3114c3697
move loop index inside iterator
2023-01-11 16:07:35 +00:00
bors
f32f64bffc
Auto merge of #13929 - danieleades:simplify, r=lnicola
...
internal: a number of code simplifications
2023-01-11 09:38:34 +00:00
Albert Larsan
3e0e51c108
Change src/test
to tests
in source files, fix tidy and tests
2023-01-11 09:32:13 +00:00
bors
75877d78d9
Auto merge of #13897 - bvanjoi:nearest-block-search, r=Veykril
...
fix(ty): should query impls in nearest block
fix https://github.com/rust-lang/rust-analyzer/issues/13895
2023-01-10 22:44:29 +00:00
Daniel Eades
d218b237fd
collapse some nested blocks
2023-01-10 20:40:08 +00:00
Daniel Eades
95fc3ba41c
fixup
2023-01-10 19:51:21 +00:00
Daniel Eades
5b1cd8245f
fixup
2023-01-10 19:44:19 +00:00
Daniel Eades
ac3844a0bb
a number of code simplifications
2023-01-10 18:48:51 +00:00
Daniel Eades
95d14c393c
avoid 'cloning' types that implement 'Copy'
2023-01-10 18:20:12 +00:00
bors
3987c835f2
Auto merge of #13919 - danieleades:derive-hash, r=lnicola
...
derive 'Hash'
2023-01-10 17:48:46 +00:00
bors
c3b78f440e
Auto merge of #13917 - Veykril:raw-attrs, r=Veykril
...
Split out hir-def attribute handling parts into hir-expand
This should help with `cfg_attr` handling for macro inputs
2023-01-10 17:35:37 +00:00
Daniel Eades
6153ea8dce
loop-that-never-loops
2023-01-10 08:28:28 +00:00
Daniel Eades
56ffe63c3c
derive 'Hash'
2023-01-10 07:18:17 +00:00
Daniel Eades
db41e6b408
remove 'deny_clippy' test
2023-01-10 07:16:27 +00:00
Daniel Eades
b971b5b64f
suppress lint
2023-01-10 07:06:26 +00:00
Daniel Eades
ef4debc8b1
comment out disabled code
2023-01-10 07:02:04 +00:00
bvanjoi
9a15cc81b4
fix(ty): should query impls in nearest block
2023-01-10 10:28:17 +08:00
Lukas Wirth
621e96bd6a
Encode one level of cfg_attr in attr_id
2023-01-09 21:06:13 +01:00
arcnmx
25242fe93f
⬆️ rust-analyzer
...
Merge commit '368e0bb32f1178cf162c2ce5f7e10b7ae211eb26'
2023-01-09 10:36:22 -08:00
Lukas Wirth
68723043db
Split out hir-def attribute handling parts into hir-expand
2023-01-09 19:29:28 +01:00
Ian Chamberlain
65cf7abbe2
Use experimental capability to enable color codes
2023-01-09 11:50:35 -05:00
Ian Chamberlain
c3e4bc3136
Update docs to include note about ANSI diagnostics
2023-01-09 11:49:58 -05:00
Ian Chamberlain
40207906f4
Default to use colored ANSI diagnostics
2023-01-09 11:46:29 -05:00
bors
fd300eebc9
Auto merge of #13799 - Veykril:flycheck, r=Veykril
...
Rename `checkOnSave` settings to `check`
Now that flychecks can be triggered without saving the setting name doesn't make that much sense anymore. This PR renames it to just `check`, but keeps `checkOnSave` as the enabling setting.
2023-01-09 15:35:38 +00:00
bors
f920b03c6c
Auto merge of #13914 - WaffleLapkin:qualify_method_call_rewrite, r=lnicola
...
minor: Make `qualify_method_call` `RefactorRewrite`
See https://github.com/rust-lang/rust-analyzer/pull/13825#issuecomment-1363289767
2023-01-09 15:22:51 +00:00
bors
e125bee055
Auto merge of #13890 - lowr:fix/unescape-inline-mod-name, r=Veykril
...
fix: unescape inline module names in module resolution
Fixes #13884
2023-01-09 15:07:06 +00:00
bors
ba204ef07b
Auto merge of #13863 - danieleades:approx-constant, r=Veykril
...
minor: suppress 'clippy::approx_constant' lint in test case
suppresses a false positive clippy lint
2023-01-09 14:53:46 +00:00
bors
d33fa38cc9
Auto merge of #13825 - WaffleLapkin:ufcs_to_method_call_and_back, r=Veykril
...
feat: Add `unqualify_method_call` assist
...which is the inverse of `qualify_method_call` assist.
![Peek 2022-12-22 22-47](https://user-images.githubusercontent.com/38225716/209206554-8f067206-6fa6-48f8-849e-f6d36ee2e5a1.gif )
Optional future work:
- import the trait if needed
- remove excess references when auto-ref is possible
2023-01-09 14:37:40 +00:00
Maybe Waffle
bdaad9eb15
Make qualify_method_call
RefactorRewrite
2023-01-09 14:26:48 +00:00
bors
336608aa92
Auto merge of #13810 - tfpk:tfpk/macro-inline, r=Veykril
...
Add action to expand a declarative macro once, inline. Fixes #13598
This commit adds a new r-a method, `expandMacroInline`, which expands the macro that's currently selected. See #13598 for the most applicable issue; though I suspect it'll resolve part of #5949 and make #11888 significantly easier).
The macro works like this:
![rust-analyser-feature](https://user-images.githubusercontent.com/10906982/208813167-3123e379-8fd5-4206-a4f4-5af1129565f9.gif )
I have 2 questions before this PR can be merged:
1. **Should we rustfmt the output?** The advantage of doing this is neater code. The disadvantages are we'd have to format the whole expr/stmt/block (since there's no point just formatting one part, especially over multiple lines), and maybe it moves the code around more in weird ways. My suggestion here is to start off by not doing any formatting; and if it appears useful we can decide to do formatting in a later release.
2. **Is it worth solving the `$crate` hygiene issue now?** -- I think this PR is usable as of right now for some use-cases; but it is annoying that many common macros (i.e. `println!()`, `format!()`) can't be expanded further unless the user guesses the correct `$crate` value. The trouble with solving that issue is that I think it's complicated and imperfect. If we do solve it; we'd also need to either change the existing `expandMacro`/`expandMacroInline` commands; provide some option to allow/disallow `$crate` expanding; or come to some other compromise.
2023-01-09 14:24:41 +00:00
Maybe Waffle
c782353a90
Rename assist: convert_ufcs_to_method
=> unqualify_method_call
2023-01-09 14:23:30 +00:00
bors
938a39ab89
Auto merge of #13891 - bvanjoi:reverse-whitespace-in-assists, r=Veykril
...
fix: keep whitespace in extract function handler
Fixed #13874
2023-01-09 14:11:40 +00:00
Tom Kunc
769273ca4c
Simplify code with @Veykril's suggestion.
2023-01-09 07:01:41 -07:00
Maybe Waffle
44c84a8d28
Add convert_ufcs_to_method
assist
2023-01-09 13:50:00 +00:00
bors
ec968198b9
Auto merge of #13816 - WaffleLapkin:postfix_adjustment_hints, r=Veykril
...
Postfix adjustment hints
# Basic Description
This PR implements "postfix" adjustment hints:
![2022-12-21_19-27](https://user-images.githubusercontent.com/38225716/208941721-d48d316f-a918-408a-9757-8d4e2b402a66.png )
They are identical to normal adjustment hints, but are rendered _after_ the expression. E.g. `expr.*` instead of `*expr`. ~~This mirrors "postfix deref" feature that I'm planning to eventually propose to the compiler.~~
# Motivation
The advantage of being postfix is that you need to add parentheses less often:
![2022-12-21_19-38](https://user-images.githubusercontent.com/38225716/208944302-16718112-14a4-4438-8aed-797766391c63.png )
![2022-12-21_19-37](https://user-images.githubusercontent.com/38225716/208944281-d9614888-6597-41ee-bf5d-a081d8048f94.png )
This is because a lot of "reborrow" hints are caused by field access or method calls, both of which are postfix and have higher "precedence" than prefix `&` and `*`.
Also IMHO it just looks nicer and it's more clear what is happening (order of operations).
# Modes
However, there are some cases where postfix hints need parentheses but prefix don't (for example `&x` being turned into `(&x).*.*.&` or `&**&x`).
This PR allows users to choose which look they like more. There are 4 options (`rust-analyzer.inlayHints.expressionAdjustmentHints.mode` setting):
- `prefix` — always use prefix hints (default, what was used before that PR)
- `postfix` — always use postfix hints
- `prefer_prefix` — try to minimize number of parentheses, breaking ties in favor of prefix
- `prefer_postfix` — try to minimize number of parentheses, breaking ties in favor of postfix
Comparison of all modes:
![2022-12-21_19-53](https://user-images.githubusercontent.com/38225716/208947482-26357c82-2b42-47d9-acec-835f5f03f6b4.png )
![2022-12-21_19-49](https://user-images.githubusercontent.com/38225716/208946731-fe566d3b-52b2-4846-994d-c2cecc769e0f.png )
![2022-12-21_19-48](https://user-images.githubusercontent.com/38225716/208946742-6e237f44-805e-469a-a3db-03d8f76e1317.png )
![2022-12-21_19-47](https://user-images.githubusercontent.com/38225716/208946747-79f25fae-e3ea-47d2-8d27-cb4eeac034fe.png )
# Edge cases
Where are some rare cases where chain hints weirdly interact with adjustment hints, for example (note `SourceAnalyzer.&`):
![image](https://user-images.githubusercontent.com/38225716/208947958-41c12971-f1f0-4a41-a930-47939cce9f58.png )
This is pre-existing, you can get the same effect with prefix hints (`SourceAnalyzer)`).
----
Another weird thing is this:
![2022-12-21_20-00](https://user-images.githubusercontent.com/38225716/208948590-ea26d325-2108-4b35-abaa-716a65a1ae99.png )
Here `.&` is a hint and `?` is written in the source code. It looks like `?` is part of the hint because `?.` is ligature in my font. IMO this is a bug in vscode, but still worth mentioning (I'm also too lazy to report it there...).
# Fixed bugs
I've used the "needs parens" API and this accidentally fixed a bug with parens around `as`, see the test diff:
```diff,rust
let _: *const u32 = &mut 0u32 as *mut u32;
//^^^^^^^^^^^^^^^^^^^^^<mut-ptr-to-const-ptr>
+ //^^^^^^^^^^^^^^^^^^^^^(
+ //^^^^^^^^^^^^^^^^^^^^^)
...
let _: *const u32 = &mut 0u32 as *mut u32;
//^^^^^^^^^^^^^^^^^^^^^<mut-ptr-to-const-ptr>
+ //^^^^^^^^^^^^^^^^^^^^^(
+ //^^^^^^^^^^^^^^^^^^^^^)
```
# Changelog
changelog feature Add an option to make adjustment hints (aka reborrow hints) postfix
changelog fix Fix placement of parentheses around `as` casts for adjustment hints
2023-01-09 13:47:46 +00:00
Maybe Waffle
b6169c2a2e
Add a fixme to remove hacks
2023-01-09 13:37:37 +00:00