diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-04-10 16:48:21 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-04-10 16:48:21 +0100 |
commit | f553162c4eee2c99e27de7e7351d8a3681601b1d (patch) | |
tree | 2267fb0aa4f15d900d7ce8c6bcc4ef976aac8084 /crates | |
parent | fcd609862b8d5b0567bb74895ef75b02912a375d (diff) | |
parent | c476742f47dd905fa366e62f480e3f656c62e66c (diff) |
Merge #3928
3928: Simplify r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_syntax/src/ast/extensions.rs | 20 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/generated/nodes.rs | 1 |
2 files changed, 2 insertions, 19 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 { | |||
275 | impl ast::SelfParam { | 275 | impl 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 {} | |||
2307 | impl ast::AttrsOwner for SelfParam {} | 2307 | impl ast::AttrsOwner for SelfParam {} |
2308 | impl SelfParam { | 2308 | impl 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 | } |