fix parens when inlining closure local variables

This commit is contained in:
Ryan Mehri 2023-09-21 21:31:15 -07:00
parent d6fef2c7e3
commit 60f7473c99

View file

@ -96,8 +96,7 @@ pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext<'_>)
); );
let parent = matches!( let parent = matches!(
usage_parent, usage_parent,
ast::Expr::CallExpr(_) ast::Expr::TupleExpr(_)
| ast::Expr::TupleExpr(_)
| ast::Expr::ArrayExpr(_) | ast::Expr::ArrayExpr(_)
| ast::Expr::ParenExpr(_) | ast::Expr::ParenExpr(_)
| ast::Expr::ForExpr(_) | ast::Expr::ForExpr(_)
@ -949,6 +948,24 @@ fn f() {
let S$0 = S; let S$0 = S;
S; S;
} }
"#,
);
}
#[test]
fn test_inline_closure() {
check_assist(
inline_local_variable,
r#"
fn main() {
let $0f = || 2;
let _ = f();
}
"#,
r#"
fn main() {
let _ = (|| 2)();
}
"#, "#,
); );
} }