@@ -3,7 +3,7 @@ use ide_db::famous_defs::FamousDefs;
33use stdx:: format_to;
44use syntax:: {
55 AstNode ,
6- ast:: { self , HasArgList , HasLoopBody , edit_in_place :: Indent , syntax_factory:: SyntaxFactory } ,
6+ ast:: { self , HasArgList , HasLoopBody , edit :: AstNodeEdit , syntax_factory:: SyntaxFactory } ,
77} ;
88
99use crate :: { AssistContext , AssistId , Assists } ;
@@ -62,10 +62,10 @@ pub(crate) fn convert_iter_for_each_to_for(
6262 stmt. as_ref ( ) . map_or_else ( || method. indent_level ( ) , ast:: ExprStmt :: indent_level) ;
6363
6464 let block = match body {
65- ast:: Expr :: BlockExpr ( block) => block. clone_for_update ( ) ,
66- _ => make. block_expr ( Vec :: new ( ) , Some ( body) ) ,
67- } ;
68- block . reindent_to ( indent) ;
65+ ast:: Expr :: BlockExpr ( block) => block. reset_indent ( ) ,
66+ _ => make. block_expr ( Vec :: new ( ) , Some ( body. reset_indent ( ) . indent ( 1 . into ( ) ) ) ) ,
67+ }
68+ . indent ( indent) ;
6969
7070 let expr_for_loop = make. expr_for_loop ( param, receiver, block) ;
7171
@@ -285,15 +285,23 @@ fn main() {
285285 r#"
286286//- minicore: iterators
287287fn main() {
288- let it = core::iter::repeat(92);
289- it.$0for_each(|(x, y)| println!("x: {}, y: {}", x, y));
288+ {
289+ let it = core::iter::repeat(92);
290+ it.$0for_each(|param| match param {
291+ (x, y) => println!("x: {}, y: {}", x, y),
292+ });
293+ }
290294}
291295"# ,
292296 r#"
293297fn main() {
294- let it = core::iter::repeat(92);
295- for (x, y) in it {
296- println!("x: {}, y: {}", x, y)
298+ {
299+ let it = core::iter::repeat(92);
300+ for param in it {
301+ match param {
302+ (x, y) => println!("x: {}, y: {}", x, y),
303+ }
304+ }
297305 }
298306}
299307"# ,
0 commit comments