Commit Graph

19773 Commits

Author SHA1 Message Date
Jeremy Kolb
14ddc3353e Update crates 2021-10-15 07:12:30 -04:00
Anton Firszov
1e303cc035 cursor_inside_simple_match_arm_list -- tests 2021-10-15 12:15:52 +02:00
Aramis Razzaghipour
dce5c640f8
Move IdxRange into la_arena 2021-10-15 13:03:28 +11:00
bors[bot]
3a79af7e27
Merge #10491
10491: Support nested type on replace if let with match r=k-nasa a=k-nasa

## Why

close: https://github.com/rust-analyzer/rust-analyzer/issues/8690

Now, Replacing if-let with match cant't output exhaustive patterns code.
This was because the `else` conversion used specific types (ex. Option, Result) instead of wildcards.

I thought it was more of a problem to generate non-exhaustive patterns than the benefits of using the concrete one.

How about using wildcards in `else`? 
Is this change policy acceptable?

## What

- using wildcards on `make_else_arm`
- Change test cases

Co-authored-by: k-nasa <htilcs1115@gmail.com>
2021-10-14 22:41:06 +00: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
Anton Firszov
68a50150d6 use ctx.selection_trimmed() instead of ctx.frange.range 2021-10-14 20:45:10 +02:00
Anton Firszov
0a8a56b77a apply formatting recommendations 2021-10-14 20:38:06 +02:00
Anton Firszov
01e3022521 update generated.rs 2021-10-14 20:35:59 +02:00
Anton Firszov
8cca6242f8 make it work from macro 2021-10-14 20:31:33 +02:00
bors[bot]
e52d47a3b8
Merge #10539
10539: Add "generate delegate methods" assist r=Veykril a=yoshuawuyts

_Co-authored with `@rylev_.`

This patch adds a new assist: "generate delegate method" which creates a method that calls to a method defined on an inner field. Delegation is common when authoring newtypes, and having IDE support for this is the best way we can make this easier to author in Rust, bar adding language-level support for it. Thanks!

Closes #5944.

## Example

__before__
```rust
struct Age(u8);
impl Age {
    fn age(&self) -> u8 {
        self.0
    }
}

struct Person {
    ag$0e: Age,
}
```

__after__
```rust
struct Age(u8);
impl Age {
    fn age(&self) -> u8 {
        self.0
    }
}

struct Person {
    age: Age,
}

impl Person {
    $0fn age(&self) -> u8 {
        self.age.age()
    }
}
```

Co-authored-by: Ryan Levick <me@ryanlevick.com>
Co-authored-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
2021-10-14 18:16:17 +00:00
Anton Firszov
fb47a65ab2 apply necessary test changes 2021-10-14 19:31:27 +02:00
Yoshua Wuyts
f84b0b3242 fix ret type in generic 2021-10-14 18:38:52 +02:00
Yoshua Wuyts
987ab1feda implement feedback from review 2021-10-14 18:19:20 +02:00
Anton Firszov
a17a132617 Narrow add_missing_match_arms assist range 2021-10-14 18:15:00 +02:00
Alex Macleod
a6eeb75120 Use workspace cargo to fetch rust source's metadata
Previously the detected cargo is the global one, as it uses the
directory of the rust source which doesn't pick up the local override

This fixes the case in clippy where the local rust toolchain is a recent
nightly that has a 2021 edition Cargo.toml. The global (stable) cargo
returns an error attempting to parse it

Fixes #10445
2021-10-14 16:20:11 +01:00
Yoshua Wuyts
68ffe91526 Add support for tuple structs 2021-10-14 14:18:12 +02:00
bors[bot]
a30941e2a5
Merge #10517
10517: Show cargo check failures to the user r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10515

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-14 11:57:16 +00:00
Lukas Wirth
168f9adaf5 Kill the child process before waiting in streaming_output 2021-10-14 13:53:25 +02:00
Yoshua Wuyts
8b6ea8ee86 Update label names 2021-10-14 13:52:31 +02:00
bors[bot]
8619058d3d
Merge #10538
10538: fix: matching brace should prefer brace on cursor's right r=Veykril a=codgician

I observed a brace matching issue with the following Rust code:

```rust
let x = (1 + (2 + 3)) * 4;
```

In a situation like `<|>(1 + (2 + 3)) * 4`, the cursor will go to `(1 + (2 + 3)<|>) * 4`, and if user tries to match bracket again it will go like  `(1 + <|>(2 + 3)) * 4` while logically the expected result should be `<|>(1 + (2 + 3)) * 4`. This behavior exists in both line cursor style and block cursor style.

This PR fixes this by letting `matching_brace` prefer the brace to cursor's right when the cursor lies between multiple consecutive braces. It **does NOT** fix #1942 but could be related. Please review.


Co-authored-by: codgician <15964984+codgician@users.noreply.github.com>
2021-10-14 11:50:14 +00:00
bors[bot]
c5354877c9
Merge #10503
10503: Only include targets of packages that are workspace members r=Veykril a=bcully

CargoWorkspace's package list includes packages that are path
dependencies, even if those packages aren't actually members of the
cargo workspace. As a result, rust-analyzer's runnable finder, which
returns the target from the first workspace that has a matching package,
may select the wrong working directory, causing runnables to fail, e.g.,
```
error: package `root` cannot be tested because it requires dev-dependencies and is not a member of the workspace
```

To fix this, we filter out packages that aren't members of the workspace
when searching for targets.

Fixes #7764

Co-authored-by: Brendan Cully <brendan@cully.org>
2021-10-14 11:42:53 +00:00
Yoshua Wuyts
680dd9d952 Enable delegation generation for complex types 2021-10-14 13:23:46 +02:00
bors[bot]
f87debcf87
Merge #10434
10434: Allow `Locate parent module` command in Cargo.toml r=Veykril a=rainy-me

close #10355

Co-authored-by: rainy-me <github@rainy.me>
Co-authored-by: rainy-me <github@yue.coffee>
2021-10-14 10:56:08 +00:00
bors[bot]
641fa374ed
Merge #10309
10309: use `ControlFlow` in "extract function" assist r=Veykril a=dzvon

Fixes #10272 

Co-authored-by: Dezhi Wu <wu543065657@163.com>
2021-10-14 10:47:11 +00:00
Yoshua Wuyts
c9882c8002 Get a make version working! 2021-10-14 12:34:31 +02:00
codgician
7e68db3670 Matching brace prefers brace on cursor's right 2021-10-14 14:15:56 +08:00
bors[bot]
7d1015b8d1
Merge #10537
10537: minor: Document rustc source auto-discovery r=lnicola a=lnicola

CC #10521

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-10-14 05:57:31 +00:00
Laurențiu Nicola
e43e1240a7 Document rustc source auto-discovery 2021-10-14 08:57:07 +03:00
rainy-me
59c755227d Provide navigations to parent modules 2021-10-14 07:16:42 +09:00
Yoshua Wuyts
efb4d45ebc Update generate_delegate.rs 2021-10-13 23:59:23 +02:00
Yoshua Wuyts
c14a12edd7 create function 2021-10-13 20:13:36 +02:00
Ryan Levick
0ff89deb69 Add basic support for delegation 2021-10-13 18:05:09 +02:00
k-nasa
bd9bab87ed fix 2021-10-13 23:07:49 +09:00
Dezhi Wu
214e7cc69d merge use statement 2021-10-13 21:24:17 +08:00
Dezhi Wu
93ae993ec4 resolve ControlFlow ourself instead of hard coding. 2021-10-13 21:19:41 +08:00
bors[bot]
1619fa9d8f
Merge #10534
10534: Made Rust analyzer logos dark mode friendly r=lnicola a=Permik

Hi! Here's a list of changes what I made to the logos to make them dark mode friendly:

* Simplified the letter R in both logos for strokes to play nice
* Added white stroke around the dark letters about the same weight as the light gray stroke around the rectangle/square

Extra, that is nice but doesn't really matter:
* Simplified the dots in the logo to be circles, not paths

Co-authored-by: Santtu Ojanperä <tintti214@gmail.com>
2021-10-13 13:13:00 +00:00
k-nasa
bc29b75b92 update calc_depth 2021-10-13 22:06:53 +09:00
k-nasa
b3930599a7 calc depth 2021-10-13 22:02:39 +09:00
bors[bot]
e24429f31b
Merge #10536
10536: minor: Make AssistContext::frange private r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-13 12:41:25 +00:00
Lukas Wirth
ccad89a2db Make AssistContext::frange private 2021-10-13 14:39:37 +02:00
k-nasa
ef9c4b666f move test case 2021-10-13 21:03:01 +09:00
k-nasa
a6a052f407 Revert "Apply make_else_arm to general case"
This reverts commit aeee70397e.
2021-10-13 20:36:04 +09:00
Dezhi Wu
5818358bbf import ControlFlow to the module 2021-10-13 09:09:07 +08:00
Dezhi Wu
f888e85f79 use ControlFlow::Break(_) pattern 2021-10-13 09:06:47 +08:00
Dezhi Wu
971a271840 use ControlFlow in "extract function" assist 2021-10-13 09:06:47 +08:00
Santtu Ojanperä
0ab1768401 Simplified the dot in the wide logo 2021-10-13 01:41:12 +03:00
Santtu Ojanperä
6436bd1aaa Made the Rust analyzer logos more dark mode friendly 2021-10-13 01:22:47 +03:00