Skip to content

Commit 6791eb9

Browse files
committed
Rename PalceholderPat -> WildcardPat
1 parent d7f75db commit 6791eb9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+132
-135
lines changed

crates/ra_assists/src/handlers/fill_match_arms.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub(crate) fn fill_match_arms(acc: &mut Assists, ctx: &AssistContext) -> Option<
4343

4444
let mut arms: Vec<MatchArm> = match_arm_list.arms().collect();
4545
if arms.len() == 1 {
46-
if let Some(Pat::PlaceholderPat(..)) = arms[0].pat() {
46+
if let Some(Pat::WildcardPat(..)) = arms[0].pat() {
4747
arms.clear();
4848
}
4949
}
@@ -116,17 +116,15 @@ pub(crate) fn fill_match_arms(acc: &mut Assists, ctx: &AssistContext) -> Option<
116116
match (first_new_arm, ctx.config.snippet_cap) {
117117
(Some(first_new_arm), Some(cap)) => {
118118
let extend_lifetime;
119-
let cursor = match first_new_arm
120-
.syntax()
121-
.descendants()
122-
.find_map(ast::PlaceholderPat::cast)
123-
{
124-
Some(it) => {
125-
extend_lifetime = it.syntax().clone();
126-
Cursor::Replace(&extend_lifetime)
127-
}
128-
None => Cursor::Before(first_new_arm.syntax()),
129-
};
119+
let cursor =
120+
match first_new_arm.syntax().descendants().find_map(ast::WildcardPat::cast)
121+
{
122+
Some(it) => {
123+
extend_lifetime = it.syntax().clone();
124+
Cursor::Replace(&extend_lifetime)
125+
}
126+
None => Cursor::Before(first_new_arm.syntax()),
127+
};
130128
let snippet = render_snippet(cap, new_arm_list.syntax(), cursor);
131129
builder.replace_snippet(cap, old_range, snippet);
132130
}

crates/ra_assists/src/handlers/merge_match_arms.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ pub(crate) fn merge_match_arms(acc: &mut Assists, ctx: &AssistContext) -> Option
8686
}
8787

8888
fn contains_placeholder(a: &ast::MatchArm) -> bool {
89-
matches!(a.pat(), Some(ast::Pat::PlaceholderPat(..)))
89+
matches!(a.pat(), Some(ast::Pat::WildcardPat(..)))
9090
}
9191

9292
#[cfg(test)]

crates/ra_assists/src/handlers/replace_let_with_if_let.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ pub(crate) fn replace_let_with_if_let(acc: &mut Assists, ctx: &AssistContext) ->
6262
let if_ = make::expr_if(make::condition(init, Some(with_placeholder)), block);
6363
let stmt = make::expr_stmt(if_);
6464

65-
let placeholder =
66-
stmt.syntax().descendants().find_map(ast::PlaceholderPat::cast).unwrap();
65+
let placeholder = stmt.syntax().descendants().find_map(ast::WildcardPat::cast).unwrap();
6766
let stmt = stmt.replace_descendant(placeholder.into(), original_pat);
6867

6968
edit.replace_ast(ast::Stmt::from(let_stmt), ast::Stmt::from(stmt));

crates/ra_hir_def/src/body/lower.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ impl ExprCollector<'_> {
783783
let (args, ellipsis) = self.collect_tuple_pat(p.args());
784784
Pat::Tuple { args, ellipsis }
785785
}
786-
ast::Pat::PlaceholderPat(_) => Pat::Wild,
786+
ast::Pat::WildcardPat(_) => Pat::Wild,
787787
ast::Pat::RecordPat(p) => {
788788
let path = p.path().and_then(|path| self.expander.parse_path(path));
789789
let args: Vec<_> = p

crates/ra_parser/src/grammar/patterns.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ fn placeholder_pat(p: &mut Parser) -> CompletedMarker {
234234
assert!(p.at(T![_]));
235235
let m = p.start();
236236
p.bump(T![_]);
237-
m.complete(p, PLACEHOLDER_PAT)
237+
m.complete(p, WILDCARD_PAT)
238238
}
239239

240240
// test dot_dot_pat

crates/ra_parser/src/syntax_kind/generated.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ pub enum SyntaxKind {
157157
REF_PAT,
158158
BOX_PAT,
159159
BIND_PAT,
160-
PLACEHOLDER_PAT,
160+
WILDCARD_PAT,
161161
DOT_DOT_PAT,
162162
PATH_PAT,
163163
RECORD_PAT,

crates/ra_syntax/src/ast/edit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ impl ast::MatchArmList {
390390
#[must_use]
391391
pub fn remove_placeholder(&self) -> ast::MatchArmList {
392392
let placeholder =
393-
self.arms().find(|arm| matches!(arm.pat(), Some(ast::Pat::PlaceholderPat(_))));
393+
self.arms().find(|arm| matches!(arm.pat(), Some(ast::Pat::WildcardPat(_))));
394394
if let Some(placeholder) = placeholder {
395395
self.remove_arm(&placeholder)
396396
} else {

crates/ra_syntax/src/ast/generated/nodes.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,10 +1175,10 @@ impl PathPat {
11751175
pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
11761176
}
11771177
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1178-
pub struct PlaceholderPat {
1178+
pub struct WildcardPat {
11791179
pub(crate) syntax: SyntaxNode,
11801180
}
1181-
impl PlaceholderPat {
1181+
impl WildcardPat {
11821182
pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) }
11831183
}
11841184
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -1343,7 +1343,7 @@ pub enum Pat {
13431343
OrPat(OrPat),
13441344
ParenPat(ParenPat),
13451345
PathPat(PathPat),
1346-
PlaceholderPat(PlaceholderPat),
1346+
WildcardPat(WildcardPat),
13471347
RangePat(RangePat),
13481348
RecordPat(RecordPat),
13491349
RefPat(RefPat),
@@ -2644,8 +2644,8 @@ impl AstNode for PathPat {
26442644
}
26452645
fn syntax(&self) -> &SyntaxNode { &self.syntax }
26462646
}
2647-
impl AstNode for PlaceholderPat {
2648-
fn can_cast(kind: SyntaxKind) -> bool { kind == PLACEHOLDER_PAT }
2647+
impl AstNode for WildcardPat {
2648+
fn can_cast(kind: SyntaxKind) -> bool { kind == WILDCARD_PAT }
26492649
fn cast(syntax: SyntaxNode) -> Option<Self> {
26502650
if Self::can_cast(syntax.kind()) {
26512651
Some(Self { syntax })
@@ -3160,8 +3160,8 @@ impl From<ParenPat> for Pat {
31603160
impl From<PathPat> for Pat {
31613161
fn from(node: PathPat) -> Pat { Pat::PathPat(node) }
31623162
}
3163-
impl From<PlaceholderPat> for Pat {
3164-
fn from(node: PlaceholderPat) -> Pat { Pat::PlaceholderPat(node) }
3163+
impl From<WildcardPat> for Pat {
3164+
fn from(node: WildcardPat) -> Pat { Pat::WildcardPat(node) }
31653165
}
31663166
impl From<RangePat> for Pat {
31673167
fn from(node: RangePat) -> Pat { Pat::RangePat(node) }
@@ -3185,7 +3185,7 @@ impl AstNode for Pat {
31853185
fn can_cast(kind: SyntaxKind) -> bool {
31863186
match kind {
31873187
BIND_PAT | BOX_PAT | DOT_DOT_PAT | LITERAL_PAT | MACRO_PAT | OR_PAT | PAREN_PAT
3188-
| PATH_PAT | PLACEHOLDER_PAT | RANGE_PAT | RECORD_PAT | REF_PAT | SLICE_PAT
3188+
| PATH_PAT | WILDCARD_PAT | RANGE_PAT | RECORD_PAT | REF_PAT | SLICE_PAT
31893189
| TUPLE_PAT | TUPLE_STRUCT_PAT => true,
31903190
_ => false,
31913191
}
@@ -3200,7 +3200,7 @@ impl AstNode for Pat {
32003200
OR_PAT => Pat::OrPat(OrPat { syntax }),
32013201
PAREN_PAT => Pat::ParenPat(ParenPat { syntax }),
32023202
PATH_PAT => Pat::PathPat(PathPat { syntax }),
3203-
PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }),
3203+
WILDCARD_PAT => Pat::WildcardPat(WildcardPat { syntax }),
32043204
RANGE_PAT => Pat::RangePat(RangePat { syntax }),
32053205
RECORD_PAT => Pat::RecordPat(RecordPat { syntax }),
32063206
REF_PAT => Pat::RefPat(RefPat { syntax }),
@@ -3221,7 +3221,7 @@ impl AstNode for Pat {
32213221
Pat::OrPat(it) => &it.syntax,
32223222
Pat::ParenPat(it) => &it.syntax,
32233223
Pat::PathPat(it) => &it.syntax,
3224-
Pat::PlaceholderPat(it) => &it.syntax,
3224+
Pat::WildcardPat(it) => &it.syntax,
32253225
Pat::RangePat(it) => &it.syntax,
32263226
Pat::RecordPat(it) => &it.syntax,
32273227
Pat::RefPat(it) => &it.syntax,
@@ -4021,7 +4021,7 @@ impl std::fmt::Display for PathPat {
40214021
std::fmt::Display::fmt(self.syntax(), f)
40224022
}
40234023
}
4024-
impl std::fmt::Display for PlaceholderPat {
4024+
impl std::fmt::Display for WildcardPat {
40254025
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
40264026
std::fmt::Display::fmt(self.syntax(), f)
40274027
}

crates/ra_syntax/src/ast/make.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,10 @@ pub fn bind_pat(name: ast::Name) -> ast::BindPat {
156156
}
157157
}
158158

159-
pub fn placeholder_pat() -> ast::PlaceholderPat {
159+
pub fn placeholder_pat() -> ast::WildcardPat {
160160
return from_text("_");
161161

162-
fn from_text(text: &str) -> ast::PlaceholderPat {
162+
fn from_text(text: &str) -> ast::WildcardPat {
163163
ast_from_text(&format!("fn f({}: ())", text))
164164
}
165165
}

crates/ra_syntax/test_data/parser/err/0024_many_type_parens.rast

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ [email protected]
8080
8181
8282
83-
PLACEHOLDER_PAT@75..76
83+
WILDCARD_PAT@75..76
8484
8585
8686
@@ -147,7 +147,7 @@ [email protected]
147147
148148
149149
150-
PLACEHOLDER_PAT@132..133
150+
WILDCARD_PAT@132..133
151151
152152
153153
@@ -223,7 +223,7 @@ [email protected]
223223
224224
225225
226-
PLACEHOLDER_PAT@189..190
226+
WILDCARD_PAT@189..190
227227
228228
229229

0 commit comments

Comments
 (0)