Commit Graph

423 Commits

Author SHA1 Message Date
Aleksey Kladov
1171dc74e0 internal: remove unused param 2021-07-11 15:08:00 +03:00
Aleksey Kladov
5021f10660 internal: add a test for broken refactor 2021-07-11 15:05:16 +03:00
Aleksey Kladov
f42648e305 internal: remove needless distinction between a carte and its root mod 2021-07-11 14:55:24 +03:00
bors[bot]
2e52d6ea93
Merge #9557
9557: fix: Respect coercions in `inline_call` r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-10 17:25:16 +00:00
Lukas Wirth
9e1eb77f6b Respect coercions in inline_call 2021-07-10 19:24:49 +02:00
Lukas Wirth
7e6f40b6f1 Expose coercions for patterns and expressions in semantics 2021-07-10 19:03:46 +02:00
bors[bot]
f83f069f94
Merge #9552
9552: internal: `add_explicit_type` respects coercions r=Veykril a=Veykril

or so I'd like to say but there is one odd case here where it doesn't work(see [review](https://github.com/rust-analyzer/rust-analyzer/pull/9552#discussion_r667351856))

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-10 16:25:58 +00:00
Lukas Wirth
576e3a4e12 add_explicit_type respects coercions 2021-07-10 18:19:46 +02:00
bors[bot]
2d7727fe31
Merge #9553
9553: minor: Disambiguate replace with if let assist labels r=Veykril a=Veykril

Turns out we have two assists for replacing something with `if let` constructs, so having the cursor on a `let` keyword inside a match gave you two identical assist labels which is rather confusing.
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-10 16:07:01 +00:00
Lukas Wirth
0796288ed2 Disambiguate replace with if let assist labels 2021-07-10 18:00:22 +02:00
bors[bot]
4337f5e456
Merge #9555 #9556
9555: feat: Enable `auto_import` on ident patterns r=Veykril a=Veykril

Helpful for when you want to import a type in a pattern right before destructuring it.

9556: Bump deps r=lnicola a=lnicola

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-07-10 15:59:26 +00:00
Lukas Wirth
79614c486b Enable auto_import on ident patterns 2021-07-10 17:57:33 +02:00
Lukas Wirth
0db5992311 replace_qualified_name_with_use keeps qualifier for import 2021-07-10 17:03:24 +02:00
vi_mi
57f119b5fa fix: Adding async keyword when await is present in generate_function assist 2021-07-09 20:04:55 +05:30
Lukas Wirth
d91704cac5 Invert boolean literals in assist negation logic 2021-07-06 20:30:26 +02:00
bors[bot]
112e53f10e
Merge #9500
9500: internal: Only inline closure, literal and local arguments when used once r=Veykril a=Veykril

See https://github.com/rust-analyzer/rust-analyzer/pull/9474#discussion_r663881507 for reasoning.

This still inlines single use closures and literals as naming these is usually not as useful. Prime examples being the Option/Result consuming functions like `map_or` etc.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-06 16:20:54 +00:00
Lukas Wirth
e71ae68b2d Only inline closure, literal and local arguments when used once 2021-07-05 16:43:16 +02:00
Lukas Wirth
46c42166d6 Yeet replace_unwrap_with_match in favor of inline_call 2021-07-05 15:47:55 +02:00
Lukas Wirth
dafbe6940e Wrap inlined closures in parens when inlined in an expression in inline_call 2021-07-05 15:42:11 +02:00
Lukas Wirth
2579dc6d82 Update inline_call assist doc example 2021-07-05 14:24:25 +02:00
bors[bot]
2bc4f9e371
Merge #9474
9474: fix: Inline parameters in `inline_call` if possible r=Veykril a=Veykril

Fixes #9491

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-05 11:50:18 +00:00
Lukas Wirth
ea02d27a1e Fixup emitted whitespace in most cases 2021-07-05 13:44:42 +02:00
Aleksey Kladov
86720f2953 minor: drop dummy authors field 2021-07-05 14:19:41 +03:00
Lukas Wirth
e41b5348b8 replace_qualified_name_with_use insert qualified import paths 2021-07-03 23:42:59 +02:00
bors[bot]
e73328f22a
Merge #9477
9477: fix: Don't show an import per namespace in auto_import r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/9113
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-03 20:13:14 +00:00
Lukas Wirth
05ec824ab7 Don't show an import per namespace in auto_import 2021-07-03 22:11:01 +02:00
Lukas Wirth
6181154d50 Add some more inline_call tests 2021-07-03 21:42:59 +02:00
bors[bot]
336194c09b
Merge #9476
9476: internal: overhaul codegen r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-07-03 19:26:04 +00:00
Aleksey Kladov
58d2ece88a internal: overhaul code generation
* Keep codegen adjacent to the relevant crates.
* Remove codgen deps from xtask, speeding-up from-source installation.

This regresses the release process a bit, as it now needs to run the
tests (and, by extension, compile the code).
2021-07-03 22:11:03 +03:00
Lukas Wirth
d308f17a21 Inline parameters in inline_call if possible 2021-07-03 20:05:54 +02:00
bors[bot]
888bb6c452
Merge #9468
9468: feat: Make `inline_function` work on methods r=Veykril a=Veykril

Now called `inline_call`.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-03 16:13:06 +00:00
Lukas Wirth
14e18bfa38 Merge the inline function/method assists into inline_call 2021-07-03 18:07:03 +02:00
Lukas Wirth
9c923068fb Don't hide meta lines 2021-07-03 12:16:07 +02:00
Lukas Wirth
688398febc feat: Implement inline_method assist 2021-07-03 01:33:34 +02:00
Lukas Wirth
fbdcb49d48 Simplify 2021-07-03 01:31:41 +02:00
Lukas Wirth
26dd0c4e5b wrap_return_type_in_result works on the HIR 2021-07-02 23:19:32 +02:00
Lukas Wirth
eb3f90b301 Don't check sad pattern equality by text 2021-07-02 21:10:44 +02:00
Lukas Wirth
251f0c6090 replace_match_with_if_let works on more binary matches 2021-07-02 21:05:10 +02:00
Lukas Wirth
f1819525f5 Simplify 2021-07-02 19:50:37 +02:00
bors[bot]
d18cfd4467
Merge #9458
9458: minor: Remove make::match_arm_with_guard r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-01 23:47:38 +00:00
Lukas Wirth
071ac48b6c Remove make::match_arm_with_guard 2021-07-02 01:44:54 +02:00
bors[bot]
cd3d633850
Merge #9455
9455: feat: Handle not let if expressions in replace_if_let_with_match r=Veykril a=Veykril

Transforms bare `if cond {}` into `_ if cond` guard patterns in the match as long as at least one `if let` is in the if chain, otherwise the assist wont be applicable.

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-01 23:00:50 +00:00
Lukas Wirth
8967856d78 Handle not let if expressions in replace_if_let_with_match 2021-07-02 00:58:56 +02:00
bors[bot]
51d85e1060
Merge #9454
9454: feat: Empower `replace_if_let_with_match` r=Veykril a=Veykril

Now instead of only working on `if let ... {} else {}` if expressions it now works on all of them where the condition expression is the same text-wise.

This includes if let expressions without an else block, in which case a simple `_ => ()` will be generated in the resulting match but also in more complex cases where multiple `if let` expressions are chained.

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-01 22:24:17 +00:00
Lukas Wirth
20be999304 Empower replace_if_let_with_match 2021-07-02 00:21:21 +02:00
bors[bot]
564fa0146e
Merge #9450
9450: internal: Add ModuleOrItem guess to import granularity guessing r=Veykril a=Veykril

I think this should be the last fix needed for this(🤞)
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-01 19:33:53 +00:00
Lukas Wirth
3d2490ca97 Simplify 2021-07-01 21:10:45 +02:00
Lukas Wirth
04f1104179 Don't classify NameRef paths inside attribute TokenTrees 2021-06-30 21:51:28 +02:00
Lukas Wirth
3ce5c66ca1 Deduplicate ast expression walking logic 2021-06-27 01:11:57 +02:00
Daiki Ihara
873aa904f2 Fix var name 2021-06-21 22:47:39 +09:00
Daiki Ihara
7a04f72220 Fix pointed out 2021-06-21 18:42:25 +09:00
Daiki Ihara
cd1ef8de18 Fix extract_function with await 2021-06-21 18:31:53 +09:00
Lukas Wirth
2113c46797 Cleanup insert_use tests 2021-06-19 22:33:29 +02:00
Lukas Wirth
344cb5e76a Don't insert imports outside of cfg attributed items 2021-06-18 23:56:43 +02:00
bors[bot]
d9666ce509
Merge #9334
9334: feat: Allow to disable import insertion on single path glob imports r=Veykril a=Veykril

On by default as I feel like this is something the majority would prefer.

Closes #8490

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-06-18 21:23:22 +00:00
Lukas Wirth
2ee090faaf Allow to disable import insertion on single path glob imports 2021-06-18 23:11:56 +02:00
Aleksey Kladov
3762cc7465 minor: use minicore 2021-06-18 23:59:47 +03:00
Aleksey Kladov
a9623f3165 minor: use minicore 2021-06-18 23:38:19 +03:00
Aleksey Kladov
181184a350 minor: use minicore 2021-06-18 23:28:37 +03:00
Aleksey Kladov
2e4df27132 minor: use minicore 2021-06-18 22:25:35 +03:00
Aleksey Kladov
15c4b3fa7f internal: add Copy to minicore 2021-06-18 22:10:52 +03:00
bors[bot]
0657812bc2
Merge #9321
9321: Inline generics in const and function trait completions r=Veykril a=RDambrosio016

This PR does a couple of things:
- moves path_transform from ide_assists to ide_db to be shared by both assists and completions
- when completing a const or a function for a trait, it will "inline" any generics in those associated items instead 
of leaving the generic's name. For example:
```rust
trait Foo<T> {
    const BAR: T;
    fn foo() -> T;
}
struct Bar;

impl Foo<u32> for Bar {
    // autocompletes to this
    fn foo() -> u32;

    // and not this (old)
    fn foo() -> T;

    // also works for associated consts and where clauses
    const BAR: u32 = /* */
}
```

Currently this does not work for const generics, because `PathTransform` does not seem to account for them. If this should work on const generics too, `PathTransform` will need to be changed. However, it is uncommon to implement a trait only for a single const value, so this isnt a huge concern.

Co-authored-by: rdambrosio <rdambrosio016@gmail.com>
2021-06-18 16:47:58 +00:00
Laurențiu Nicola
e3ce88f6f2 Minor clippy perf fixes 2021-06-18 14:40:51 +03:00
rdambrosio
8e08b86304 Feat: inline generics in const and func trait completions 2021-06-17 19:54:28 -04:00
Aleksey Kladov
89c2dff58a minor: simplify 2021-06-18 00:36:25 +03:00
Aleksey Kladov
ebb591a570 internal: add derive and ord support to minicore 2021-06-18 00:30:22 +03:00
Aleksey Kladov
ca99aaa053 internal: add From to minicore 2021-06-17 21:04:12 +03:00
Aleksey Kladov
08c220ab2c internal: add default to minicore 2021-06-17 20:49:49 +03:00
Lukas Wirth
b6cb6d5abe simplify 2021-06-17 17:58:26 +02:00
Lukas Wirth
95c8c65139 Nest all the or-patterns! 2021-06-17 17:37:14 +02:00
bors[bot]
3b58d8f785
Merge #9308
9308: fix: Create modules in correct directory for nested modules in move_module assist r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-06-17 10:10:25 +00:00
Lukas Wirth
cd5f4121e3 Create modules in correct directory for nested modules in move_module assist 2021-06-17 12:09:28 +02:00
Aleksey Kladov
a43bba760e internal: switch some tests to minicore 2021-06-17 11:41:36 +03:00
Aleksey Kladov
c42cdff3d2 internal: minimize minicore
We want to keep minicore small, so let's split out iterator adapters and
sources into a separate `iterators` region, and use them only when
needed.
2021-06-17 11:28:44 +03:00
Aleksey Kladov
35772256f8 internal: cleanup tests 2021-06-16 23:27:46 +03:00
Aleksey Kladov
7ba5482a04 internal: switch some tests to minicore 2021-06-16 22:26:46 +03:00
Aleksey Kladov
7e0d441687 internal: switch some tests to minicore 2021-06-16 22:24:11 +03:00
Aleksey Kladov
4584868a7a internal: don't #[ignore] tests
See the style.md for motivation
2021-06-15 16:37:58 +03:00
Aleksey Kladov
1e100e8b3e internal: cleanup tests
* ensure standard, non-indented style (should add this check to
  `fixture` some day)
* removed a couple of ignores
2021-06-15 12:48:05 +03:00
Aleksey Kladov
3f4ad44082 internal: document that we don't #[ignore] tests 2021-06-15 11:46:47 +03:00
Aleksey Kladov
a91071b57b internal: cut deps between assists and diagnostics 2021-06-14 17:45:17 +03:00
Aleksey Kladov
2e8dab631b internal: prepare to move assist definitions 2021-06-14 17:45:17 +03:00
Lukas Wirth
7cf273a18e Don't keep a trailing self token in import paths after unmerge_use 2021-06-14 13:56:33 +02:00
bors[bot]
adbee621a7
Merge #9242
9242: Clippy r=matklad a=Maan2003

Best viewed commit wise

Co-authored-by: Maan2003 <manmeetmann2003@gmail.com>
2021-06-13 07:18:49 +00:00
bors[bot]
f107b0f1e2
Merge #9240
9240: Fixed a small typo in comment r=matklad a=fee1-dead



Co-authored-by: fee1-dead <ent3rm4n@gmail.com>
2021-06-13 06:58:37 +00:00
Maan2003
5ac6804bb3
cargo fmt 2021-06-13 09:48:15 +05:30
Maan2003
aabd41cafc
clippy::redundant_field_names 2021-06-13 09:40:22 +05:30
Maan2003
c50b4579ec
clippy::useless_return 2021-06-13 09:35:29 +05:30
Maan2003
75370312fb
clippy::redundant_closure 2021-06-13 09:29:36 +05:30
Maan2003
c9b4ac5be4
clippy::redudant_borrow 2021-06-13 09:24:16 +05:30
Aleksey Kladov
0463d76a1f internal: cross-crate cov-marks 2021-06-12 23:40:52 +03:00
bors[bot]
80b3b74018
Merge #9215
9215: change visibility for use and macro items r=jonas-schievink a=Maan2003



Co-authored-by: Maan2003 <manmeetmann2003@gmail.com>
2021-06-11 14:10:22 +00:00
fee1-dead
7ad8cd8232
Fixed a small typo in comment 2021-06-11 22:01:34 +08:00
Maan2003
4c1a02288c
change visibility for use and macro items 2021-06-11 19:10:56 +05:30
Maan2003
7f71000c12
Don't suggest Remove unused param in trait impls 2021-06-11 12:24:56 +05:30
Joshua Warner
9b74dd0c04 fmt 2021-06-05 17:09:56 -07:00
Joshua Warner
18f796a728 Refactor to be just one assist 2021-06-05 15:29:29 -07:00
Joshua Warner
ca9ffba047 Add assist for converting a tuple enum variant to a named variant 2021-06-04 21:48:32 -07:00
Lukas Wirth
1bd04d9064 Don't inline mutable locals in 'inline_local_variable' 2021-06-04 20:43:48 +02:00
Matthias Krüger
9452dfaac7 NFC: remove redundant clones (clippy::perf) 2021-06-03 15:32:46 +02:00