mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-16 09:48:10 +00:00
9200d27a26
# 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 |
||
---|---|---|
.. | ||
base-db | ||
cfg | ||
flycheck | ||
hir | ||
hir-def | ||
hir-expand | ||
hir-ty | ||
ide | ||
ide-assists | ||
ide-completion | ||
ide-db | ||
ide-diagnostics | ||
ide-ssr | ||
intern | ||
limit | ||
load-cargo | ||
mbe | ||
parser | ||
paths | ||
proc-macro-api | ||
proc-macro-srv | ||
proc-macro-srv-cli | ||
proc-macro-test | ||
profile | ||
project-model | ||
rust-analyzer | ||
sourcegen | ||
stdx | ||
syntax | ||
test-utils | ||
text-edit | ||
toolchain | ||
tt | ||
vfs | ||
vfs-notify |