From ce4ae41605f8a049afee8b013121496aa9950e9f Mon Sep 17 00:00:00 2001 From: roife Date: Tue, 27 Feb 2024 12:21:05 +0800 Subject: [PATCH] internal: simplify the process of inserting spaces after mut --- .../ide-assists/src/handlers/inline_call.rs | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/crates/ide-assists/src/handlers/inline_call.rs b/crates/ide-assists/src/handlers/inline_call.rs index 11b22b6520..7531dd5c03 100644 --- a/crates/ide-assists/src/handlers/inline_call.rs +++ b/crates/ide-assists/src/handlers/inline_call.rs @@ -415,24 +415,16 @@ fn inline( let expr: &ast::Expr = expr; let mut insert_let_stmt = || { - let param_ty = match param_ty { - None => None, - Some(param_ty) => { - if sema.hir_file_for(param_ty.syntax()).is_macro() { - if let Some(param_ty) = - ast::Type::cast(insert_ws_into(param_ty.syntax().clone())) - { - Some(param_ty) - } else { - Some(param_ty.clone_for_update()) - } - } else { - Some(param_ty.clone_for_update()) - } + let param_ty = param_ty.clone().map(|param_ty| { + if sema.hir_file_for(param_ty.syntax()).is_macro() { + ast::Type::cast(insert_ws_into(param_ty.syntax().clone())) + .unwrap_or_else(|| param_ty) + } else { + param_ty } - }; - let ty: Option = - sema.type_of_expr(expr).filter(TypeInfo::has_adjustment).and(param_ty); + }); + + let ty = sema.type_of_expr(expr).filter(TypeInfo::has_adjustment).and(param_ty); let is_self = param .name(sema.db)