Matthew Hall
6a2127be28
Cleanup checking for existing impls in impl From assist
...
Use the trait solver to check if there's an existing implementation of
From<type_in_enum_variant> for the enum.
2020-04-02 18:42:30 +01:00
Matthew Hall
1fee60181f
Add impl From for enum variant assist
...
Basically adds a From impl for tuple enum variants with one field. Added
to cover the fairly common case of implementing your own Error that can
be created from another one, although other use cases exist.
2020-04-01 22:26:41 +01:00
Timo Freiberg
10667753c7
Use ast::make API in add_function assist
2020-04-01 23:06:14 +02:00
Timo Freiberg
e5fc42cbc1
Add create_function assist
2020-04-01 23:06:14 +02:00
Aleksey Kladov
2fe6e23138
When adding match arm, don't let the floating comma
2020-03-31 14:52:20 +02:00
Aleksey Kladov
0cfa9eb445
Use IntoIter
2020-03-30 12:28:22 +02:00
Matthew Hall
77bb9a56f1
Remove "TODO" in comment in test
2020-03-28 21:24:26 +00:00
Matthew Hall
ecc2615ba2
Append new match arms rather than replacing all of them
...
This means we now retain comments when filling in match arms.
2020-03-28 20:58:46 +00:00
Aleksey Kladov
b764c38436
Start stdx
...
This crate will hold everything to small to be worth publishing
2020-03-28 11:01:25 +01:00
Piotr Szpetkowski
f016d8b900
Fix merge-imports assist for wildcard imports
2020-03-27 17:28:25 +01:00
Aleksey Kladov
dc311b10f3
Fix assist description
2020-03-27 13:23:19 +01:00
bors[bot]
a4901fdcfd
Merge #3742
...
3742: Replace if with if-let r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-27 11:21:57 +00:00
Aleksey Kladov
91e482b46d
Replace if with if-let
2020-03-27 12:15:46 +01:00
bors[bot]
f9cf86475c
Merge #3741
...
3741: More general ctor for ifs r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-27 10:38:31 +00:00
Aleksey Kladov
cbb53cf55c
More general ctor for ifs
2020-03-27 11:38:00 +01:00
bors[bot]
20c110e57f
Merge #3732
...
3732: Assist: replace unwrap with match r=matklad a=unrealhoang
attempt on #3669
Co-authored-by: Unreal Hoang <unrealhoang@gmail.com>
2020-03-26 15:38:03 +00:00
Aleksey Kladov
db34abeb85
Get rid of ItemOrMacro
2020-03-26 16:10:01 +01:00
Unreal Hoang
d9df0f43ac
Assist: replace unwrap with match
2020-03-27 00:08:12 +09:00
Aleksey Kladov
72c6fc3ff0
Fix add visibility false-positive
2020-03-25 15:55:57 +01:00
bors[bot]
9690f6bc43
Merge #3708
...
3708: Generalise syntax rewriting infrastructure to allow removal of nodes r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-24 16:15:08 +00:00
Aleksey Kladov
062f6e3bbe
Generalise syntax rewriting infrastructure to allow removal of nodes
2020-03-24 17:14:33 +01:00
bors[bot]
7c2cc85806
Merge #3705
...
3705: Align naming r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-24 11:56:43 +00:00
Aleksey Kladov
9bf2cd609c
Align naming
2020-03-24 12:56:07 +01:00
bors[bot]
6ef64622af
Merge #3700
...
3700: fill match arms with empty block rather than unit tuple r=matklad a=JoshMcguigan
As requested by @Veetaha in #3689 and #3687 , this modifies the fill match arms assist to create match arms as an empty block `{}` rather than a unit tuple `()`.
In one test I left one of the pre-existing match arms as a unit tuple, and added a body to another match arm, to demonstrate that the contents of existing match arms persist.
Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
2020-03-24 11:48:32 +00:00
Kirill Bulatov
dd3b64124b
Add a test
2020-03-24 10:43:24 +02:00
Kirill Bulatov
944f28fe5b
Use more generic public api
2020-03-24 10:43:22 +02:00
Kirill Bulatov
d221ff4f9e
Auto import macros
2020-03-24 10:43:00 +02:00
Josh Mcguigan
7ba934fe58
fill match arms with empty block rather than unit tuple
2020-03-23 19:23:30 -07:00
Josh Mcguigan
df58ab8963
update itertools version to 0.9.0
2020-03-23 16:22:46 -07:00
Aleksey Kladov
3bd119a4c1
Add a test
2020-03-23 20:57:42 +01:00
Josh Mcguigan
bc48c9d511
review comments
2020-03-23 05:19:09 -07:00
Josh Mcguigan
2afccbe477
implement fill match arm assist for tuple of enums
2020-03-22 23:28:25 -07:00
Josh Mcguigan
c3702a6b71
disable invert if assist for if-let to fix #3281
2020-03-21 06:40:18 -07:00
Steffen Lyngbaek
b5ba9c3e3a
Address nits and suggestions.
...
Simplify the logic a lot by removing the check for a placeholder pat.
This means the auto-fill no longer returns a compile-able value.
2020-03-19 11:49:01 -07:00
Steffen Lyngbaek
5f8f8a38a2
Don't show assist if all arms are present
2020-03-19 11:47:33 -07:00
Steffen Lyngbaek
6087c01460
'Fill match arms' should work with existing match arms
...
Addresses #3039
This essentially adds missing match arms. The algorithm for this
can get complicated rather quickly so bail in certain conditions
and rely on a PlaceholderPat.
The algorighm works as such:
- Iterate through the Enum Def Variants
- Attempt to see if the variant already exists as a match arm
- If yes, skip the enum variant. If no, include it.
- If it becomes complicated, rather than exhaustively deal with every
branch, mark it as a "partial match" and simply include the
placeholder.
Conditions for "complication":
- The match arm contains a match guard
- Any kind of nested destrucuring
Order the resulting merged match branches as such:
1. Provided match arms
2. Missing enum variant branch arms
3. End with Placeholder if required
- Add extra tests
2020-03-19 11:47:33 -07:00
Aleksey Kladov
7e2bca4ec3
Cleanup imports
2020-03-19 12:36:33 +01:00
Aleksey Kladov
0c55c06944
Merge nested use trees
2020-03-19 12:18:59 +01:00
Aleksey Kladov
ef3bf906c4
Generalize
2020-03-19 11:38:26 +01:00
Aleksey Kladov
0bf903411c
Use match_ast
2020-03-18 20:51:47 +01:00
Aleksey Kladov
3f6dc20d3c
Merge imports assist
...
Work towards #2220
2020-03-18 19:34:47 +01:00
Aleksey Kladov
3c88ef76d6
Reduce visibility
2020-03-18 16:48:45 +01:00
Aleksey Kladov
6eb05c4a14
Simplify
2020-03-13 18:02:04 +01:00
Aleksey Kladov
687bec117c
Don't use generic DB where a concrete one will do
2020-03-13 17:58:49 +01:00
CAD97
88c944f96b
Remove some TextUnit->usize escapees
2020-03-12 22:33:27 -04:00
Aleksey Kladov
ea0c124219
Rerail split_import API onto AST
...
The code is more verbose and less efficient now, but should be
reusable in add_import context as well
2020-03-06 14:08:43 +01:00
Kirill Bulatov
0ff8c55246
Unfold groups with single assists into plain assists
2020-03-06 00:17:26 +02:00
Aleksey Kladov
f57682c0b3
Remove old find refs infra
2020-03-04 14:25:22 +01:00
Aleksey Kladov
cf0ececb7a
Highlight assist tests
2020-03-03 17:03:46 +01:00
Aleksey Kladov
1cca6b2a3d
Fix applicability of inline local
2020-03-03 16:56:42 +01:00