Closed
Description
rust-analyzer version: rust-analyzer 1.73.0 (cc66ad4 2023-10-03)
rustc version: rustc 1.73.0 (cc66ad468 2023-10-03)
relevant settings: n/a
Input
fn f() {
match$0(true) {}
}
Expected output
fn f() {
match true {}
}
Output
fn f() {
matchtrue {}
}
Notes
Looks like the code assist that rust-analyzer generates from the compiler warning ("remove these parentheses") does handle this case correctly, so it's maybe it's possible to take notes from the compiler implementation
Test Patch
diff --git a/crates/ide-assists/src/handlers/remove_parentheses.rs b/crates/ide-assists/src/handlers/remove_parentheses.rs
index ffc32f804..f93e8ecbb 100644
--- a/crates/ide-assists/src/handlers/remove_parentheses.rs
+++ b/crates/ide-assists/src/handlers/remove_parentheses.rs
@@ -218,4 +218,13 @@ mod tests {
check_assist_not_applicable(remove_parentheses, r#"fn f() { $0(return 2) + 2 }"#);
}
+
+ #[test]
+ fn remove_parens_space() {
+ check_assist(
+ remove_parentheses,
+ r#"fn f() { match$0(true) {} }"#,
+ r#"fn f() { match$0 true {} }"#,
+ );
+ }
}