mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 00:03:43 +00:00
fix parens when inlining closure local variables
This commit is contained in:
parent
d6fef2c7e3
commit
60f7473c99
@ -96,8 +96,7 @@ pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext<'_>)
|
||||
);
|
||||
let parent = matches!(
|
||||
usage_parent,
|
||||
ast::Expr::CallExpr(_)
|
||||
| ast::Expr::TupleExpr(_)
|
||||
ast::Expr::TupleExpr(_)
|
||||
| ast::Expr::ArrayExpr(_)
|
||||
| ast::Expr::ParenExpr(_)
|
||||
| ast::Expr::ForExpr(_)
|
||||
@ -949,6 +948,24 @@ fn f() {
|
||||
let S$0 = 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 New Issue
Block a user