Skip to content

Commit 60f7473

Browse files
committed
fix parens when inlining closure local variables
1 parent d6fef2c commit 60f7473

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

crates/ide-assists/src/handlers/inline_local_variable.rs

+19-2
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext<'_>)
9696
);
9797
let parent = matches!(
9898
usage_parent,
99-
ast::Expr::CallExpr(_)
100-
| ast::Expr::TupleExpr(_)
99+
ast::Expr::TupleExpr(_)
101100
| ast::Expr::ArrayExpr(_)
102101
| ast::Expr::ParenExpr(_)
103102
| ast::Expr::ForExpr(_)
@@ -949,6 +948,24 @@ fn f() {
949948
let S$0 = S;
950949
S;
951950
}
951+
"#,
952+
);
953+
}
954+
955+
#[test]
956+
fn test_inline_closure() {
957+
check_assist(
958+
inline_local_variable,
959+
r#"
960+
fn main() {
961+
let $0f = || 2;
962+
let _ = f();
963+
}
964+
"#,
965+
r#"
966+
fn main() {
967+
let _ = (|| 2)();
968+
}
952969
"#,
953970
);
954971
}

0 commit comments

Comments
 (0)