Commit Graph

13210 Commits

Author SHA1 Message Date
crauzer
1161fa45af fix tests 2021-10-06 20:45:18 +02:00
crauzer
765d7f20f9 add sourcegen 2021-10-06 20:23:22 +02:00
crauzer
05e58afde2 Add replace_try_expr_with_match assist 2021-10-06 20:11:00 +02:00
bors[bot]
4cfe237a56
Merge #10459
10459: feat: Add generate constant assist r=Veykril a=longfangsong

Close #10330.
![demo(1)](https://user-images.githubusercontent.com/13777628/135885262-c80de86f-5555-4f84-9508-822243f8a876.gif)



Co-authored-by: longfangsong <longfangsong@icloud.com>
Co-authored-by: 龙方淞 <longfangsong@icloud.com>
2021-10-06 09:38:58 +00:00
longfangsong
3fde682bcf cleanup 2021-10-06 10:14:12 +08:00
龙方淞
7228dbadca
Update crates/ide_assists/src/handlers/generate_constant.rs
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-06 10:06:51 +08:00
龙方淞
fab238adf6
Update crates/ide_assists/src/handlers/generate_constant.rs
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-06 10:06:46 +08:00
bors[bot]
5ff992465e
Merge #10447
10447: Add enum variant references CodeLens. r=Veykril a=ericsampson



Co-authored-by: Eric Sampson <esampson@eaze.com>
2021-10-05 22:03:23 +00:00
Eric Sampson
6d05b07f7d Refactor according to PR comments to remove allocations. 2021-10-05 15:42:45 -05:00
bors[bot]
c409cf0e26
Merge #10458
10458: feat: Implement custom user snippets r=Veykril a=Veykril

![Y24dX7fOWX](https://user-images.githubusercontent.com/3757771/136059454-ceccfc2c-2c90-46da-8ad1-bac9c2e83ec1.gif)

Allows us to address the following issues:
    - `.arc / .rc / .pin, similar to .box?` https://github.com/rust-analyzer/rust-analyzer/issues/7033
    - `Add unsafe snippet` https://github.com/rust-analyzer/rust-analyzer/issues/10392, would allow users to have this without the diagnostic)
    - `.ok() postfix snippet is annoying` https://github.com/rust-analyzer/rust-analyzer/issues/9636, allows us to get rid of the `ok` postfix and similar ones
    - `Postfix vec completion` https://github.com/rust-analyzer/rust-analyzer/issues/7773

cc https://github.com/rust-analyzer/rust-analyzer/issues/772

Zulipd discussion: https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Custom.20Postfix.20snippets

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-05 16:41:11 +00:00
Lukas Wirth
041cfbe0f4 Render the expansion of snippets as their docs 2021-10-05 18:11:22 +02:00
Lukas Wirth
77cbf4adbc Bring the implementation closer to VSCode snippet definitions 2021-10-05 17:18:40 +02: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
Eric Sampson
160a7b097a initialize vector to required size. 2021-10-04 16:14:01 -05:00
Lukas Wirth
2b17da60db Resolve macros in snippet require items 2021-10-04 22:53:02 +02:00
Lukas Wirth
ca1fdd75f1 Regen docs 2021-10-04 22:13:12 +02:00
Lukas Wirth
1f7e14e78b Fix multiple imports acting on files on separately 2021-10-04 22:05:30 +02:00
Lukas Wirth
454ecd167c Make multiple import edits work for completions 2021-10-04 21:44:33 +02:00
Lukas Wirth
046c85ef0c Add custom non-postfix snippets 2021-10-04 19:22:41 +02:00
Jonas Schievink
0cd24c14c5 Only add proc_macro to prelude in proc-macro crates 2021-10-04 18:22:39 +02:00
bors[bot]
5bdae82947
Merge #10456
10456: fix: Avoid cycle when lowering predicates for associated item lookup r=flodiebold a=jonas-schievink

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

(the salsa bug persists, but this lets us avoid it by fixing the underlying bug)

This reimplements the rustc logic in b27661eb33/compiler/rustc_typeck/src/collect.rs (L556): When resolving an associated type `T::Item`, we've previously lowered all predicates that could affect `T`, but we actually have to look only at those predicates whose traits define an associated type of the right name.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-10-04 15:58:06 +00:00
longfangsong
4d1a4dc0d6 Add generate_constant assist 2021-10-04 23:53:32 +08:00
Lukas Wirth
88f213eadd Initial implementation of custom postfix snippets 2021-10-04 17:49:21 +02:00
Jonas Schievink
3aa37d7f80 Avoid cycle when lowering predicates for associated item lookup 2021-10-04 17:39:55 +02:00
Laurențiu Nicola
a683c08729 Remove support for old-style sysroot 2021-10-04 18:36:56 +03:00
bors[bot]
9724ca7af1
Merge #10451
10451: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-04 13:18:21 +00:00
Lukas Wirth
7faa35cbbd Simplify 2021-10-04 15:16:13 +02:00
zhoufan
a248f39cb4 make Some(1..) parsed 2021-10-04 17:33:48 +08:00
Eric Sampson
5df6259996 tweak variable names. 2021-10-04 02:42:13 -05:00
Eric Sampson
a0bb31587e Add enum variant references CodeLens. 2021-10-04 02:18:31 -05:00
bors[bot]
10eaa5a0af
Merge #10441
10441: feat: Hide type inlay hints for constructors r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-03 13:35:47 +00:00
Lukas Wirth
a31bc668f5 Hide generic constructors if appropriate 2021-10-03 15:35:26 +02:00
Aramis Razzaghipour
eff195852d
Fix miscellaneous Clippy lints 2021-10-03 23:53:30 +11:00
Lukas Wirth
992b4648d9 feat: Hide type inlay hints for constructors 2021-10-03 14:53:18 +02:00
Aramis Razzaghipour
55c0b86cde
Add semicolons for consistency
`clippy::semicolon_if_nothing_returned`
2021-10-03 23:39:43 +11:00
bors[bot]
e28aa1928b
Merge #10439
10439: fix: fix insert_use incorrectly merging glob imports r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-03 12:19:02 +00:00
Lukas Wirth
5b0c91d118 fix: fix insert_use incorrectly merging glob imports 2021-10-03 14:06:44 +02:00
Lukas Wirth
e684235329 Move module private logic down 2021-10-03 13:52:40 +02: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
bors[bot]
0618a6f184
Merge #10436
10436: fix: await insertion with try_expr during extract_function r=Veykril a=feniljain

Fixing  #10333

Co-authored-by: vi_mi <fenil.jain2018@vitstudent.ac.in>
2021-10-03 10:07:58 +00:00
vi_mi
61643513b6 fix: await insertion with try_expr during extract_function 2021-10-03 09:41:21 +00:00
bors[bot]
13ec077b91
Merge #10437
10437: fix: Fix extract_variable not allowing to extract macro calls r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-03 09:10:33 +00:00
Lukas Wirth
a359a1f2e3 Fix extract_variable not allowing to extract macro calls 2021-10-03 11:09:49 +02:00
Aleksey Kladov
4e352275d1 minor: simplify 2021-10-02 20:38:39 +03:00
Aleksey Kladov
613609cc5e minor: cleanup 2021-10-02 20:38:39 +03:00
Aleksey Kladov
77bf761203 internal: move code to where it's used and reduce visibility 2021-10-02 20:38:39 +03:00
bors[bot]
e504f8ae8d
Merge #10430
10430: fix: Fix rename trying to edit the same range multiple times for certain macro inputs r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-02 16:51:55 +00:00