Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-assists/src/handlers/inline_call.rs')
-rw-r--r--crates/ide-assists/src/handlers/inline_call.rs33
1 files changed, 12 insertions, 21 deletions
diff --git a/crates/ide-assists/src/handlers/inline_call.rs b/crates/ide-assists/src/handlers/inline_call.rs
index 2b9ed86e41..50ec4347dc 100644
--- a/crates/ide-assists/src/handlers/inline_call.rs
+++ b/crates/ide-assists/src/handlers/inline_call.rs
@@ -418,24 +418,15 @@ 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(param_ty)
+ } else {
+ param_ty
}
- };
- let ty: Option<syntax::ast::Type> =
- 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)
@@ -1359,8 +1350,8 @@ macro_rules! define_foo {
define_foo!();
fn bar() -> u32 {
{
- let x = 0;
- x
+ let x = 0;
+ x
}
}
"#,
@@ -1673,7 +1664,7 @@ fn main() {
let a: A = A{};
let b = {
let a = a;
- a as A
+ a as A
};
}
"#,
@@ -1792,7 +1783,7 @@ fn _hash2(self_: &u64, state: &mut u64) {
{
let inner_self_: &u64 = &self_;
let state: &mut u64 = state;
- _write_u64(state, *inner_self_)
+ _write_u64(state, *inner_self_)
};
}
"#,