Skip to content

Commit 1914d0a

Browse files
bors[bot]matklad
andauthored
Merge #5633
5633: Rename DotDotPat -> RestPat r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 parents 215b9b9 + 22d295c commit 1914d0a

File tree

14 files changed

+55
-55
lines changed

14 files changed

+55
-55
lines changed

crates/ra_hir_def/src/body/lower.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ impl ExprCollector<'_> {
826826
Pat::Missing
827827
}
828828
}
829-
ast::Pat::DotDotPat(_) => {
829+
ast::Pat::RestPat(_) => {
830830
// `DotDotPat` requires special handling and should not be mapped
831831
// to a Pat. Here we are using `Pat::Missing` as a fallback for
832832
// when `DotDotPat` is mapped to `Pat`, which can easily happen
@@ -853,10 +853,10 @@ impl ExprCollector<'_> {
853853
fn collect_tuple_pat(&mut self, args: AstChildren<ast::Pat>) -> (Vec<PatId>, Option<usize>) {
854854
// Find the location of the `..`, if there is one. Note that we do not
855855
// consider the possiblity of there being multiple `..` here.
856-
let ellipsis = args.clone().position(|p| matches!(p, ast::Pat::DotDotPat(_)));
856+
let ellipsis = args.clone().position(|p| matches!(p, ast::Pat::RestPat(_)));
857857
// We want to skip the `..` pattern here, since we account for it above.
858858
let args = args
859-
.filter(|p| !matches!(p, ast::Pat::DotDotPat(_)))
859+
.filter(|p| !matches!(p, ast::Pat::RestPat(_)))
860860
.map(|p| self.collect_pat(p))
861861
.collect();
862862

crates/ra_ide/src/syntax_highlighting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ fn highlight_element(
577577
_ if element.parent().and_then(ast::RangePat::cast).is_some() => {
578578
HighlightTag::Operator.into()
579579
}
580-
_ if element.parent().and_then(ast::DotDotPat::cast).is_some() => {
580+
_ if element.parent().and_then(ast::RestPat::cast).is_some() => {
581581
HighlightTag::Operator.into()
582582
}
583583
_ if element.parent().and_then(ast::Attr::cast).is_some() => {

crates/ra_parser/src/grammar/patterns.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ fn record_field_pat_list(p: &mut Parser) {
192192
p.bump(T!['{']);
193193
while !p.at(EOF) && !p.at(T!['}']) {
194194
match p.current() {
195-
// A trailing `..` is *not* treated as a DOT_DOT_PAT.
195+
// A trailing `..` is *not* treated as a REST_PAT.
196196
T![.] if p.at(T![..]) => p.bump(T![..]),
197197
T!['{'] => error_block(p, "expected ident"),
198198

@@ -267,7 +267,7 @@ fn dot_dot_pat(p: &mut Parser) -> CompletedMarker {
267267
assert!(p.at(T![..]));
268268
let m = p.start();
269269
p.bump(T![..]);
270-
m.complete(p, DOT_DOT_PAT)
270+
m.complete(p, REST_PAT)
271271
}
272272

273273
// test ref_pat

crates/ra_parser/src/syntax_kind/generated.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ pub enum SyntaxKind {
158158
BOX_PAT,
159159
IDENT_PAT,
160160
WILDCARD_PAT,
161-
DOT_DOT_PAT,
161+
REST_PAT,
162162
PATH_PAT,
163163
RECORD_PAT,
164164
RECORD_PAT_FIELD_LIST,

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,10 +1130,10 @@ impl BoxPat {
11301130
pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
11311131
}
11321132
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1133-
pub struct DotDotPat {
1133+
pub struct RestPat {
11341134
pub(crate) syntax: SyntaxNode,
11351135
}
1136-
impl DotDotPat {
1136+
impl RestPat {
11371137
pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) }
11381138
}
11391139
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -1336,7 +1336,7 @@ pub enum Stmt {
13361336
pub enum Pat {
13371337
IdentPat(IdentPat),
13381338
BoxPat(BoxPat),
1339-
DotDotPat(DotDotPat),
1339+
RestPat(RestPat),
13401340
LiteralPat(LiteralPat),
13411341
MacroPat(MacroPat),
13421342
OrPat(OrPat),
@@ -2577,8 +2577,8 @@ impl AstNode for BoxPat {
25772577
}
25782578
fn syntax(&self) -> &SyntaxNode { &self.syntax }
25792579
}
2580-
impl AstNode for DotDotPat {
2581-
fn can_cast(kind: SyntaxKind) -> bool { kind == DOT_DOT_PAT }
2580+
impl AstNode for RestPat {
2581+
fn can_cast(kind: SyntaxKind) -> bool { kind == REST_PAT }
25822582
fn cast(syntax: SyntaxNode) -> Option<Self> {
25832583
if Self::can_cast(syntax.kind()) {
25842584
Some(Self { syntax })
@@ -3141,8 +3141,8 @@ impl From<IdentPat> for Pat {
31413141
impl From<BoxPat> for Pat {
31423142
fn from(node: BoxPat) -> Pat { Pat::BoxPat(node) }
31433143
}
3144-
impl From<DotDotPat> for Pat {
3145-
fn from(node: DotDotPat) -> Pat { Pat::DotDotPat(node) }
3144+
impl From<RestPat> for Pat {
3145+
fn from(node: RestPat) -> Pat { Pat::RestPat(node) }
31463146
}
31473147
impl From<LiteralPat> for Pat {
31483148
fn from(node: LiteralPat) -> Pat { Pat::LiteralPat(node) }
@@ -3183,7 +3183,7 @@ impl From<TupleStructPat> for Pat {
31833183
impl AstNode for Pat {
31843184
fn can_cast(kind: SyntaxKind) -> bool {
31853185
match kind {
3186-
IDENT_PAT | BOX_PAT | DOT_DOT_PAT | LITERAL_PAT | MACRO_PAT | OR_PAT | PAREN_PAT
3186+
IDENT_PAT | BOX_PAT | REST_PAT | LITERAL_PAT | MACRO_PAT | OR_PAT | PAREN_PAT
31873187
| PATH_PAT | WILDCARD_PAT | RANGE_PAT | RECORD_PAT | REF_PAT | SLICE_PAT
31883188
| TUPLE_PAT | TUPLE_STRUCT_PAT => true,
31893189
_ => false,
@@ -3193,7 +3193,7 @@ impl AstNode for Pat {
31933193
let res = match syntax.kind() {
31943194
IDENT_PAT => Pat::IdentPat(IdentPat { syntax }),
31953195
BOX_PAT => Pat::BoxPat(BoxPat { syntax }),
3196-
DOT_DOT_PAT => Pat::DotDotPat(DotDotPat { syntax }),
3196+
REST_PAT => Pat::RestPat(RestPat { syntax }),
31973197
LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }),
31983198
MACRO_PAT => Pat::MacroPat(MacroPat { syntax }),
31993199
OR_PAT => Pat::OrPat(OrPat { syntax }),
@@ -3214,7 +3214,7 @@ impl AstNode for Pat {
32143214
match self {
32153215
Pat::IdentPat(it) => &it.syntax,
32163216
Pat::BoxPat(it) => &it.syntax,
3217-
Pat::DotDotPat(it) => &it.syntax,
3217+
Pat::RestPat(it) => &it.syntax,
32183218
Pat::LiteralPat(it) => &it.syntax,
32193219
Pat::MacroPat(it) => &it.syntax,
32203220
Pat::OrPat(it) => &it.syntax,
@@ -3990,7 +3990,7 @@ impl std::fmt::Display for BoxPat {
39903990
std::fmt::Display::fmt(self.syntax(), f)
39913991
}
39923992
}
3993-
impl std::fmt::Display for DotDotPat {
3993+
impl std::fmt::Display for RestPat {
39943994
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
39953995
std::fmt::Display::fmt(self.syntax(), f)
39963996
}

crates/ra_syntax/src/ast/node_ext.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,15 +293,15 @@ impl ast::SlicePat {
293293
let mut args = self.args().peekable();
294294
let prefix = args
295295
.peeking_take_while(|p| match p {
296-
ast::Pat::DotDotPat(_) => false,
296+
ast::Pat::RestPat(_) => false,
297297
ast::Pat::IdentPat(bp) => match bp.pat() {
298-
Some(ast::Pat::DotDotPat(_)) => false,
298+
Some(ast::Pat::RestPat(_)) => false,
299299
_ => true,
300300
},
301301
ast::Pat::RefPat(rp) => match rp.pat() {
302-
Some(ast::Pat::DotDotPat(_)) => false,
302+
Some(ast::Pat::RestPat(_)) => false,
303303
Some(ast::Pat::IdentPat(bp)) => match bp.pat() {
304-
Some(ast::Pat::DotDotPat(_)) => false,
304+
Some(ast::Pat::RestPat(_)) => false,
305305
_ => true,
306306
},
307307
_ => true,

crates/ra_syntax/test_data/parser/inline/ok/0008_path_part.rast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ SOURCE_FILE@0..103
8181
NAME_REF@87..90
8282
IDENT@87..90 "Bar"
8383
L_PAREN@90..91 "("
84-
DOT_DOT_PAT@91..93
84+
REST_PAT@91..93
8585
DOT2@91..93 ".."
8686
R_PAREN@93..94 ")"
8787
WHITESPACE@94..95 " "

crates/ra_syntax/test_data/parser/inline/ok/0024_slice_pat.rast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ SOURCE_FILE@0..39
2626
IDENT@24..25 "b"
2727
COMMA@25..26 ","
2828
WHITESPACE@26..27 " "
29-
DOT_DOT_PAT@27..29
29+
REST_PAT@27..29
3030
DOT2@27..29 ".."
3131
R_BRACK@29..30 "]"
3232
WHITESPACE@30..31 " "

crates/ra_syntax/test_data/parser/inline/ok/0026_tuple_pat_fields.rast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ SOURCE_FILE@0..97
8383
UNDERSCORE@78..79 "_"
8484
COMMA@79..80 ","
8585
WHITESPACE@80..81 " "
86-
DOT_DOT_PAT@81..83
86+
REST_PAT@81..83
8787
DOT2@81..83 ".."
8888
WHITESPACE@83..84 " "
8989
COMMA@84..85 ","

crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.rast

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ SOURCE_FILE@0..94
2626
IDENT@24..25 "b"
2727
COMMA@25..26 ","
2828
WHITESPACE@26..27 " "
29-
DOT_DOT_PAT@27..29
29+
REST_PAT@27..29
3030
DOT2@27..29 ".."
3131
R_PAREN@29..30 ")"
3232
WHITESPACE@30..31 " "
@@ -60,7 +60,7 @@ SOURCE_FILE@0..94
6060
WHITESPACE@63..64 " "
6161
TUPLE_PAT@64..68
6262
L_PAREN@64..65 "("
63-
DOT_DOT_PAT@65..67
63+
REST_PAT@65..67
6464
DOT2@65..67 ".."
6565
R_PAREN@67..68 ")"
6666
WHITESPACE@68..69 " "

0 commit comments

Comments
 (0)