Commit Graph

487 Commits

Author SHA1 Message Date
zhoufan
a539b5e693 fix: parse the range pat inside the tuple pat 2021-11-18 11:11:37 +08:00
Laurențiu Nicola
b23bebebc0 Remove validation of super in use paths 2021-11-16 20:02:42 +02:00
bors[bot]
6c7be6cd84
Merge #10734
10734: fix: add generic parameters in convert to manual impl assist r=Veykril a=TheDoctor314

Fixes #10041.

Co-authored-by: TheDoctor314 <64731940+TheDoctor314@users.noreply.github.com>
2021-11-16 11:27:11 +00:00
Lukas Wirth
92f7db447c minor: Lift out FxIndex{Map/Set} types into ide_db 2021-11-16 12:15:47 +01:00
TheDoctor314
58a24de7d8 Fix impl_def_from_trait
Revert "Fix `impl_trait` function to emit correct ast"

This reverts commit 55a4813151.

Fix `impl_def_from_trait`

It now generates the correct `ast::Impl` using
`generate_trait_impl_text` and parses it to form the right node (copied
from the private fn 'make::ast_from_text').
2021-11-15 22:28:22 +05:30
TheDoctor314
55a4813151 Fix impl_trait function to emit correct ast
`impl_trait` code copied from `generate_impl_text_inner` to properly
handle the bounds for the generic parameters.
2021-11-11 14:16:59 +05:30
bors[bot]
1e8d1e84b2
Merge #10689
10689: Handle pub tuple fields in tuple structs r=Veykril a=adamrk

The current implementation will throw a parser error for tuple structs
that contain a pub tuple field. For example,
```rust
struct Foo(pub (u32, u32));
```
is valid Rust, but rust-analyzer will throw a parser error.  This is
because the parens after `pub` is treated as a visibility context.
Allowing a tuple type to follow `pub` in the special case when we are
defining fields in a tuple struct can fix the issue.

I guess this is a really minor case because there's not much reason
for having a tuple type within a struct tuple, but it is valid rust syntax...

Co-authored-by: Adam Bratschi-Kaye <ark.email@gmail.com>
2021-11-10 21:08:51 +00:00
Adam Bratschi-Kaye
0d54754ca7 Handle pub tuple fields in tuple structs
The current implementation will throw a parser error for tuple structs
that contain a pub tuple field. For example,
```rust
struct Foo(pub (u32, u32));
```
is valid Rust, but rust-analyzer will throw a parser error.  This is
because the parens after `pub` is treated as a visibility context.
Allowing a tuple type to follow `pub` in the special case when we are
defining fields in a tuple struct can fix the issue.
2021-11-10 21:29:50 +01:00
TheDoctor314
05b368f065 Add generic parameters for manual impl assist
The `impl_trait` function takes an optional `GenericParamList` to create
the trait impl.
2021-11-10 12:53:48 +05:30
Lukas Wirth
2f5afba9f8 Replace some String usages with SmolStr in completions 2021-11-05 12:30:39 +01:00
Lukas Wirth
c93983e76f Fix for-loop expressions breaking with BlockExpr iterable 2021-10-30 16:37:32 +02:00
Lukas Wirth
3018ffd85e Refactor ide handling for paths in derive inputs 2021-10-28 16:47:19 +02:00
Aleksey Kladov
485c5e6717 internal: remove unused dollars 2021-10-23 20:44:35 +03:00
Laurențiu Nicola
8457ae34bd Set MSRV 2021-10-23 15:07:11 +03:00
bors[bot]
a75353e8ac
Merge #9939
9939: feat: Adding extract_module assist r=Veykril a=feniljain

Should solve https://github.com/rust-analyzer/rust-analyzer/issues/9591

Co-authored-by: vi_mi <fenil.jain2018@vitstudent.ac.in>
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-10-22 09:29:16 +00:00
Lukas Wirth
1294bfce86 Migrate to edition 2021 2021-10-21 20:10:40 +02:00
Lukas Wirth
b219a4c465 internal: Parse const trait bounds 2021-10-19 14:20:00 +02:00
vi_mi
32b95ea310 feat: Adding extract_module assist 2021-10-16 13:36:06 +03:00
bors[bot]
bfb8f73fb3
Merge #10545
10545: A few clippy fixes r=Veykril a=Milo123459

A few clippy fixes

Co-authored-by: Milo <50248166+Milo123459@users.noreply.github.com>
2021-10-14 20:10:59 +00:00
bors[bot]
0af9d1fc8a
Merge #10546
10546: feat: Implement promote_local_to_const assist r=Veykril a=Veykril

Fixes #7692, that is now one can invoke the `extract_variable` assist on something and then follow that up with this assist to turn it into a const.
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-14 19:51:34 +00:00
Lukas Wirth
06286ee90b Implement promotoe_local_to_const assist 2021-10-14 21:49:46 +02:00
Milo
35de195c41 a few clippy fixes 2021-10-14 19:57:21 +01:00
Yoshua Wuyts
680dd9d952 Enable delegation generation for complex types 2021-10-14 13:23:46 +02:00
Ryan Levick
0ff89deb69 Add basic support for delegation 2021-10-13 18:05:09 +02:00
Lukas Wirth
03fcf1b246 Make selections in assists with trailing/leading whitespace more forgiving 2021-10-12 14:41:59 +02:00
bors[bot]
4439cd8c68
Merge #10506
10506: Add comment r=lnicola a=k-nasa

## Why


This code looks logic-bug ...


ce86534e1c/crates/syntax/src/syntax_node.rs (L50)


However, this code has been intentionally disabled.
It's a good idea to write a comment

ref: https://github.com/rust-analyzer/rust-analyzer/pull/10357

## What

- I added comment

Co-authored-by: k-nasa <htilcs1115@gmail.com>
2021-10-10 07:56:47 +00:00
k-nasa
84bc6e159a Add comment 2021-10-10 16:53:37 +09:00
bors[bot]
64ca0f63bf
Merge #10504
10504: Remove needless clone r=lnicola a=k-nasa

## Why

Delete clones for efficiency

## What

- I erased unnecessary clones


Co-authored-by: k-nasa <htilcs1115@gmail.com>
2021-10-10 07:17:52 +00:00
k-nasa
9dd823a0e1 remove comment 2021-10-10 13:16:34 +09:00
k-nasa
3829cd981a Revert "update comment"
This reverts commit 820393f72d.
2021-10-10 10:51:45 +09:00
k-nasa
b50cb5c261 Remove neesless clone 2021-10-10 10:50:51 +09:00
k-nasa
820393f72d update comment 2021-10-10 10:16:32 +09:00
k-nasa
42377d3dad Add code comment 2021-10-10 10:10:52 +09:00
Aleksey Kladov
c2e425dd00 internal: make sure macro test expand to valid syntax 2021-10-09 18:06:24 +03:00
Aleksey Kladov
afacdd612d internal: update expect 2021-10-09 17:17:16 +03:00
Jonas Schievink
f8acae7895 Support let...else 2021-10-07 17:06:24 +02:00
cynecx
07cd19dcef parser: fix parsing of macro call inside generic args 2021-10-06 22:41:35 +02:00
bors[bot]
94fa49c0a3
Merge #10420
10420: Parse outer attributes on StructPatternEtCetera r=jonas-schievink a=XFFXFF

Try to fix https://github.com/rust-analyzer/rust-analyzer/issues/8610  
Related pr in ungrammer: https://github.com/rust-analyzer/ungrammar/pull/41

Co-authored-by: zhoufan <1247714429@qq.com>
2021-10-06 15:05:40 +00:00
bors[bot]
86c534f244
Merge #10440
10440: Fix Clippy warnings and replace some `if let`s with `match` r=Veykril a=arzg

I decided to try fixing a bunch of Clippy warnings. I am aware of this project’s opinion of Clippy (I have read both [rust-lang/clippy#5537](https://github.com/rust-lang/rust-clippy/issues/5537) and [rust-analyzer/rowan#57 (comment)](https://github.com/rust-analyzer/rowan/pull/57#discussion_r415676159)), so I totally understand if part of or the entirety of this PR is rejected. In particular, I can see how the semicolons and `if let` vs `match` commits provide comparatively little benefit when compared to the ensuing churn.

I tried to separate each kind of change into its own commit to make it easier to discard certain changes. I also only applied Clippy suggestions where I thought they provided a definite improvement to the code (apart from semicolons, which is IMO more of a formatting/consistency question than a linting question). In the end I accumulated a list of 28 Clippy lints I ignored entirely.

Sidenote: I should really have asked about this on Zulip before going through all 1,555 `if let`s in the codebase to decide which ones definitely look better as `match` :P

Co-authored-by: Aramis Razzaghipour <aramisnoah@gmail.com>
2021-10-05 08:58:40 +00:00
Aramis Razzaghipour
9583dd5725
Replace if let with match where appropriate 2021-10-05 09:00:21 +11:00
Aramis Razzaghipour
f29796da61
Replace if let Some(_) = foo with if foo.is_some() 2021-10-05 09:00:18 +11:00
zhoufan
a248f39cb4 make Some(1..) parsed 2021-10-04 17:33:48 +08:00
Aramis Razzaghipour
eff195852d
Fix miscellaneous Clippy lints 2021-10-03 23:53:30 +11:00
Aramis Razzaghipour
55c0b86cde
Add semicolons for consistency
`clippy::semicolon_if_nothing_returned`
2021-10-03 23:39:43 +11:00
bors[bot]
ebe6c38a44
Merge #10438
10438: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-03 11:06:06 +00:00
Lukas Wirth
0943c4be8b minor: Simplify 2021-10-03 13:05:42 +02:00
vi_mi
61643513b6 fix: await insertion with try_expr during extract_function 2021-10-03 09:41:21 +00:00
zhoufan
116c7aef7f move outer_attrs call before the match 2021-10-03 09:22:02 +08:00
Aleksey Kladov
7dbf24fc7a minor: dead code 2021-10-02 15:42:10 +03:00
Aleksey Kladov
d5c5b7cd12 internal: remove deprecated method 2021-10-02 15:28:55 +03:00