File tree Expand file tree Collapse file tree 1 file changed +30
-1
lines changed
crates/ide-assists/src/handlers Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -481,8 +481,12 @@ fn inline(
481481 } ;
482482 body. reindent_to ( original_indentation) ;
483483
484+ let no_stmts = body. statements ( ) . next ( ) . is_none ( ) ;
484485 match body. tail_expr ( ) {
485- Some ( expr) if !is_async_fn && body. statements ( ) . next ( ) . is_none ( ) => expr,
486+ Some ( expr) if matches ! ( expr, ast:: Expr :: ClosureExpr ( _) ) && no_stmts => {
487+ make:: expr_paren ( expr) . clone_for_update ( )
488+ }
489+ Some ( expr) if !is_async_fn && no_stmts => expr,
486490 _ => match node
487491 . syntax ( )
488492 . parent ( )
@@ -1471,6 +1475,31 @@ fn main() {
14711475 }
14721476 });
14731477}
1478+ "# ,
1479+ ) ;
1480+ }
1481+
1482+ #[ test]
1483+ fn inline_call_closure_body ( ) {
1484+ check_assist (
1485+ inline_call,
1486+ r#"
1487+ fn f() -> impl Fn() -> i32 {
1488+ || 2
1489+ }
1490+
1491+ fn main() {
1492+ let _ = $0f()();
1493+ }
1494+ "# ,
1495+ r#"
1496+ fn f() -> impl Fn() -> i32 {
1497+ || 2
1498+ }
1499+
1500+ fn main() {
1501+ let _ = (|| 2)();
1502+ }
14741503"# ,
14751504 ) ;
14761505 }
You can’t perform that action at this time.
0 commit comments