From 6791eb9685375da94556bb910ea71f78b08be5ec Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 31 Jul 2020 20:07:21 +0200 Subject: Rename PalceholderPat -> WildcardPat --- crates/ra_assists/src/handlers/fill_match_arms.rs | 22 ++++++++++------------ crates/ra_assists/src/handlers/merge_match_arms.rs | 2 +- .../src/handlers/replace_let_with_if_let.rs | 3 +-- 3 files changed, 12 insertions(+), 15 deletions(-) (limited to 'crates/ra_assists/src/handlers') diff --git a/crates/ra_assists/src/handlers/fill_match_arms.rs b/crates/ra_assists/src/handlers/fill_match_arms.rs index 708e1bc6c..36658f104 100644 --- a/crates/ra_assists/src/handlers/fill_match_arms.rs +++ b/crates/ra_assists/src/handlers/fill_match_arms.rs @@ -43,7 +43,7 @@ pub(crate) fn fill_match_arms(acc: &mut Assists, ctx: &AssistContext) -> Option< let mut arms: Vec = match_arm_list.arms().collect(); if arms.len() == 1 { - if let Some(Pat::PlaceholderPat(..)) = arms[0].pat() { + if let Some(Pat::WildcardPat(..)) = arms[0].pat() { arms.clear(); } } @@ -116,17 +116,15 @@ pub(crate) fn fill_match_arms(acc: &mut Assists, ctx: &AssistContext) -> Option< match (first_new_arm, ctx.config.snippet_cap) { (Some(first_new_arm), Some(cap)) => { let extend_lifetime; - let cursor = match first_new_arm - .syntax() - .descendants() - .find_map(ast::PlaceholderPat::cast) - { - Some(it) => { - extend_lifetime = it.syntax().clone(); - Cursor::Replace(&extend_lifetime) - } - None => Cursor::Before(first_new_arm.syntax()), - }; + let cursor = + match first_new_arm.syntax().descendants().find_map(ast::WildcardPat::cast) + { + Some(it) => { + extend_lifetime = it.syntax().clone(); + Cursor::Replace(&extend_lifetime) + } + None => Cursor::Before(first_new_arm.syntax()), + }; let snippet = render_snippet(cap, new_arm_list.syntax(), cursor); builder.replace_snippet(cap, old_range, snippet); } diff --git a/crates/ra_assists/src/handlers/merge_match_arms.rs b/crates/ra_assists/src/handlers/merge_match_arms.rs index 186a1f618..563292282 100644 --- a/crates/ra_assists/src/handlers/merge_match_arms.rs +++ b/crates/ra_assists/src/handlers/merge_match_arms.rs @@ -86,7 +86,7 @@ pub(crate) fn merge_match_arms(acc: &mut Assists, ctx: &AssistContext) -> Option } fn contains_placeholder(a: &ast::MatchArm) -> bool { - matches!(a.pat(), Some(ast::Pat::PlaceholderPat(..))) + matches!(a.pat(), Some(ast::Pat::WildcardPat(..))) } #[cfg(test)] 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 a49292c97..64ad15a23 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 @@ -62,8 +62,7 @@ pub(crate) fn replace_let_with_if_let(acc: &mut Assists, ctx: &AssistContext) -> let if_ = make::expr_if(make::condition(init, Some(with_placeholder)), block); let stmt = make::expr_stmt(if_); - let placeholder = - stmt.syntax().descendants().find_map(ast::PlaceholderPat::cast).unwrap(); + let placeholder = stmt.syntax().descendants().find_map(ast::WildcardPat::cast).unwrap(); let stmt = stmt.replace_descendant(placeholder.into(), original_pat); edit.replace_ast(ast::Stmt::from(let_stmt), ast::Stmt::from(stmt)); -- cgit v1.2.3