rust-analyzer/crates
Omer Tuchfeld 9200d27a26 Stop inserting semicolon when extracting match arm
# Overview

Extracting a match arm value that has type unit into a function, when a
comma already follows the match arm value, results in an invalid (syntax
error) semicolon added between the newly generated function's generated
call and the comma.

# Example

Running this extraction

```rust
fn main() {
    match () {
        _ => $0()$0,
    };
}
```

would lead to

```rust
fn main() {
    match () {
        _ => fun_name();,
    };
}

fn fun_name() {
}
```

# Issue / Fix details

This happens because when there is no comma, rust-analyzer would simply
add the comma and wouldn't even try to evaluate whether it needs to add
a semicolon. But when the comma is there, it proceeds to evaluate
whether it needs to add a semicolon and it looks like the evaluation
logic erroneously ignores the possibility that we're in a match arm.
IIUC it never makes sense to add a semicolon when we're extracting from
a match arm value, so I've adjusted the logic to always decide against
adding a semicolon when we're in a match arm
2023-07-08 15:41:24 +02:00
..
base-db Replace x with it 2023-07-06 17:33:17 +03:30
cfg Replace x with it 2023-07-06 17:33:17 +03:30
flycheck Bump more deps 2023-06-22 11:44:10 +02:00
hir Use debug impl in rendering const eval result 2023-07-08 01:07:38 +03:30
hir-def Implement recursion in mir interpreter without recursion 2023-07-07 15:07:29 +03:30
hir-expand Replace x with it 2023-07-06 17:33:17 +03:30
hir-ty Use debug impl in rendering const eval result 2023-07-08 01:07:38 +03:30
ide Replace x with it 2023-07-06 17:33:17 +03:30
ide-assists Stop inserting semicolon when extracting match arm 2023-07-08 15:41:24 +02:00
ide-completion Replace x with it 2023-07-06 17:33:17 +03:30
ide-db Auto merge of #15181 - lowr:patch/import-map-purge-unused, r=Veykril 2023-07-03 14:37:55 +00:00
ide-diagnostics Auto merge of #15223 - lowr:patch/no-unresolved-field-for-missing, r=HKalbasi 2023-07-06 11:54:08 +00:00
ide-ssr Use anonymous lifetime where possible 2023-06-29 23:27:28 +09:00
intern Bump more deps 2023-06-22 11:44:10 +02:00
limit Move Expander and LowerCtx into separate modules 2023-04-17 20:44:06 +02:00
load-cargo Split out project loading capabilities from rust-analyzer crate 2023-07-03 17:40:31 +02:00
mbe Use anonymous lifetime where possible 2023-06-29 23:27:28 +09:00
parser Recover from missing associated items and generic const defaults 2023-07-05 00:24:11 +09:00
paths internal: use consistent style for error handling 2023-06-19 13:01:47 +01:00
proc-macro-api Bump more deps 2023-06-22 11:44:10 +02:00
proc-macro-srv Bump more deps 2023-06-22 11:44:10 +02:00
proc-macro-srv-cli Remove proc-macro server command from the rust-analyzer binary 2023-04-26 08:19:28 +02:00
proc-macro-test ⬆️ rust-analyzer 2023-02-13 13:55:14 +02:00
profile Use anonymous lifetime where possible 2023-06-29 23:27:28 +09:00
project-model Change in-tree libs to workspace dependencies 2023-06-20 13:53:39 +10:00
rust-analyzer Replace x with it 2023-07-06 17:33:17 +03:30
sourcegen Format let-else 2023-07-03 20:34:09 +02:00
stdx Bump more deps 2023-06-22 11:44:10 +02:00
syntax Auto merge of #15152 - alibektas:14987, r=Veykril,lowr 2023-07-05 16:56:37 +00:00
test-utils Revert "Support #[rustc_coinductive]" 2023-07-03 05:06:55 +09:00
text-edit Make text-size a workspace dep 2023-05-06 00:49:23 -07:00
toolchain ⬆️ rust-analyzer 2023-03-13 10:42:24 +02:00
tt Use anonymous lifetime where possible 2023-06-29 23:27:28 +09:00
vfs Upgrade to indexmap v2 2023-06-24 17:35:20 -07:00
vfs-notify Downgrade some deps to get rif of windows-sys duplication 2023-06-22 11:44:10 +02:00