From 09d3b7d7a2ae23a0463fadee9ae8cb6a0fa2c4bf Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 5 Aug 2020 19:29:24 +0200 Subject: align names in make --- crates/ra_assists/src/handlers/early_return.rs | 6 +++--- crates/ra_assists/src/handlers/expand_glob_import.rs | 2 +- crates/ra_assists/src/handlers/fill_match_arms.rs | 5 ++--- crates/ra_assists/src/handlers/generate_function.rs | 2 +- crates/ra_assists/src/handlers/replace_if_let_with_match.rs | 2 +- crates/ra_assists/src/handlers/replace_let_with_if_let.rs | 4 ++-- crates/ra_assists/src/handlers/replace_unwrap_with_match.rs | 4 ++-- 7 files changed, 12 insertions(+), 13 deletions(-) (limited to 'crates/ra_assists/src/handlers') diff --git a/crates/ra_assists/src/handlers/early_return.rs b/crates/ra_assists/src/handlers/early_return.rs index 69852b611..6816a2709 100644 --- a/crates/ra_assists/src/handlers/early_return.rs +++ b/crates/ra_assists/src/handlers/early_return.rs @@ -123,7 +123,7 @@ pub(crate) fn convert_to_guarded_return(acc: &mut Assists, ctx: &AssistContext) let happy_arm = { let pat = make::tuple_struct_pat( path, - once(make::bind_pat(make::name("it")).into()), + once(make::ident_pat(make::name("it")).into()), ); let expr = { let name_ref = make::name_ref("it"); @@ -136,7 +136,7 @@ pub(crate) fn convert_to_guarded_return(acc: &mut Assists, ctx: &AssistContext) let sad_arm = make::match_arm( // FIXME: would be cool to use `None` or `Err(_)` if appropriate - once(make::placeholder_pat().into()), + once(make::wildcard_pat().into()), early_expression, ); @@ -144,7 +144,7 @@ pub(crate) fn convert_to_guarded_return(acc: &mut Assists, ctx: &AssistContext) }; let let_stmt = make::let_stmt( - make::bind_pat(make::name(&bound_ident.syntax().to_string())).into(), + make::ident_pat(make::name(&bound_ident.syntax().to_string())).into(), Some(match_expr), ); let let_stmt = let_stmt.indent(if_indent_level); diff --git a/crates/ra_assists/src/handlers/expand_glob_import.rs b/crates/ra_assists/src/handlers/expand_glob_import.rs index 69f6b3674..eb216a81a 100644 --- a/crates/ra_assists/src/handlers/expand_glob_import.rs +++ b/crates/ra_assists/src/handlers/expand_glob_import.rs @@ -173,7 +173,7 @@ fn replace_ast( replace_node(replacement); }, ast::Use(use_item) => { - builder.replace_ast(use_item, ast::make::use_item(replacement.left_or_else(|ut| ast::make::use_tree(path, Some(ut), None, false)))); + builder.replace_ast(use_item, ast::make::use_(replacement.left_or_else(|ut| ast::make::use_tree(path, Some(ut), None, false)))); }, _ => {}, } diff --git a/crates/ra_assists/src/handlers/fill_match_arms.rs b/crates/ra_assists/src/handlers/fill_match_arms.rs index b2e14f9d7..6698d1a27 100644 --- a/crates/ra_assists/src/handlers/fill_match_arms.rs +++ b/crates/ra_assists/src/handlers/fill_match_arms.rs @@ -197,12 +197,11 @@ fn build_pat(db: &RootDatabase, module: hir::Module, var: hir::EnumVariant) -> O // FIXME: use HIR for this; it doesn't currently expose struct vs. tuple vs. unit variants though let pat: ast::Pat = match var.source(db).value.kind() { ast::StructKind::Tuple(field_list) => { - let pats = - iter::repeat(make::placeholder_pat().into()).take(field_list.fields().count()); + let pats = iter::repeat(make::wildcard_pat().into()).take(field_list.fields().count()); make::tuple_struct_pat(path, pats).into() } ast::StructKind::Record(field_list) => { - let pats = field_list.fields().map(|f| make::bind_pat(f.name().unwrap()).into()); + let pats = field_list.fields().map(|f| make::ident_pat(f.name().unwrap()).into()); make::record_pat(path, pats).into() } ast::StructKind::Unit => make::path_pat(path), diff --git a/crates/ra_assists/src/handlers/generate_function.rs b/crates/ra_assists/src/handlers/generate_function.rs index 56510861d..acc97e648 100644 --- a/crates/ra_assists/src/handlers/generate_function.rs +++ b/crates/ra_assists/src/handlers/generate_function.rs @@ -142,7 +142,7 @@ impl FunctionBuilder { let fn_body = make::block_expr(vec![], Some(placeholder_expr)); let visibility = if self.needs_pub { Some(make::visibility_pub_crate()) } else { None }; let mut fn_def = - make::fn_def(visibility, self.fn_name, self.type_params, self.params, fn_body); + make::fn_(visibility, self.fn_name, self.type_params, self.params, fn_body); let leading_ws; let trailing_ws; diff --git a/crates/ra_assists/src/handlers/replace_if_let_with_match.rs b/crates/ra_assists/src/handlers/replace_if_let_with_match.rs index b7e30a7f2..ecafb74a1 100644 --- a/crates/ra_assists/src/handlers/replace_if_let_with_match.rs +++ b/crates/ra_assists/src/handlers/replace_if_let_with_match.rs @@ -65,7 +65,7 @@ pub(crate) fn replace_if_let_with_match(acc: &mut Assists, ctx: &AssistContext) .type_of_pat(&pat) .and_then(|ty| TryEnum::from_ty(&ctx.sema, &ty)) .map(|it| it.sad_pattern()) - .unwrap_or_else(|| make::placeholder_pat().into()); + .unwrap_or_else(|| make::wildcard_pat().into()); let else_expr = unwrap_trivial_block(else_block); make::match_arm(vec![pattern], else_expr) }; diff --git a/crates/ra_assists/src/handlers/replace_let_with_if_let.rs b/crates/ra_assists/src/handlers/replace_let_with_if_let.rs index 64ad15a23..e4d436dec 100644 --- a/crates/ra_assists/src/handlers/replace_let_with_if_let.rs +++ b/crates/ra_assists/src/handlers/replace_let_with_if_let.rs @@ -50,10 +50,10 @@ pub(crate) fn replace_let_with_if_let(acc: &mut Assists, ctx: &AssistContext) -> target, |edit| { let with_placeholder: ast::Pat = match happy_variant { - None => make::placeholder_pat().into(), + None => make::wildcard_pat().into(), Some(var_name) => make::tuple_struct_pat( make::path_unqualified(make::path_segment(make::name_ref(var_name))), - once(make::placeholder_pat().into()), + once(make::wildcard_pat().into()), ) .into(), }; diff --git a/crates/ra_assists/src/handlers/replace_unwrap_with_match.rs b/crates/ra_assists/src/handlers/replace_unwrap_with_match.rs index e5a4bb23c..d69f2c1b0 100644 --- a/crates/ra_assists/src/handlers/replace_unwrap_with_match.rs +++ b/crates/ra_assists/src/handlers/replace_unwrap_with_match.rs @@ -52,7 +52,7 @@ pub(crate) fn replace_unwrap_with_match(acc: &mut Assists, ctx: &AssistContext) target, |builder| { let ok_path = make::path_unqualified(make::path_segment(make::name_ref(happy_variant))); - let it = make::bind_pat(make::name("a")).into(); + let it = make::ident_pat(make::name("a")).into(); let ok_tuple = make::tuple_struct_pat(ok_path, iter::once(it)).into(); let bind_path = make::path_unqualified(make::path_segment(make::name_ref("a"))); @@ -60,7 +60,7 @@ pub(crate) fn replace_unwrap_with_match(acc: &mut Assists, ctx: &AssistContext) let unreachable_call = make::expr_unreachable(); let err_arm = - make::match_arm(iter::once(make::placeholder_pat().into()), unreachable_call); + make::match_arm(iter::once(make::wildcard_pat().into()), unreachable_call); let match_arm_list = make::match_arm_list(vec![ok_arm, err_arm]); let match_expr = make::expr_match(caller.clone(), match_arm_list) -- cgit v1.2.3