Skip to content

Commit b9c6aa9

Browse files
committed
Unify naming of tuple fields
1 parent 675e86b commit b9c6aa9

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

crates/ra_assists/src/handlers/early_return.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ pub(crate) fn convert_to_guarded_return(acc: &mut Assists, ctx: &AssistContext)
5151
// Check if there is an IfLet that we can handle.
5252
let if_let_pat = match cond.pat() {
5353
None => None, // No IfLet, supported.
54-
Some(ast::Pat::TupleStructPat(pat)) if pat.args().count() == 1 => {
54+
Some(ast::Pat::TupleStructPat(pat)) if pat.fields().count() == 1 => {
5555
let path = pat.path()?;
5656
match path.qualifier() {
5757
None => {
58-
let bound_ident = pat.args().next().unwrap();
58+
let bound_ident = pat.fields().next().unwrap();
5959
Some((path, bound_ident))
6060
}
6161
Some(_) => return None,

crates/ra_hir_def/src/body/lower.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ impl ExprCollector<'_> {
496496
self.alloc_expr(Expr::BinaryOp { lhs, rhs, op }, syntax_ptr)
497497
}
498498
ast::Expr::TupleExpr(e) => {
499-
let exprs = e.exprs().map(|expr| self.collect_expr(expr)).collect();
499+
let exprs = e.fields().map(|expr| self.collect_expr(expr)).collect();
500500
self.alloc_expr(Expr::Tuple { exprs }, syntax_ptr)
501501
}
502502
ast::Expr::BoxExpr(e) => {
@@ -762,7 +762,7 @@ impl ExprCollector<'_> {
762762
}
763763
ast::Pat::TupleStructPat(p) => {
764764
let path = p.path().and_then(|path| self.expander.parse_path(path));
765-
let (args, ellipsis) = self.collect_tuple_pat(p.args());
765+
let (args, ellipsis) = self.collect_tuple_pat(p.fields());
766766
Pat::TupleStruct { path, args, ellipsis }
767767
}
768768
ast::Pat::RefPat(p) => {
@@ -780,7 +780,7 @@ impl ExprCollector<'_> {
780780
}
781781
ast::Pat::ParenPat(p) => return self.collect_pat_opt(p.pat()),
782782
ast::Pat::TuplePat(p) => {
783-
let (args, ellipsis) = self.collect_tuple_pat(p.args());
783+
let (args, ellipsis) = self.collect_tuple_pat(p.fields());
784784
Pat::Tuple { args, ellipsis }
785785
}
786786
ast::Pat::WildcardPat(_) => Pat::Wild,

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ pub struct TupleExpr {
893893
impl ast::AttrsOwner for TupleExpr {}
894894
impl TupleExpr {
895895
pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
896-
pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
896+
pub fn fields(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
897897
pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
898898
}
899899
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -1210,7 +1210,7 @@ pub struct SlicePat {
12101210
}
12111211
impl SlicePat {
12121212
pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
1213-
pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1213+
pub fn pats(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
12141214
pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
12151215
}
12161216
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -1219,7 +1219,7 @@ pub struct TuplePat {
12191219
}
12201220
impl TuplePat {
12211221
pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
1222-
pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1222+
pub fn fields(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
12231223
pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
12241224
}
12251225
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -1229,7 +1229,7 @@ pub struct TupleStructPat {
12291229
impl TupleStructPat {
12301230
pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
12311231
pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
1232-
pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1232+
pub fn fields(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
12331233
pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
12341234
}
12351235
#[derive(Debug, Clone, PartialEq, Eq, Hash)]

crates/ra_syntax/src/ast/node_ext.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ pub struct SlicePatComponents {
290290

291291
impl ast::SlicePat {
292292
pub fn components(&self) -> SlicePatComponents {
293-
let mut args = self.args().peekable();
293+
let mut args = self.pats().peekable();
294294
let prefix = args
295295
.peeking_take_while(|p| match p {
296296
ast::Pat::RestPat(_) => false,

xtask/src/codegen/rust.ungram

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ IndexExpr =
359359
Attr* base:Expr '[' index:Expr ']'
360360

361361
TupleExpr =
362-
Attr* '(' Attr* (Expr (',' Expr)* ','?)? ')'
362+
Attr* '(' Attr* fields:(Expr (',' Expr)* ','?)? ')'
363363

364364
RecordExpr =
365365
Path RecordExprFieldList
@@ -560,16 +560,16 @@ RecordPatField =
560560
Attr* (NameRef ':')? Pat
561561

562562
TupleStructPat =
563-
Path '(' args:(Pat (',' Pat)* ','?)? ')'
563+
Path '(' fields:(Pat (',' Pat)* ','?)? ')'
564564

565565
TuplePat =
566-
'(' args:(Pat (',' Pat)* ','?)? ')'
566+
'(' fields:(Pat (',' Pat)* ','?)? ')'
567567

568568
ParenPat =
569569
'(' Pat ')'
570570

571571
SlicePat =
572-
'[' args:(Pat (',' Pat)* ','?)? ']'
572+
'[' (Pat (',' Pat)* ','?)? ']'
573573

574574
PathPat =
575575
Path

0 commit comments

Comments
 (0)