Lukas Wirth
4a677e91aa
minor: Remove unnecessary arg in LowerCtx::ast_id
2023-01-25 21:52:28 +01:00
bors
dd673eea33
Auto merge of #14025 - Veykril:changekind-fix, r=jonas-schievink
...
fix: Fix process-changes not deduplicating changes correctly
probably fixes https://github.com/rust-lang/rust-analyzer/issues/12873 (will close it with this nevertheless as its not really reproducible)
2023-01-25 15:43:01 +00:00
bors
6fd5769996
Auto merge of #14011 - bvanjoi:fix-unwrap-block, r=jonas-schievink
...
fix(ide-assists): unwrap block when it parent is let stmt
fix #13990
2023-01-25 15:04:03 +00:00
Lukas Wirth
d712e52940
fix: Fix process-changes not deduplicating changes correctly
2023-01-25 15:01:15 +01:00
bors
46084a1e71
Auto merge of #14015 - vasilev-alex:lifetime-rename, r=Veykril
...
Don't include lifetime or label apostrophe when renaming
Closes #13907
2023-01-25 13:57:29 +00:00
bvanjoi
90b1222b0b
fix(ide-assists): unwrap block when it parent is let stmt
2023-01-25 10:25:59 +08:00
Nathaniel Brough
6c4749e8f5
fix(fuzz): Fixes broken Cargo.toml for fuzz tests
...
Fixes broken Cargo.toml for fuzz tests and adds building of
fuzz tests to the CI.
2023-01-24 10:54:10 -08:00
Alex Vasilev
3c898dd9a1
fix
2023-01-24 23:22:30 +05:30
bors
cd4ac0d87b
Auto merge of #14020 - Veykril:search-fix, r=Veykril
...
fix: Fix assoc item search finding unrelated definitions
Fixes https://github.com/rust-lang/rust-analyzer/issues/14014
2023-01-24 13:11:30 +00:00
Lukas Wirth
951ee3d0b5
fix: Fix assoc item search finding unrelated definitions
2023-01-24 14:11:02 +01:00
Ryo Yoshida
e9f14c505f
Remove TypeWalk
and use TypeFlags
instead
2023-01-24 19:44:58 +09:00
Alex Vasilev
5d013a79d6
exclude '
2023-01-24 13:19:20 +05:30
Alex Vasilev
5f1796f837
uncomment check
2023-01-24 12:45:51 +05:30
Alex Vasilev
8678b92218
Allow renaming lifetiems and labels without leading apostrophe
2023-01-24 12:43:13 +05:30
bors
c552e5a55f
Auto merge of #14004 - lowr:patch/no-need-to-escape-non-snippet, r=Veykril
...
Don't escape non-snippets in assist
I was misunderstanding that we're always sending snippets as response to assist request. For assists that never return snippets like `move_const_to_impl` we don't need to escape, and I don't think `utils::escape_non_snippet()` is useful at the moment since we guarantee that only a single edit will have `InsertTextFormat.Snippet` and we have `utils::render_snippet()` for that.
2023-01-23 16:32:53 +00:00
Lukas Wirth
b9fe5afb30
Add a 'open server logs' button to the error notification
2023-01-23 13:24:42 +01:00
Lukas Wirth
84239a1454
REplace soft breaks in markdown with spaces
2023-01-23 12:21:23 +01:00
Ryo Yoshida
01d8b8947c
Don't escape non-snippets in assist
2023-01-23 00:22:46 +09:00
Alex Vasilev
2a4837089e
fixes
2023-01-21 23:42:11 +05:30
Lukas Wirth
f8ed4d7ae4
Use lang item resolution instead of known paths
2023-01-21 19:03:36 +01:00
Lukas Wirth
1535881836
Replace SmolStr usage with lang item enum for lang items
2023-01-21 17:55:45 +01:00
bors
1afa032f34
Auto merge of #13996 - lnicola:bump-deps, r=lnicola
...
minor: Bump deps
2023-01-21 12:27:40 +00:00
Laurențiu Nicola
8f678a0169
Bump snap
2023-01-21 14:05:22 +02:00
Laurențiu Nicola
1431264646
Bump rayon
2023-01-21 14:05:22 +02:00
Laurențiu Nicola
25a5bd9b13
Bump object
2023-01-21 14:05:22 +02:00
Laurențiu Nicola
f2397638f5
Bump arbitrary and derive-arbitrary
2023-01-21 14:05:22 +02:00
Laurențiu Nicola
d26c8ccc89
Bump num_cpus
2023-01-21 08:49:50 +02:00
Laurențiu Nicola
392a6ee422
Bump once_cell
2023-01-21 08:48:46 +02:00
bors
303737dad7
Auto merge of #13989 - Veykril:hover, r=Veykril
...
internal: Remove hover fallback in favor of ranged hover
The fallback is usually more annoying than useful at this point (it messes with the range of diagnostic popups a lot), we now have a ranged hover to check the type of something which works a lot better.
Closes https://github.com/rust-lang/rust-analyzer/issues/11602
2023-01-20 22:00:22 +00:00
Lukas Wirth
4685b97f74
Remove hover fallback in favor of ranged hover
2023-01-20 21:52:05 +01:00
Alex Vasilev
dd9dcca7a2
assist id fix
2023-01-21 00:47:02 +05:30
Alex Vasilev
1ab58b190e
cargo test
2023-01-21 00:42:29 +05:30
Alex Vasilev
ddb2f8760b
typo fix
2023-01-21 00:30:38 +05:30
Alex Vasilev
69ffbe25a1
feat: add braces assist
2023-01-21 00:17:23 +05:30
Lukas Wirth
a542bd46bf
Split out some hover functions
2023-01-20 16:30:08 +01:00
bors
ce67dea2ac
Auto merge of #13988 - Veykril:hover-no-markdown, r=Veykril
...
Fix markdown removal in hover handling whitespace weirdly
Fixes https://github.com/rust-lang/rust-analyzer/issues/10028
2023-01-20 15:23:54 +00:00
Lukas Wirth
c5b1e3f2ae
Fix markdown removal in hover handling whitespace weirdly
2023-01-20 14:29:12 +01:00
bors
d46d012c38
Auto merge of #13978 - bvanjoi:array-match, r=Veykril
...
feat: array match
fixed https://github.com/rust-lang/rust-analyzer/issues/13970
2023-01-20 10:30:18 +00:00
bvanjoi
8fa69f9f7d
feat: array match
2023-01-20 10:59:30 +08:00
Maria José Solano
f7fcdb6218
Order alphabetically
2023-01-19 18:34:01 -08:00
Maria José Solano
d044bc3504
Format code
2023-01-19 18:33:47 -08:00
Maria José Solano
d5fb7a4ba4
Limit number of completions
2023-01-19 18:23:21 -08:00
Maria José Solano
ec89fc85a8
Add limit setting
2023-01-19 18:21:43 -08:00
bors
6e52c64031
Auto merge of #13985 - Veykril:content-modified, r=Veykril
...
Don't respond with a ContentModified while loading the workspace
Initially this was done to prevent frequent inlay hint flickering, but this causes a lot of problems for a bunch of clients. We can (and already kind of have) move this into the semantic token request handlers instead.
Fixes https://github.com/rust-lang/rust-analyzer/issues/10910
2023-01-19 21:00:26 +00:00
Lukas Wirth
7385467f2e
Don't respond with a ContentModified while loading the workspace
2023-01-19 21:52:27 +01:00
bors
56fb0cad6d
Auto merge of #13984 - Veykril:target-data-layout, r=Veykril
...
fix: Fix target-data-layout fetching incorrectly passing 'rustc' to rustc
2023-01-19 20:45:29 +00:00
Lukas Wirth
384fa4b84a
fix: Fix target-data-layout fetching incorrectly passing 'rustc' to rustc
2023-01-19 21:31:08 +01:00
onestacked
872408500b
Parse const_closures syntax.
...
Enables parsing of the syntax for `#![features(const_closures)]` introduced in https://github.com/rust-lang/rust/pull/106004
2023-01-19 15:40:07 +01:00
Lukas Wirth
c9d33cddc9
Don't run flycheck on startup unless checkOnSave is enabled
2023-01-18 21:38:30 +01:00
Lukas Wirth
1e4a182954
Fix checkOnSave to check config patching not always working
2023-01-18 20:29:55 +01:00
Laurențiu Nicola
210757769d
Fix replace_arith label
2023-01-17 16:31:34 +02:00
Ryo Yoshida
c53064fb58
Enforce builtin binop expectations even without lang items
2023-01-17 20:17:15 +09:00
Ryo Yoshida
461435adab
Enforce builtin binop expectations on single references
...
Also don't enforce them on non-builtin types
2023-01-17 20:17:09 +09:00
bors
fa874627f0
Auto merge of #13969 - Veykril:workspace.dependencies, r=Veykril
...
Use workspace.dependencies to declare local dependencies
2023-01-17 10:29:27 +00:00
bors
62907858d5
Auto merge of #13964 - Veykril:workspace.package, r=Veykril
...
Specify authors, edition, license and rust-versian via workspace.package
2023-01-17 10:13:24 +00:00
Lukas Wirth
bed4db3c62
Use workspace.dependencies to declare local dependencies
2023-01-17 10:52:26 +01:00
bors
e11c0e3e85
Auto merge of #13966 - HKalbasi:layout, r=Veykril
...
Don't compute layout if `TargetDataLayout` is not available
2023-01-17 09:39:32 +00:00
hkalbasi
ec65b3b3aa
fix tests
2023-01-16 23:45:12 +03:30
hkalbasi
77efa0267d
Don't compute layout if TargetDataLayout
is not available
2023-01-16 22:43:27 +03:30
bors
455ef0c806
Auto merge of #13935 - ModProg:assist_desugar_doc_comment, r=Veykril
...
Assist: desugar doc-comment
My need for this arose due to wanting to do feature dependent documentation and therefor convert parts of my doc-comments to attributes.
Not sure about the pub-making of the other handlers functions, but I didn't think it made much sense to reimplement them.
2023-01-16 19:11:19 +00:00
Roland Fredenhagen
ec06313a6d
fix test for required_hashes
2023-01-16 19:25:30 +01:00
Roland Fredenhagen
5e66e49c73
move required_hashes into utils
2023-01-16 18:39:16 +01:00
Lukas Wirth
e4858fe480
Specify authors, edition and license via workspace.package
2023-01-16 16:44:00 +01:00
Lukas Wirth
679df2adf1
Specify rust-version via workspace.package
2023-01-16 16:33:01 +01:00
Lukas Wirth
3a95864df5
Unconditionally enable location links in inlay hints again
2023-01-16 16:04:38 +01:00
bors
5306eb06cc
Auto merge of #13947 - WaffleLapkin:adjustment_hint_tooltips, r=Veykril
...
Add basic tooltips to adjustment hints
![2023-01-16_16-45](https://user-images.githubusercontent.com/38225716/212681383-a60b60bb-a8e7-410d-8b24-f6b72c197311.png )
I'm not sure how to make them look nicer, but it's at least something.
2023-01-16 13:11:16 +00:00
Maybe Waffle
81d7e302ed
Add basic tooltips to adjustment hints
2023-01-16 12:44:39 +00:00
Ryo Yoshida
fc56cacfc1
Test TraitRef
equality before generating missing impl method body
2023-01-16 20:55:56 +09:00
Ryo Yoshida
8afaaa54b0
Add TraitRef
for HIR
2023-01-16 20:55:51 +09:00
Niels Sascha Reedijk
8aa1d2d789
Update command-group from 1.0.8 to 2.0.1
...
With #13552 the depencency of on the command-group crate was introduced, which also
introduced a dependency on nix. That version of nix does not build on Haiku. This
change introduces a newer version of command-group, which also updates nix from
0.22.3 to 0.26.1, which is compatible on Haiku.
2023-01-15 08:20:25 +00:00
Maybe Waffle
a7787533af
Use the fact that Either
: AstNode
2023-01-14 15:20:32 +00:00
bors
c78b9f0068
Auto merge of #13949 - WaffleLapkin:either_ast_node, r=Veykril
...
minor: implement `AstNode` for `Either`
Makes code a little bit nicer
2023-01-14 13:50:11 +00:00
bors
ce86f12e8d
Auto merge of #13945 - bvanjoi:orpat-match, r=lnicola
...
fix: check orpat in missing match
fixed #13942
2023-01-14 13:37:30 +00:00
bors
8800ea6461
Auto merge of #13950 - WaffleLapkin:iterate_over_arrays_directly, r=Veykril
...
minor: Iterate over arrays dirrectly, instead of going through a slice
Minor code improvement.
2023-01-14 13:08:36 +00:00
Maybe Waffle
bd04416aaa
Iterate over arrays dirrectly, instead of going through a slice
2023-01-14 13:02:28 +00:00
bors
6673e515b7
Auto merge of #13948 - Veykril:inlay-hints, r=Veykril
...
Make inlay hint location links work for more types
2023-01-14 12:50:26 +00:00
Maybe Waffle
cfc01150bf
implement AstNode
for Either
2023-01-14 12:45:20 +00:00
Lukas Wirth
27ba598dfe
Make inlay hint location links work for more types
2023-01-14 13:30:56 +01:00
bors
ce6955c10e
Auto merge of #13946 - Veykril:inlay-hints, r=Veykril
...
Remove hover inlay tooltips, replace them with location links
Turns out we re-implemented what clients can already figure out through the use of location-links. We might want lazy resolves tooltips later on still, but for now this simplifies things again.
2023-01-14 12:22:43 +00:00
Lukas Wirth
f2444b2a40
Remove unnecessary Hint suffix on InlayKind variants
2023-01-14 13:08:45 +01:00
Lukas Wirth
60075a6625
Remove hover inlay tooltips, replace them with location links
2023-01-14 12:19:29 +01:00
bvanjoi
e9724e55df
fix: check orpat in missing match
2023-01-14 18:54:45 +08:00
bors
32be158630
Auto merge of #13941 - matklad:rpj, r=Veykril
...
internal: explain the idea behind rust-project.json
2023-01-14 09:40:40 +00:00
Lukas Wirth
aafb0f1f8d
Use smallvec for inlay-hint parts
2023-01-13 15:03:37 +01:00
bors
a119352ada
Auto merge of #13937 - danieleades:recursive-display, r=lnicola
...
remove recursive 'Display' implementations
closes #13920
`@lnicola` is this the solution you were looking for?
having explicitly unimplemented methods seems preferable to apparently implemented methods that can't be called
2023-01-13 12:07:28 +00:00
Alex Kladov
bd350085f6
Update crates/project-model/src/project_json.rs
...
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2023-01-13 12:01:04 +00:00
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
Maybe Waffle
a9676cfbe3
Add a "bug" test for adjustment hints to check for status quo
2023-01-09 13:35:21 +00:00
Maybe Waffle
12b7f9f7bf
Add an option to minimize parentheses for adjustment hints
2023-01-09 13:35:17 +00:00
bors
b0214d81e8
Auto merge of #13843 - Overpeek:master, r=Veykril
...
fix: generate async delegate methods
Fixes a bug where the generated async method doesn't await the result before returning it.
This is an example of what the output looked like:
```rust
struct Age<T>(T);
impl<T> Age<T> {
pub(crate) async fn age<J, 'a>(&'a mut self, ty: T, arg: J) -> T {
self.0
}
}
struct Person<T> {
age: Age<T>,
}
impl<T> Person<T> {
pub(crate) async fn age<J, 'a>(&'a mut self, ty: T, arg: J) -> T {
self.age.age(ty, arg) // .await is missing
}
}
```
The `.await` is missing, so the return type is `impl Future<Output = T>` instead of `T`
2023-01-09 13:34:51 +00:00
Maybe Waffle
b89c4f0a05
Implement postfix adjustment hints
...
I'd say "First stab at implementing..." but I've been working on this
for a month already lol
2023-01-09 13:27:59 +00:00
Lukas Wirth
d2bb62b6a8
Rename checkOnSave settings to check
2023-01-09 14:17:13 +01:00
Lukas Wirth
87d57f51bc
Rename checkOnSave settings to flycheck
2023-01-09 14:17:13 +01:00
bors
ae659125a5
Auto merge of #13763 - rami3l:fix/gen-partial-eq-generic, r=Veykril
...
fix: add generic `TypeBoundList` in generated derivable impl
Potentially fixes #13727 .
Continuing with the work in #13732 , this fix tries to add correct type bounds in the generated `impl` block:
```diff
enum Either<T, U> {
Left(T),
Right(U),
}
- impl<T, U> PartialEq for Either<T, U> {
+ impl<T: PartialEq, U: PartialEq> PartialEq for Either<T, U> {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::Left(l0), Self::Left(r0)) => l0 == r0,
(Self::Right(l0), Self::Right(r0)) => l0 == r0,
_ => false,
}
}
}
```
2023-01-09 13:02:09 +00:00
bors
fe8ee9c43a
Auto merge of #13744 - vtta:numthreads, r=Veykril
...
feat: add the ability to limit the number of threads launched by `main_loop`
## Motivation
`main_loop` defaults to launch as many threads as cpus in one machine. When developing on multi-core remote servers on multiple projects, this will lead to thousands of idle threads being created. This is very annoying when one wants check whether his program under developing is running correctly via `htop`.
<img width="756" alt="image" src="https://user-images.githubusercontent.com/41831480/206656419-fa3f0dd2-e554-4f36-be1b-29d54739930c.png ">
## Contribution
This patch introduce the configuration option `rust-analyzer.numThreads` to set the desired thread number used by the main thread pool.
This should have no effects on the performance as not all threads are actually used.
<img width="1325" alt="image" src="https://user-images.githubusercontent.com/41831480/206656834-fe625c4c-b993-4771-8a82-7427c297fd41.png ">
## Demonstration
The following is a snippet of `lunarvim` configuration using my own build.
```lua
vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "rust_analyzer" })
require("lvim.lsp.manager").setup("rust_analyzer", {
cmd = { "env", "RA_LOG=debug", "RA_LOG_FILE=/tmp/ra-test.log",
"/home/jlhu/Projects/rust-analyzer/target/debug/rust-analyzer",
},
init_options = {
numThreads = 4,
},
settings = {
cachePriming = {
numThreads = 8,
},
},
})
```
## Limitations
The `numThreads` can only be modified via `initializationOptions` in early initialisation because everything has to wait until the thread pool starts including the dynamic settings modification support.
The `numThreads` also does not reflect the end results of how many threads is actually created, because I have not yet tracked down everything that spawns threads.
2023-01-09 11:53:23 +00:00
bors
1e20bf38b2
Auto merge of #13684 - unvalley:extract-expressions-from-format-string, r=Veykril
...
feat: extract_expressions_from_format_string
closes #13640
- rename to `extract_expressions_from_format_string`
- leave identifier from format string
- but this is from rustc version 1.65.0
- Should I add flag or something?
Note: the assist behaves below cases for now. I'll create an issue for these.
```rs
let var = 1 + 1;
// ok
format!("{var} {1+1}"); // → format!("{var} {}", 1+1);
format!("{var:?} {1+1}"); // → format!("{var:?} {}", 1 + 1);
format!("{var} {var} {1+1}"); // → format!("{var} {var} {}", 1 + 1);
// breaks (need to handle minimum width by postfix`$`)
format!("{var:width$} {1+1}"); // → format!("{var:width\$} {}", 1+1);
format!("{var:.prec$} {1+1}"); // → format!("{var:.prec\$} {}", 1+1);
format!("Hello {:1$}! {1+1}", "x" 5); // → format("Hello {:1\$}! {}", "x", 1+1);
format!("Hello {:width$}! {1+1}", "x", width = 5); // → println!("Hello {:width\$}! {}", "x", 1+1);
```
https://user-images.githubusercontent.com/38400669/204344911-f1f8fbd2-706d-414e-b1ab-d309376efb9b.mov
2023-01-09 11:40:48 +00:00
bors
814ff01620
Auto merge of #13458 - cameron1024:suggest-checked-wrapping-saturating, r=Veykril
...
add wrapping/checked/saturating assist
This addresses #13452
I'm not sure about the structure of the code. I'm not sure if it needs to be 3 separate assists, and if that means it needs to be in 3 separate files as well.
Most of the logic is in `util.rs`, which feels funny to me, but there seems to be a pattern of 1 assist per file, and this seems better than duplicating the logic.
Let me know if anything needs changes 😁
2023-01-09 11:24:44 +00:00
unvalley
9eabc2cde8
fix: add_format_like_completions to handle no exprs
2023-01-09 12:23:59 +01:00
unvalley
a310fc0cd5
docs: update assist comment
2023-01-09 12:23:06 +01:00
unvalley
872df2f413
chore: update assist label name
2023-01-09 12:22:29 +01:00
unvalley
285f09cfa8
feat: extract only expressions from format string
2023-01-09 12:22:29 +01:00