Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-assists/src/handlers/remove_parentheses.rs')
-rw-r--r--crates/ide-assists/src/handlers/remove_parentheses.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/crates/ide-assists/src/handlers/remove_parentheses.rs b/crates/ide-assists/src/handlers/remove_parentheses.rs
index 799d36be93..f74fc26112 100644
--- a/crates/ide-assists/src/handlers/remove_parentheses.rs
+++ b/crates/ide-assists/src/handlers/remove_parentheses.rs
@@ -239,4 +239,33 @@ mod tests {
check_assist_not_applicable(remove_parentheses, r#"fn f() { $0(return 2) + 2 }"#);
}
+
+ #[test]
+ fn remove_parens_indirect_calls() {
+ check_assist(
+ remove_parentheses,
+ r#"fn f(call: fn(usize), arg: usize) { $0(call)(arg); }"#,
+ r#"fn f(call: fn(usize), arg: usize) { call(arg); }"#,
+ );
+ check_assist(
+ remove_parentheses,
+ r#"fn f<F>(call: F, arg: usize) where F: Fn(usize) { $0(call)(arg); }"#,
+ r#"fn f<F>(call: F, arg: usize) where F: Fn(usize) { call(arg); }"#,
+ );
+
+ // Parentheses are necessary when calling a function-like pointer that is a member of a struct or union.
+ check_assist_not_applicable(
+ remove_parentheses,
+ r#"
+struct Foo<T> {
+ t: T,
+}
+
+impl Foo<fn(usize)> {
+ fn foo(&self, arg: usize) {
+ $0(self.t)(arg);
+ }
+}"#,
+ );
+ }
}