Jonas Schievink
20ae41c1a1
Reuse database in LowerCtx
2021-05-06 23:23:50 +02:00
Aleksey Kladov
c4f9cb9b53
Update crates/hir_def/src/nameres/tests/incremental.rs
...
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-05-06 20:00:43 +02:00
Aleksey Kladov
548e5a5c29
internal: add failing incremental test
2021-05-06 20:00:11 +02:00
Jonas Schievink
976a3226fe
Don't store call-site text offsets in hygiene info
2021-05-06 19:59:54 +02:00
Kirill Bulatov
607d8a2f61
Small macro fix
2021-05-06 20:12:30 +03:00
Aleksey Kladov
6a16ec52aa
internal: use API stabilized in 1.52
2021-05-06 20:12:15 +03:00
Lukas Tobias Wirth
d97a4b8e49
Support goto_type_definition for types
2021-05-06 17:05:49 +02:00
Edwin Cheng
1fb20e3231
Simplify
2021-05-06 22:39:51 +08:00
Jesse Bakker
10254b5d95
Fix: Do not overwrite comments and attrs in trait impl completion
2021-05-06 16:16:38 +02:00
Dawer
90a5dca0a2
Fix build
2021-05-06 10:22:51 +05:00
Dawer
0a156c80af
Hide implementation details of TokenText
2021-05-06 10:07:06 +05:00
Dawer
d9b4ac8128
Clean up
2021-05-06 10:07:06 +05:00
Dawer
d7e169fe55
Borrow text from nodes of immutable syntax trees
2021-05-06 10:07:06 +05:00
Dawer
dc4fa504ea
Adapt to a new rowan borrowing node API.
2021-05-06 10:06:52 +05:00
Dawer
52143f389f
Update to rowan 0.13.0-pre.5
2021-05-06 10:04:39 +05:00
bors[bot]
c3596371d8
Merge #8674
...
8674: fix for #8664 : Emit folding ranges for multi-line where clauses r=matklad a=m5tfi
#8664
I added a test that assert folding multi-line where clauses while leaving single lined one. Please, let me know if the code needs further improvements.
Co-authored-by: m5tfi <72708423+m5tfi@users.noreply.github.com>
2021-05-05 21:14:12 +00:00
Lukas Tobias Wirth
3f796fea9f
simplify
2021-05-05 22:55:12 +02:00
m5tfi
c2cf34db90
remove unneeded visited_where_clauses
2021-05-05 06:28:41 +02:00
Lukas Tobias Wirth
d26fb188c1
Add some cov marks for qualified_path completion
2021-05-04 22:35:37 +02:00
Aleksey Kladov
1ea4dae596
Document expansion queries
2021-05-04 22:41:46 +03:00
Aleksey Kladov
3f6980e4e1
simplify macro expansion code
...
Using `Option` arguments such that you always pass `None` or `Some` at
the call site is a code smell.
2021-05-04 22:41:46 +03:00
Aleksey Kladov
95dc8ef265
make illegal states unrepresentable
...
only declarative macros have def-site token map
2021-05-04 22:41:43 +03:00
Aleksey Kladov
7d9ea39de6
Cleanups
2021-05-04 22:40:59 +03:00
bors[bot]
010e4c8fe0
Merge #8731
...
8731: Complete enum variants through type aliases r=Veykril a=Veykril
Fixes #8730
bors r+
Co-authored-by: Lukas Tobias Wirth <lukastw97@gmail.com>
2021-05-04 19:05:19 +00:00
Lukas Tobias Wirth
8b94bf7b2d
Complete enum variants through type aliases
2021-05-04 21:04:19 +02:00
bors[bot]
e17748e4b2
Merge #8727
...
8727: minor: use standard import style r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-04 17:37:09 +00:00
Aleksey Kladov
2e97dbcbb8
minor: use standard import style
2021-05-04 20:36:48 +03:00
bors[bot]
5e87f84211
Merge #8726
...
8726: internal: reduce visibility r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-04 17:29:55 +00:00
Aleksey Kladov
87f827bfaf
internal: reduce visibility
2021-05-04 20:29:30 +03:00
bors[bot]
871bc1cd08
Merge #8725
...
8725: internal: env var to toggle slow benches r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-04 15:31:10 +00:00
Aleksey Kladov
a1f42ef8ad
internal: env var to toggle slow benches
2021-05-04 18:21:36 +03:00
Aleksey Kladov
16f7c3ea91
minor: unconfuse myself about macro def vs macro rules
2021-05-04 18:20:10 +03:00
bors[bot]
a231da9d24
Merge #8720
...
8720: internal: add integrated completion benchmark r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-04 12:14:56 +00:00
Aleksey Kladov
b2f040fc9a
internal: add integrated completion benchmark
2021-05-04 15:14:33 +03:00
bors[bot]
d9f1b5fc7c
Merge #8719
...
8719: Fix block comment intra doc link injection ranges r=Veykril a=Veykril
bors r+
Co-authored-by: Lukas Tobias Wirth <lukastw97@gmail.com>
2021-05-04 12:00:30 +00:00
Lukas Tobias Wirth
5a78d96d0e
Fix block comment intra doc link injection ranges
2021-05-04 13:51:57 +02:00
bors[bot]
6d812efcd9
Merge #8711
...
8711: Only resolve selected assist r=matklad a=SomeoneToIgnore
Part of https://github.com/rust-analyzer/rust-analyzer/issues/8700
Now resolves only the assist that was selected out of the list, while before the whole assist list was resolved despite a single popup selection.
Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2021-05-04 11:51:09 +00:00
Aleksey Kladov
41f8ae7daa
More searchable name
2021-05-04 10:23:47 +03:00
bors[bot]
0323045631
Merge #8714
...
8714: internal: remove one more usage of the rewriter r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-04 07:07:06 +00:00
Aleksey Kladov
ae6b9c25ed
internal: remove one more usage of the rewriter
2021-05-04 09:42:20 +03:00
memoryruins
27ba1dd8e3
Replace memmap
to memmap2
in proc_macro_api
2021-05-03 20:20:47 -04:00
Kirill Bulatov
734b95a1ac
Code review fixes
2021-05-03 23:24:36 +03:00
bors[bot]
a0ec841bfe
Merge #8715
...
8715: Make CompletionContext expected_type smarter r=Veykril a=Veykril
bors r+
Co-authored-by: Lukas Tobias Wirth <lukastw97@gmail.com>
2021-05-03 19:36:40 +00:00
Lukas Tobias Wirth
121bd5c533
Make CompletionContext expected_type smarter
2021-05-03 21:34:34 +02:00
Lukas Tobias Wirth
3d6d4e9855
Don't mutate the tree while traversing in reorder_impl
2021-05-03 18:36:31 +02:00
Kirill Bulatov
90fc329377
Index retrieval fix
2021-05-03 19:35:44 +03:00
Kirill Bulatov
53a73de3d1
Small fixes
2021-05-03 18:45:30 +03:00
Kirill Bulatov
8089a227f4
Tests added
2021-05-03 18:40:04 +03:00
Kirill Bulatov
b1d600a1ec
Less panics in the assist resolution
2021-05-03 18:18:45 +03:00
Kirill Bulatov
28293d370f
Add docs and use better naming
2021-05-03 18:16:35 +03:00
Kirill Bulatov
1679a376f3
Resolve single assist only
2021-05-03 18:03:28 +03:00
Kirill Bulatov
e5cdcb8b12
Add a way to resolve certain assists
2021-05-03 17:14:49 +03:00
Daniel McNab
11c926fd97
Add a test for conditionally compiled tails
2021-05-03 14:14:33 +01:00
Daniel McNab
ebbcf9f458
Fix inference with conditionally compiled tails
...
Fixes #8378
2021-05-03 14:13:05 +01:00
Aleksey Kladov
cd69307aee
fix: don't duplicate Progerss::Finised for cache priming
2021-05-02 21:45:00 +03:00
bors[bot]
548c18c062
Merge #8693
...
8693: Ensure that only one cache priming task can run at a time r=matklad a=Bobo1239
Fixes #8632 .
Co-authored-by: Boris-Chengbiao Zhou <bobo1239@web.de>
2021-05-02 18:34:29 +00:00
Brandon
43c79a35a8
Fix feature description inconsistency
2021-04-30 19:47:41 -07:00
Jonas Schievink
6873920c4f
find_path: check only crate-level prelude
2021-04-30 18:41:18 +02:00
Boris-Chengbiao Zhou
ce8c6c4762
Ensure that only one cache priming task can run at a time
...
Fixes #8632 .
2021-04-30 16:48:11 +02:00
bors[bot]
b5b4a1f23d
Merge #8692
...
8692: Fix panic caused by new Try trait definition r=flodiebold a=flodiebold
The new Try trait definition caused a query cycle for us. This adds recovery for that cycle, but also fixes the cause, which is that we went through the supertraits when resolving `<T as Trait>::Assoc`, which isn't actually necessary. I also rewrote `all_super_trait_refs` to an iterator before I realized what the actual problem was, so I kept that.
Fixes #8686 .
Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2021-04-30 09:07:24 +00:00
bors[bot]
6ea91a419f
Merge #8695
...
8695: internal: fix naming polarity r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-04-30 08:57:17 +00:00
Aleksey Kladov
1a01a5ae19
internal: fix naming polarity
...
Type Constructors have *parameters*, when they are substituted with type
*arguments*, we have a type.
2021-04-30 11:55:59 +03:00
Aleksey Kladov
cb3ef552e8
internal: normalize name
...
All def types in hir are unsubstituted
2021-04-30 11:52:31 +03:00
m5tfi
5778ab1e41
add folding for where clauses
2021-04-30 10:18:36 +02:00
Florian Diebold
c2aefd5b95
Don't look in super traits for <T as Trait>::Assoc
...
This isn't actually how it works, you have to specify the exact trait
that has the associated type.
Fixes #8686 .
2021-04-29 20:23:02 +02:00
Florian Diebold
2d20ab7eaf
Rewrite all_super_trait_refs as an iterator
...
Doesn't fix the bug I was trying to fix, but now that I did it anyway it
seems fine to keep.
2021-04-29 20:18:41 +02:00
Florian Diebold
b384cfcb81
Handle cycles in generic_defaults more gracefully
2021-04-29 20:00:43 +02:00
Florian Diebold
184a0d7c1e
Add test for #8686
2021-04-29 20:00:21 +02:00
Comonad
78f1583bdd
fix: closure unify without check ClosureId
...
closes #8604
2021-04-29 15:26:41 +08:00
Jonas Schievink
cb8632d87c
Parse const param defaults
2021-04-29 03:07:53 +02:00
Jonas Schievink
caee3a2eeb
Correctly parse negated literals as const args
2021-04-29 02:27:55 +02:00
Aleksey Kladov
5c1a901035
internal: ensure that client and server-side configs are not mixed up
...
https://github.com/rust-lang/rust/issues/84647 would help big time here.
2021-04-28 13:13:30 +03:00
bors[bot]
86b5084917
Merge #8679
...
8679: fix: don't show error message for a valid notification r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-04-27 13:10:22 +00:00
Aleksey Kladov
f45c1ffc5b
fix: don't show error message for a valid notification
...
Closes #6782 , #6772
2021-04-27 16:09:59 +03:00
Jeremy Kolb
36c20dc23d
Return ServerNotInitialized according to the spec
...
According to the spec we should return ServerNotInitialized if the server is waiting for an initialize request and something else comes in.
Upgrading to lsp-server 0.5.1 will do this and retry until the initialize request comes in.
Fixes #8581
2021-04-27 07:47:06 -04:00
Jorge Mederos Alvarado
c4dba4077f
Add config options
2021-04-26 20:29:54 -04:00
Aleksey Kladov
f06e4b8e74
minor: simplify
2021-04-26 19:30:50 +03:00
Aleksey Kladov
363cef5c0e
fix: make error message in the status bar more useful
...
At the moment,the popup is just a bazillion of Cargo's "Compiling this\nCompiling that",
which is not that useful.
--quiet still displays error, which is what we needc
2021-04-26 19:16:07 +03:00
Kirill Bulatov
c24bdab97e
Use -u instead of --utc date flag
2021-04-26 17:12:13 +03:00
Aleksey Kladov
4f9640ff39
fix: add date to the version string on Mac
...
It doesn't support `--iso`
2021-04-26 15:20:15 +03:00
Bastian Kersting
421cf9a1bd
Fixed formatting
2021-04-26 11:37:28 +02:00
Bastian Kersting
336b81abd7
Added mutable semantic token modifier for &mut self methods
2021-04-26 09:24:18 +02:00
Danny Zhu
09fc5e1dd7
Check more carefully for cases where a rename can't be done
...
Attempting to rename an element of a tuple field would previously
replace the type with the new name, which doesn't make sense; now it
fails instead.
The check is done in both `prepare_rename` and `rename` so that the case
is caught before the user is prompted for a new name. Some other
existing failure cases are also now additionally checked in
`prepare_rename`.
2021-04-25 14:08:56 -07:00
Lukas Wirth
050c69c19d
Split out merge_imports module from helpers::insert_use
2021-04-24 13:31:43 +02:00
Aleksey Kladov
8d54fd105c
fix: correct version string to contain hash, build date and channel
2021-04-24 13:36:45 +03:00
bors[bot]
5cbde9f531
Merge #8591 #8638
...
8591: Remove SyntaxRewriter usage in insert_use in favor of mutable syntax trees r=matklad a=Veykril
Unfortunately changing `insert_use` to not use `SyntaxRewriter` creates a lot of changes since so much relies on that. But on the other hand this should be the biggest usage of `SyntaxRewriter` I believe.
8638: Remove SyntaxRewriter::from_fn r=Veykril a=Veykril
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-04-23 16:49:08 +00:00
Lukas Wirth
e6e4417bbb
Remove SyntaxRewriter::from_fn
2021-04-23 18:36:43 +02:00
Lukas Wirth
1e88f5ec8e
Simplify highlight token match guards
2021-04-23 17:27:18 +02:00
Lukas Wirth
ef6f596b4b
Sort HlMod variants and ALL const
2021-04-23 17:24:58 +02:00
Lukas Wirth
c005ce60a0
Tag yield
and await
as ControlFlow in semantic highlighting
2021-04-23 17:24:45 +02:00
bors[bot]
85bab7539a
Merge #8317
...
8317: Convert tuple struct to named struct assist r=Veykril a=unexge
Closes https://github.com/rust-analyzer/rust-analyzer/issues/8192
Co-authored-by: unexge <unexge@gmail.com>
2021-04-23 13:37:48 +00:00
unexge
5e765895cf
Add missing test case for "Convert to named struct" assist
2021-04-23 16:18:10 +03:00
unexge
97270dfb91
Stop iterating reference after made an edit in "Convert to named struct" assist
2021-04-23 13:08:07 +03:00
bors[bot]
07fb65abb8
Merge #8628
...
8628: minor: Add one more profiling span to add_dep r=lnicola a=lnicola
CC #8623
bors r+
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-04-22 18:48:53 +00:00
Laurențiu Nicola
c37ca7841c
Add one more profiling span to add_dep
2021-04-22 21:48:17 +03:00
bors[bot]
e529f73355
Merge #8627
...
8627: Add profiling spans under cargo_to_crate_graph r=lnicola a=lnicola
bors r+
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-04-22 18:26:09 +00:00
Laurențiu Nicola
6b187af337
Add profiling spans under cargo_to_crate_graph
2021-04-22 21:25:29 +03:00
bors[bot]
0bb074aa26
Merge #8620
...
8620: Remove unnecessary braces for extracted block expression r=Veykril a=brandondong
This change addresses the first bullet point of https://github.com/rust-analyzer/rust-analyzer/issues/7839 .
Specifically, when extracting block expressions, remove the unneeded extra braces inside the generated function.
Co-authored-by: Brandon <brandondong604@hotmail.com>
2021-04-22 15:22:43 +00:00
unexge
affd8d3518
Move reference editing logic into own function to make error handling more ease in "Convert to named struct" assist
2021-04-22 11:33:56 +03:00
Brandon
1713f4c7cd
Remove unnecessary braces for extracted block expression
2021-04-21 23:39:35 -07:00
Lukas Wirth
d5c9de65c5
Don't filter equal nodes in reorder assists
2021-04-22 00:54:31 +02:00
James Leitch
72718bc2d7
Code review feedback.
2021-04-21 15:10:53 -07:00
James Leitch
9fcad82980
Diagnostic Remap Path Prefixes added.
2021-04-21 15:10:53 -07:00
James Leitch
60841f4276
Diagnostic paths attempt to use VSCode's path join behavior before defaulting to Rust's path join behavior.
2021-04-21 15:10:53 -07:00
bors[bot]
32491c0978
Merge #8570
...
8570: Flycheck tries to parse both Cargo and Rustc messages. r=rickvanprim a=rickvanprim
This change allows non-Cargo build systems to be used for Flycheck provided they call `rustc` with `--error-format=json` and emit those JSON messages to `stdout`.
Co-authored-by: James Leitch <rickvanprim@gmail.com>
2021-04-21 21:56:54 +00:00
bors[bot]
b21701c5ee
Merge #8616
...
8616: minor: Bump deps r=lnicola a=lnicola
bors r+
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-04-21 16:20:56 +00:00
Laurențiu Nicola
27c5e2da48
Bump chalk
2021-04-21 19:20:01 +03:00
Laurențiu Nicola
e50ca6b067
Bump rustc_lexer
2021-04-21 19:19:27 +03:00
Jonas Schievink
0414b65319
Remove ItemTree::all_inner_items
2021-04-21 18:10:25 +02:00
Jonas Schievink
7b7d051e81
Add failing local items test
2021-04-21 17:57:45 +02:00
unexge
322cd1fa7f
Use multiple loops instead of Iterator::chain
in FindUsages
2021-04-21 16:42:47 +03:00
unexge
6630266ce1
Add multi file test for "Convert to named struct" assist
2021-04-21 16:20:08 +03:00
unexge
96d694062b
Remove unwrap
s in "Convert to named struct" assist
2021-04-21 16:01:13 +03:00
Comonad
09147c3303
Add support for fill match arms of boolean values
...
- Add support for boolean inside tuple
2021-04-21 19:33:45 +08:00
Lukas Wirth
3f7a086b4f
Parse outer atttributes for RecordPatField
2021-04-21 11:08:15 +02:00
unexge
e0a60e71d7
Add larger example for "Convert to named struct" assist
2021-04-21 10:57:36 +03:00
unexge
53599d11f6
Fix incorrectly replacing method calls in "Convert to named struct" assist
2021-04-21 10:27:26 +03:00
Aleksey Kladov
cdfe5a8be0
fix: no more Registering progress handler for token rustAnalyzer/Indexing failed.
2021-04-20 22:54:05 +03:00
Lukas Wirth
b290cd5782
Add cov_marks to insert_use tests
2021-04-20 19:34:43 +02:00
Lukas Wirth
2c8f1b5c30
Rewrite extract_struct_from_enum_variant assist
2021-04-20 17:36:42 +02:00
bors[bot]
ad131049c4
Merge #8600
...
8600: fix: no longer get stuck on windows r=matklad a=matklad
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-04-20 15:05:33 +00:00
Aleksey Kladov
1772eb0f1a
fix: no longer get stuck on windows
...
reading both stdout & stderr is a common gotcha, you need to drain them
concurrently to avoid deadlocks. Not sure why I didn't do the right
thing from the start. Seems like I assumed the stderr is short? That's
not the case when cargo spams `compiling xyz` messages
2021-04-20 18:02:54 +03:00
bors[bot]
86c2bb3c5b
Merge #8602
...
8602: Fix panic in `replace_derive_with_manual_impl` r=jonas-schievink a=jonas-schievink
bors r+
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-04-20 14:27:08 +00:00
Jonas Schievink
c0ad9b3581
Follow testing style guide
2021-04-20 16:26:07 +02:00
Jonas Schievink
6624158969
Fix panic in replace_derive_with_manual_impl
2021-04-20 16:25:24 +02:00
Jonas Schievink
d699371f5f
"Inline variable" when on a use of the variable
2021-04-20 16:16:23 +02:00
Lukas Wirth
fa20a5064b
Remove SyntaxRewriter usage in insert_use in favor of ted
2021-04-20 02:09:12 +02:00
Lukas Wirth
e8744ed9bb
Replace SyntaxRewriter usage with ted in reorder_impl assist
2021-04-20 02:08:21 +02:00
James Leitch
b3a7953cae
Code review feedback.
2021-04-19 12:26:04 -07:00
bors[bot]
b6a7276c54
Merge #8586
...
8586: Replace SyntaxRewriter usage with ted in eager::eager_macro_recur r=Veykril a=Veykril
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-04-19 18:03:56 +00:00
Jonas Schievink
ec05186378
Add autoimport test with inner items
2021-04-19 19:53:29 +02:00
Jonas Schievink
59630977a5
Fix some find_path bugs around inner items
2021-04-19 19:50:11 +02:00
Lukas Wirth
952fc23694
Replace SyntaxRewriter with ted in exppand_macro::expand_macro_recur
2021-04-19 19:43:26 +02:00
Lukas Wirth
617cd7231c
Remove SyntaxRewriter usage in eager::eager_macro_recur
2021-04-19 19:28:41 +02:00
bors[bot]
0741de87e7
Merge #8584
...
8584: internal: fix slightly broken test r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-04-19 16:04:44 +00:00
Aleksey Kladov
21f4588fc8
internal: fix slightly broken test
2021-04-19 18:57:47 +03:00
bors[bot]
fc709c8b21
Merge #8583
...
8583: Simplify r=Veykril a=Veykril
bors r+
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-04-19 15:55:29 +00:00
bors[bot]
2b5f35ca4b
Merge #8582
...
8582: Fix typo: comparision -> comparison r=kjeremy a=stanciuadrian
Closes #8576
Co-authored-by: Adrian Stanciu <stanciu.adrian@gmail.com>
2021-04-19 15:47:18 +00:00
Adrian Stanciu
1c75d8975c
Fix typo: comparision -> comparison
2021-04-19 18:44:38 +03:00
Lukas Wirth
c96c38edd3
Simplify
2021-04-19 17:11:30 +02:00
bors[bot]
6877e6e4da
Merge #8578
...
8578: fix: false positive about inner attrs in docs r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-04-19 14:37:54 +00:00
Aleksey Kladov
5f89a60f1a
fix: false positive about inner attrs in docs
...
closes #8541
2021-04-19 17:11:49 +03:00
bors[bot]
6991b517f2
Merge #8577
...
8577: Support crates/module roots in external_docs r=Veykril a=Veykril
Fixes #8575
bors r+
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-04-19 13:51:57 +00:00
Lukas Wirth
6142afeafd
Support crates/module roots in external_docs
2021-04-19 15:50:04 +02:00
bors[bot]
e7a8977358
Merge #8524 #8527
...
8524: Fix extract function with partial block selection r=matklad a=brandondong
**Reproduction:**
```rust
fn foo() {
let n = 1;
let mut v = $0n * n;$0
v += 1;
}
```
1. Select the snippet ($0) and use the "Extract into function" assist.
2. Extracted function is incorrect and does not compile:
```rust
fn foo() {
let n = 1;
let mut v = fun_name(n);
v += 1;
}
fn fun_name(n: i32) {}
```
3. Omitting the ending semicolon from the selection fixes the extracted function:
```rust
fn fun_name(n: i32) -> i32 {
n * n
}
```
**Cause:**
- When `extraction_target` uses a block extraction (semicolon case) instead of an expression extraction (no semicolon case), the user selection is directly used as the TextRange.
- However, the existing function extraction logic for blocks requires that the TextRange spans from start to end of complete statements to work correctly.
- For example:
```rust
fn foo() {
let m = 2;
let n = 1;
let mut v = m $0* n;
let mut w = 3;$0
v += 1;
w += 1;
}
```
produces
```rust
fn foo() {
let m = 2;
let n = 1;
let mut v = m let mut w = fun_name(n);
v += 1;
w += 1;
}
fn fun_name(n: i32) -> i32 {
let mut w = 3;
w
}
```
- The user selected TextRange is directly replaced by the function call which is now in the middle of another statement. The extracted function body only contains statements that were fully covered by the TextRange and so the `* n` code is deleted. The logic for calculating variable usage and outlived variables for the function parameters and return type respectively search within the TextRange and so do not include `m` or `v`.
**Fix:**
- Only extract full statements when using block extraction. If a user selected part of a statement, extract that full statement.
8527: Switch introduce_named_lifetime assist to use mutable syntax tree r=matklad a=iDawer
This extends `GenericParamsOwnerEdit` trait with `get_or_create_generic_param_list` method
Co-authored-by: Brandon <brandondong604@hotmail.com>
Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
2021-04-19 13:09:18 +00:00
bors[bot]
e4f7f1e1bd
Merge #8462
...
8462: Expand macros at type position r=jonas-schievink a=cynecx
Co-authored-by: cynecx <me@cynecx.net>
2021-04-19 13:01:30 +00:00
bors[bot]
3f1a220f32
Merge #8574
...
8574: Check for rust doc code attributes like rustdoc does r=Veykril a=Veykril
bors r+
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-04-19 11:39:45 +00:00
Lukas Wirth
2f62c0117a
Check for rust doc code attributes like rustdoc does
2021-04-19 13:32:52 +02:00
bors[bot]
65dd942fa1
Merge #8565
...
8565: Fill match arms assist: add remaining arms for tuple of enums r=iDawer a=iDawer
Fix for #8493
However, the assist is still flaky and does not use `hir_ty::diagnostics::match_check`
Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
2021-04-19 11:32:22 +00:00
Dawer
9222d3b0fb
Unindent test according to the style guide.
2021-04-19 16:24:09 +05:00