aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-04-10 16:48:21 +0100
committerGitHub <[email protected]>2020-04-10 16:48:21 +0100
commitf553162c4eee2c99e27de7e7351d8a3681601b1d (patch)
tree2267fb0aa4f15d900d7ce8c6bcc4ef976aac8084
parentfcd609862b8d5b0567bb74895ef75b02912a375d (diff)
parentc476742f47dd905fa366e62f480e3f656c62e66c (diff)
Merge #3928
3928: Simplify r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
-rw-r--r--crates/ra_syntax/src/ast/extensions.rs20
-rw-r--r--crates/ra_syntax/src/ast/generated/nodes.rs1
-rw-r--r--xtask/src/ast_src.rs2
3 files changed, 3 insertions, 20 deletions
diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs
index 1aacb0676..76b7655e6 100644
--- a/crates/ra_syntax/src/ast/extensions.rs
+++ b/crates/ra_syntax/src/ast/extensions.rs
@@ -275,7 +275,7 @@ pub enum SelfParamKind {
275impl ast::SelfParam { 275impl ast::SelfParam {
276 pub fn kind(&self) -> SelfParamKind { 276 pub fn kind(&self) -> SelfParamKind {
277 if self.amp_token().is_some() { 277 if self.amp_token().is_some() {
278 if self.amp_mut_token().is_some() { 278 if self.mut_token().is_some() {
279 SelfParamKind::MutRef 279 SelfParamKind::MutRef
280 } else { 280 } else {
281 SelfParamKind::Ref 281 SelfParamKind::Ref
@@ -284,24 +284,6 @@ impl ast::SelfParam {
284 SelfParamKind::Owned 284 SelfParamKind::Owned
285 } 285 }
286 } 286 }
287
288 /// the "mut" in "mut self", not the one in "&mut self"
289 pub fn mut_token(&self) -> Option<SyntaxToken> {
290 self.syntax()
291 .children_with_tokens()
292 .filter_map(|it| it.into_token())
293 .take_while(|it| it.kind() != T![&])
294 .find(|it| it.kind() == T![mut])
295 }
296
297 /// the "mut" in "&mut self", not the one in "mut self"
298 pub fn amp_mut_token(&self) -> Option<SyntaxToken> {
299 self.syntax()
300 .children_with_tokens()
301 .filter_map(|it| it.into_token())
302 .skip_while(|it| it.kind() != T![&])
303 .find(|it| it.kind() == T![mut])
304 }
305} 287}
306 288
307#[derive(Clone, Debug, PartialEq, Eq, Hash)] 289#[derive(Clone, Debug, PartialEq, Eq, Hash)]
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs
index 0df7cfe52..f1098755b 100644
--- a/crates/ra_syntax/src/ast/generated/nodes.rs
+++ b/crates/ra_syntax/src/ast/generated/nodes.rs
@@ -2307,6 +2307,7 @@ impl ast::TypeAscriptionOwner for SelfParam {}
2307impl ast::AttrsOwner for SelfParam {} 2307impl ast::AttrsOwner for SelfParam {}
2308impl SelfParam { 2308impl SelfParam {
2309 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) } 2309 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
2310 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
2310 pub fn lifetime_token(&self) -> Option<SyntaxToken> { 2311 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
2311 support::token(&self.syntax, T![lifetime]) 2312 support::token(&self.syntax, T![lifetime])
2312 } 2313 }
diff --git a/xtask/src/ast_src.rs b/xtask/src/ast_src.rs
index 8c0b5f5a8..69cba9168 100644
--- a/xtask/src/ast_src.rs
+++ b/xtask/src/ast_src.rs
@@ -568,7 +568,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
568 params: [Param], 568 params: [Param],
569 T![')'] 569 T![')']
570 } 570 }
571 struct SelfParam: TypeAscriptionOwner, AttrsOwner { T![&], T![lifetime], T![self] } 571 struct SelfParam: TypeAscriptionOwner, AttrsOwner { T![&], T![mut], T![lifetime], T![self] }
572 struct Param: TypeAscriptionOwner, AttrsOwner { 572 struct Param: TypeAscriptionOwner, AttrsOwner {
573 Pat, 573 Pat,
574 T![...] 574 T![...]