diff options
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r-- | crates/ra_syntax/src/ast/generated/nodes.rs | 26 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/make.rs | 4 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/node_ext.rs | 6 |
3 files changed, 18 insertions, 18 deletions
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index f6b3fa6ef..231a0f727 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs | |||
@@ -1111,12 +1111,12 @@ impl TypeBound { | |||
1111 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } | 1111 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } |
1112 | } | 1112 | } |
1113 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1113 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1114 | pub struct BindPat { | 1114 | pub struct IdentPat { |
1115 | pub(crate) syntax: SyntaxNode, | 1115 | pub(crate) syntax: SyntaxNode, |
1116 | } | 1116 | } |
1117 | impl ast::AttrsOwner for BindPat {} | 1117 | impl ast::AttrsOwner for IdentPat {} |
1118 | impl ast::NameOwner for BindPat {} | 1118 | impl ast::NameOwner for IdentPat {} |
1119 | impl BindPat { | 1119 | impl IdentPat { |
1120 | pub fn ref_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ref]) } | 1120 | pub fn ref_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ref]) } |
1121 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } | 1121 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } |
1122 | pub fn at_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![@]) } | 1122 | pub fn at_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![@]) } |
@@ -1335,7 +1335,7 @@ pub enum Stmt { | |||
1335 | } | 1335 | } |
1336 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1336 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1337 | pub enum Pat { | 1337 | pub enum Pat { |
1338 | BindPat(BindPat), | 1338 | IdentPat(IdentPat), |
1339 | BoxPat(BoxPat), | 1339 | BoxPat(BoxPat), |
1340 | DotDotPat(DotDotPat), | 1340 | DotDotPat(DotDotPat), |
1341 | LiteralPat(LiteralPat), | 1341 | LiteralPat(LiteralPat), |
@@ -2556,8 +2556,8 @@ impl AstNode for TypeBound { | |||
2556 | } | 2556 | } |
2557 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2557 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2558 | } | 2558 | } |
2559 | impl AstNode for BindPat { | 2559 | impl AstNode for IdentPat { |
2560 | fn can_cast(kind: SyntaxKind) -> bool { kind == BIND_PAT } | 2560 | fn can_cast(kind: SyntaxKind) -> bool { kind == IDENT_PAT } |
2561 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2561 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
2562 | if Self::can_cast(syntax.kind()) { | 2562 | if Self::can_cast(syntax.kind()) { |
2563 | Some(Self { syntax }) | 2563 | Some(Self { syntax }) |
@@ -3136,8 +3136,8 @@ impl From<Item> for Stmt { | |||
3136 | impl From<LetStmt> for Stmt { | 3136 | impl From<LetStmt> for Stmt { |
3137 | fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) } | 3137 | fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) } |
3138 | } | 3138 | } |
3139 | impl From<BindPat> for Pat { | 3139 | impl From<IdentPat> for Pat { |
3140 | fn from(node: BindPat) -> Pat { Pat::BindPat(node) } | 3140 | fn from(node: IdentPat) -> Pat { Pat::IdentPat(node) } |
3141 | } | 3141 | } |
3142 | impl From<BoxPat> for Pat { | 3142 | impl From<BoxPat> for Pat { |
3143 | fn from(node: BoxPat) -> Pat { Pat::BoxPat(node) } | 3143 | fn from(node: BoxPat) -> Pat { Pat::BoxPat(node) } |
@@ -3184,7 +3184,7 @@ impl From<TupleStructPat> for Pat { | |||
3184 | impl AstNode for Pat { | 3184 | impl AstNode for Pat { |
3185 | fn can_cast(kind: SyntaxKind) -> bool { | 3185 | fn can_cast(kind: SyntaxKind) -> bool { |
3186 | match kind { | 3186 | match kind { |
3187 | BIND_PAT | BOX_PAT | DOT_DOT_PAT | LITERAL_PAT | MACRO_PAT | OR_PAT | PAREN_PAT | 3187 | IDENT_PAT | BOX_PAT | DOT_DOT_PAT | LITERAL_PAT | MACRO_PAT | OR_PAT | PAREN_PAT |
3188 | | PATH_PAT | WILDCARD_PAT | RANGE_PAT | RECORD_PAT | REF_PAT | SLICE_PAT | 3188 | | PATH_PAT | WILDCARD_PAT | RANGE_PAT | RECORD_PAT | REF_PAT | SLICE_PAT |
3189 | | TUPLE_PAT | TUPLE_STRUCT_PAT => true, | 3189 | | TUPLE_PAT | TUPLE_STRUCT_PAT => true, |
3190 | _ => false, | 3190 | _ => false, |
@@ -3192,7 +3192,7 @@ impl AstNode for Pat { | |||
3192 | } | 3192 | } |
3193 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 3193 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
3194 | let res = match syntax.kind() { | 3194 | let res = match syntax.kind() { |
3195 | BIND_PAT => Pat::BindPat(BindPat { syntax }), | 3195 | IDENT_PAT => Pat::IdentPat(IdentPat { syntax }), |
3196 | BOX_PAT => Pat::BoxPat(BoxPat { syntax }), | 3196 | BOX_PAT => Pat::BoxPat(BoxPat { syntax }), |
3197 | DOT_DOT_PAT => Pat::DotDotPat(DotDotPat { syntax }), | 3197 | DOT_DOT_PAT => Pat::DotDotPat(DotDotPat { syntax }), |
3198 | LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }), | 3198 | LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }), |
@@ -3213,7 +3213,7 @@ impl AstNode for Pat { | |||
3213 | } | 3213 | } |
3214 | fn syntax(&self) -> &SyntaxNode { | 3214 | fn syntax(&self) -> &SyntaxNode { |
3215 | match self { | 3215 | match self { |
3216 | Pat::BindPat(it) => &it.syntax, | 3216 | Pat::IdentPat(it) => &it.syntax, |
3217 | Pat::BoxPat(it) => &it.syntax, | 3217 | Pat::BoxPat(it) => &it.syntax, |
3218 | Pat::DotDotPat(it) => &it.syntax, | 3218 | Pat::DotDotPat(it) => &it.syntax, |
3219 | Pat::LiteralPat(it) => &it.syntax, | 3219 | Pat::LiteralPat(it) => &it.syntax, |
@@ -3981,7 +3981,7 @@ impl std::fmt::Display for TypeBound { | |||
3981 | std::fmt::Display::fmt(self.syntax(), f) | 3981 | std::fmt::Display::fmt(self.syntax(), f) |
3982 | } | 3982 | } |
3983 | } | 3983 | } |
3984 | impl std::fmt::Display for BindPat { | 3984 | impl std::fmt::Display for IdentPat { |
3985 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3985 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3986 | std::fmt::Display::fmt(self.syntax(), f) | 3986 | std::fmt::Display::fmt(self.syntax(), f) |
3987 | } | 3987 | } |
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs index efb2cb4a3..673777015 100644 --- a/crates/ra_syntax/src/ast/make.rs +++ b/crates/ra_syntax/src/ast/make.rs | |||
@@ -148,10 +148,10 @@ pub fn condition(expr: ast::Expr, pattern: Option<ast::Pat>) -> ast::Condition { | |||
148 | } | 148 | } |
149 | } | 149 | } |
150 | 150 | ||
151 | pub fn bind_pat(name: ast::Name) -> ast::BindPat { | 151 | pub fn bind_pat(name: ast::Name) -> ast::IdentPat { |
152 | return from_text(name.text()); | 152 | return from_text(name.text()); |
153 | 153 | ||
154 | fn from_text(text: &str) -> ast::BindPat { | 154 | fn from_text(text: &str) -> ast::IdentPat { |
155 | ast_from_text(&format!("fn f({}: ())", text)) | 155 | ast_from_text(&format!("fn f({}: ())", text)) |
156 | } | 156 | } |
157 | } | 157 | } |
diff --git a/crates/ra_syntax/src/ast/node_ext.rs b/crates/ra_syntax/src/ast/node_ext.rs index 2cfdac225..4b4a72375 100644 --- a/crates/ra_syntax/src/ast/node_ext.rs +++ b/crates/ra_syntax/src/ast/node_ext.rs | |||
@@ -233,7 +233,7 @@ impl ast::RecordPatField { | |||
233 | if let Some(name_ref) = self.name_ref() { | 233 | if let Some(name_ref) = self.name_ref() { |
234 | return Some(NameOrNameRef::NameRef(name_ref)); | 234 | return Some(NameOrNameRef::NameRef(name_ref)); |
235 | } | 235 | } |
236 | if let Some(ast::Pat::BindPat(pat)) = self.pat() { | 236 | if let Some(ast::Pat::IdentPat(pat)) = self.pat() { |
237 | let name = pat.name()?; | 237 | let name = pat.name()?; |
238 | return Some(NameOrNameRef::Name(name)); | 238 | return Some(NameOrNameRef::Name(name)); |
239 | } | 239 | } |
@@ -294,13 +294,13 @@ impl ast::SlicePat { | |||
294 | let prefix = args | 294 | let prefix = args |
295 | .peeking_take_while(|p| match p { | 295 | .peeking_take_while(|p| match p { |
296 | ast::Pat::DotDotPat(_) => false, | 296 | ast::Pat::DotDotPat(_) => false, |
297 | ast::Pat::BindPat(bp) => match bp.pat() { | 297 | ast::Pat::IdentPat(bp) => match bp.pat() { |
298 | Some(ast::Pat::DotDotPat(_)) => false, | 298 | Some(ast::Pat::DotDotPat(_)) => false, |
299 | _ => true, | 299 | _ => true, |
300 | }, | 300 | }, |
301 | ast::Pat::RefPat(rp) => match rp.pat() { | 301 | ast::Pat::RefPat(rp) => match rp.pat() { |
302 | Some(ast::Pat::DotDotPat(_)) => false, | 302 | Some(ast::Pat::DotDotPat(_)) => false, |
303 | Some(ast::Pat::BindPat(bp)) => match bp.pat() { | 303 | Some(ast::Pat::IdentPat(bp)) => match bp.pat() { |
304 | Some(ast::Pat::DotDotPat(_)) => false, | 304 | Some(ast::Pat::DotDotPat(_)) => false, |
305 | _ => true, | 305 | _ => true, |
306 | }, | 306 | }, |