-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
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 {} }"#,
+ );
+ }
}
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
Young-Flash commentedon Nov 8, 2023
@rustbot claim
Auto merge of #15857 - Young-Flash:fix, r=Veykril