mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-15 22:54:00 +00:00
fix parens when inlining closure local variables
This commit is contained in:
parent
d6fef2c7e3
commit
60f7473c99
1 changed files with 19 additions and 2 deletions
|
@ -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)();
|
||||||
|
}
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue