mirror of
				https://github.com/rust-lang/rust-analyzer.git
				synced 2025-10-31 12:04:43 +00:00 
			
		
		
		
	internal: make::expr_if should return ast::IfExpr
				
					
				
			This commit is contained in:
		
							parent
							
								
									913d197a04
								
							
						
					
					
						commit
						c549be9ab6
					
				
					 7 changed files with 8 additions and 7 deletions
				
			
		|  | @ -195,6 +195,7 @@ fn bool_expr_to_enum_expr(expr: ast::Expr) -> ast::Expr { | |||
|             make::tail_only_block_expr(true_expr), | ||||
|             Some(ast::ElseBranch::Block(make::tail_only_block_expr(false_expr))), | ||||
|         ) | ||||
|         .into() | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -60,7 +60,7 @@ pub(crate) fn convert_while_to_loop(acc: &mut Assists, ctx: &AssistContext<'_>) | |||
|             .indent(while_indent_level); | ||||
|             let block_expr = if is_pattern_cond(while_cond.clone()) { | ||||
|                 let if_expr = make::expr_if(while_cond, while_body, Some(break_block.into())); | ||||
|                 let stmts = iter::once(make::expr_stmt(if_expr).into()); | ||||
|                 let stmts = iter::once(make::expr_stmt(if_expr.into()).into()); | ||||
|                 make::block_expr(stmts, None) | ||||
|             } else { | ||||
|                 let if_cond = invert_boolean_expression(while_cond); | ||||
|  |  | |||
|  | @ -1533,7 +1533,7 @@ impl FlowHandler { | |||
|                     .into(), | ||||
|                     call_expr, | ||||
|                 ); | ||||
|                 make::expr_if(condition.into(), block, None) | ||||
|                 make::expr_if(condition.into(), block, None).into() | ||||
|             } | ||||
|             FlowHandler::IfOption { action } => { | ||||
|                 let path = make::ext::ident_path("Some"); | ||||
|  | @ -1544,7 +1544,7 @@ impl FlowHandler { | |||
|                 let action_expr = action.make_result_handler(Some(value)); | ||||
|                 let action_stmt = make::expr_stmt(action_expr); | ||||
|                 let then = make::block_expr(iter::once(action_stmt.into()), None); | ||||
|                 make::expr_if(cond.into(), then, None) | ||||
|                 make::expr_if(cond.into(), then, None).into() | ||||
|             } | ||||
|             FlowHandler::MatchOption { none } => { | ||||
|                 let some_name = "value"; | ||||
|  |  | |||
|  | @ -61,7 +61,7 @@ pub(crate) fn move_guard_to_arm_body(acc: &mut Assists, ctx: &AssistContext<'_>) | |||
|             }; | ||||
| 
 | ||||
|             edit.delete(guard.syntax().text_range()); | ||||
|             edit.replace_ast(arm_expr, if_expr); | ||||
|             edit.replace_ast(arm_expr, if_expr.into()); | ||||
|         }, | ||||
|     ) | ||||
| } | ||||
|  |  | |||
|  | @ -285,7 +285,7 @@ pub(crate) fn replace_match_with_if_let(acc: &mut Assists, ctx: &AssistContext<' | |||
|             ) | ||||
|             .indent(IndentLevel::from_node(match_expr.syntax())); | ||||
| 
 | ||||
|             edit.replace_ast::<ast::Expr>(match_expr.into(), if_let_expr); | ||||
|             edit.replace_ast::<ast::Expr>(match_expr.into(), if_let_expr.into()); | ||||
|         }, | ||||
|     ) | ||||
| } | ||||
|  |  | |||
|  | @ -63,7 +63,7 @@ pub(crate) fn replace_let_with_if_let(acc: &mut Assists, ctx: &AssistContext<'_> | |||
|             let block = | ||||
|                 make::ext::empty_block_expr().indent(IndentLevel::from_node(let_stmt.syntax())); | ||||
|             let if_ = make::expr_if(make::expr_let(pat, init).into(), block, None); | ||||
|             let stmt = make::expr_stmt(if_); | ||||
|             let stmt = make::expr_stmt(if_.into()); | ||||
| 
 | ||||
|             edit.replace_ast(ast::Stmt::from(let_stmt), ast::Stmt::from(stmt)); | ||||
|         }, | ||||
|  |  | |||
|  | @ -607,7 +607,7 @@ pub fn expr_if( | |||
|     condition: ast::Expr, | ||||
|     then_branch: ast::BlockExpr, | ||||
|     else_branch: Option<ast::ElseBranch>, | ||||
| ) -> ast::Expr { | ||||
| ) -> ast::IfExpr { | ||||
|     let else_branch = match else_branch { | ||||
|         Some(ast::ElseBranch::Block(block)) => format!("else {block}"), | ||||
|         Some(ast::ElseBranch::IfExpr(if_expr)) => format!("else {if_expr}"), | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Giga Bowser
						Giga Bowser