5634: Finish rename r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2020-07-31 20:05:10 +00:00 committed by GitHub
commit 2346a28c63
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 37 additions and 17 deletions

View file

@ -51,11 +51,11 @@ pub(crate) fn convert_to_guarded_return(acc: &mut Assists, ctx: &AssistContext)
// Check if there is an IfLet that we can handle. // Check if there is an IfLet that we can handle.
let if_let_pat = match cond.pat() { let if_let_pat = match cond.pat() {
None => None, // No IfLet, supported. None => None, // No IfLet, supported.
Some(ast::Pat::TupleStructPat(pat)) if pat.args().count() == 1 => { Some(ast::Pat::TupleStructPat(pat)) if pat.fields().count() == 1 => {
let path = pat.path()?; let path = pat.path()?;
match path.qualifier() { match path.qualifier() {
None => { None => {
let bound_ident = pat.args().next().unwrap(); let bound_ident = pat.fields().next().unwrap();
Some((path, bound_ident)) Some((path, bound_ident))
} }
Some(_) => return None, Some(_) => return None,

View file

@ -496,7 +496,7 @@ fn collect_expr(&mut self, expr: ast::Expr) -> ExprId {
self.alloc_expr(Expr::BinaryOp { lhs, rhs, op }, syntax_ptr) self.alloc_expr(Expr::BinaryOp { lhs, rhs, op }, syntax_ptr)
} }
ast::Expr::TupleExpr(e) => { ast::Expr::TupleExpr(e) => {
let exprs = e.exprs().map(|expr| self.collect_expr(expr)).collect(); let exprs = e.fields().map(|expr| self.collect_expr(expr)).collect();
self.alloc_expr(Expr::Tuple { exprs }, syntax_ptr) self.alloc_expr(Expr::Tuple { exprs }, syntax_ptr)
} }
ast::Expr::BoxExpr(e) => { ast::Expr::BoxExpr(e) => {
@ -762,7 +762,7 @@ fn collect_pat(&mut self, pat: ast::Pat) -> PatId {
} }
ast::Pat::TupleStructPat(p) => { ast::Pat::TupleStructPat(p) => {
let path = p.path().and_then(|path| self.expander.parse_path(path)); let path = p.path().and_then(|path| self.expander.parse_path(path));
let (args, ellipsis) = self.collect_tuple_pat(p.args()); let (args, ellipsis) = self.collect_tuple_pat(p.fields());
Pat::TupleStruct { path, args, ellipsis } Pat::TupleStruct { path, args, ellipsis }
} }
ast::Pat::RefPat(p) => { ast::Pat::RefPat(p) => {
@ -780,7 +780,7 @@ fn collect_pat(&mut self, pat: ast::Pat) -> PatId {
} }
ast::Pat::ParenPat(p) => return self.collect_pat_opt(p.pat()), ast::Pat::ParenPat(p) => return self.collect_pat_opt(p.pat()),
ast::Pat::TuplePat(p) => { ast::Pat::TuplePat(p) => {
let (args, ellipsis) = self.collect_tuple_pat(p.args()); let (args, ellipsis) = self.collect_tuple_pat(p.fields());
Pat::Tuple { args, ellipsis } Pat::Tuple { args, ellipsis }
} }
ast::Pat::WildcardPat(_) => Pat::Wild, ast::Pat::WildcardPat(_) => Pat::Wild,
@ -809,7 +809,7 @@ fn collect_pat(&mut self, pat: ast::Pat) -> PatId {
ast::Pat::SlicePat(p) => { ast::Pat::SlicePat(p) => {
let SlicePatComponents { prefix, slice, suffix } = p.components(); let SlicePatComponents { prefix, slice, suffix } = p.components();
// FIXME properly handle `DotDotPat` // FIXME properly handle `RestPat`
Pat::Slice { Pat::Slice {
prefix: prefix.into_iter().map(|p| self.collect_pat(p)).collect(), prefix: prefix.into_iter().map(|p| self.collect_pat(p)).collect(),
slice: slice.map(|p| self.collect_pat(p)), slice: slice.map(|p| self.collect_pat(p)),
@ -827,9 +827,9 @@ fn collect_pat(&mut self, pat: ast::Pat) -> PatId {
} }
} }
ast::Pat::RestPat(_) => { ast::Pat::RestPat(_) => {
// `DotDotPat` requires special handling and should not be mapped // `RestPat` requires special handling and should not be mapped
// to a Pat. Here we are using `Pat::Missing` as a fallback for // to a Pat. Here we are using `Pat::Missing` as a fallback for
// when `DotDotPat` is mapped to `Pat`, which can easily happen // when `RestPat` is mapped to `Pat`, which can easily happen
// when the source code being analyzed has a malformed pattern // when the source code being analyzed has a malformed pattern
// which includes `..` in a place where it isn't valid. // which includes `..` in a place where it isn't valid.

View file

@ -893,7 +893,7 @@ pub struct TupleExpr {
impl ast::AttrsOwner for TupleExpr {} impl ast::AttrsOwner for TupleExpr {}
impl TupleExpr { impl TupleExpr {
pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) } pub fn fields(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
} }
#[derive(Debug, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Clone, PartialEq, Eq, Hash)]
@ -1210,7 +1210,7 @@ pub struct SlicePat {
} }
impl SlicePat { impl SlicePat {
pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) } pub fn pats(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
} }
#[derive(Debug, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Clone, PartialEq, Eq, Hash)]
@ -1219,7 +1219,7 @@ pub struct TuplePat {
} }
impl TuplePat { impl TuplePat {
pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) } pub fn fields(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
} }
#[derive(Debug, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Clone, PartialEq, Eq, Hash)]
@ -1229,7 +1229,7 @@ pub struct TupleStructPat {
impl TupleStructPat { impl TupleStructPat {
pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) } pub fn fields(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
} }
#[derive(Debug, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Clone, PartialEq, Eq, Hash)]

View file

@ -290,7 +290,7 @@ pub struct SlicePatComponents {
impl ast::SlicePat { impl ast::SlicePat {
pub fn components(&self) -> SlicePatComponents { pub fn components(&self) -> SlicePatComponents {
let mut args = self.args().peekable(); let mut args = self.pats().peekable();
let prefix = args let prefix = args
.peeking_take_while(|p| match p { .peeking_take_while(|p| match p {
ast::Pat::RestPat(_) => false, ast::Pat::RestPat(_) => false,

View file

@ -1,3 +1,7 @@
//*************************//
// Names, Paths and Macros //
//*************************//
Name = Name =
'ident' 'ident'
@ -50,6 +54,10 @@ MacroStmts =
statements:Stmt* statements:Stmt*
Expr? Expr?
//*************************//
// Items //
//*************************//
SourceFile = SourceFile =
'shebang'? 'shebang'?
Attr* Attr*
@ -245,6 +253,10 @@ Visibility =
Attr = Attr =
'#' '!'? '[' Path ('=' Literal | TokenTree)? ']' '#' '!'? '[' Path ('=' Literal | TokenTree)? ']'
//****************************//
// Statements and Expressions //
//****************************//
Stmt = Stmt =
ExprStmt ExprStmt
| Item | Item
@ -347,7 +359,7 @@ IndexExpr =
Attr* base:Expr '[' index:Expr ']' Attr* base:Expr '[' index:Expr ']'
TupleExpr = TupleExpr =
Attr* '(' Attr* (Expr (',' Expr)* ','?)? ')' Attr* '(' Attr* fields:(Expr (',' Expr)* ','?)? ')'
RecordExpr = RecordExpr =
Path RecordExprFieldList Path RecordExprFieldList
@ -434,6 +446,10 @@ AwaitExpr =
BoxExpr = BoxExpr =
Attr* 'box' Expr Attr* 'box' Expr
//*************************//
// Types //
//*************************//
Type = Type =
ArrayType ArrayType
| DynTraitType | DynTraitType
@ -495,6 +511,10 @@ TypeBound =
'lifetime' 'lifetime'
| '?'? Type | '?'? Type
//************************//
// Patterns //
//************************//
Pat = Pat =
IdentPat IdentPat
| BoxPat | BoxPat
@ -540,16 +560,16 @@ RecordPatField =
Attr* (NameRef ':')? Pat Attr* (NameRef ':')? Pat
TupleStructPat = TupleStructPat =
Path '(' args:(Pat (',' Pat)* ','?)? ')' Path '(' fields:(Pat (',' Pat)* ','?)? ')'
TuplePat = TuplePat =
'(' args:(Pat (',' Pat)* ','?)? ')' '(' fields:(Pat (',' Pat)* ','?)? ')'
ParenPat = ParenPat =
'(' Pat ')' '(' Pat ')'
SlicePat = SlicePat =
'[' args:(Pat (',' Pat)* ','?)? ']' '[' (Pat (',' Pat)* ','?)? ']'
PathPat = PathPat =
Path Path