aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast/extensions.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/ast/extensions.rs')
-rw-r--r--crates/ra_syntax/src/ast/extensions.rs12
1 files changed, 4 insertions, 8 deletions
diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs
index eee98ebc2..03d94170d 100644
--- a/crates/ra_syntax/src/ast/extensions.rs
+++ b/crates/ra_syntax/src/ast/extensions.rs
@@ -21,11 +21,7 @@ impl ast::NameRef {
21 } 21 }
22 22
23 pub fn as_tuple_field(&self) -> Option<usize> { 23 pub fn as_tuple_field(&self) -> Option<usize> {
24 if let Some(ast::NameRefToken::IntNumber(token)) = self.name_ref_token_token() { 24 self.text().parse().ok()
25 token.text().as_str().parse().ok()
26 } else {
27 None
28 }
29 } 25 }
30} 26}
31 27
@@ -315,7 +311,7 @@ pub enum TypeBoundKind {
315 /// for<'a> ... 311 /// for<'a> ...
316 ForType(ast::ForType), 312 ForType(ast::ForType),
317 /// 'a 313 /// 'a
318 Lifetime(ast::Lifetime), 314 Lifetime(SyntaxToken),
319} 315}
320 316
321impl ast::TypeBound { 317impl ast::TypeBound {
@@ -401,7 +397,7 @@ impl ast::RangePat {
401 pub fn start(&self) -> Option<ast::Pat> { 397 pub fn start(&self) -> Option<ast::Pat> {
402 self.syntax() 398 self.syntax()
403 .children_with_tokens() 399 .children_with_tokens()
404 .take_while(|it| !ast::RangeSeparator::can_cast(it.kind())) 400 .take_while(|it| !(it.kind() == T![..] || it.kind() == T![..=]))
405 .filter_map(|it| it.into_node()) 401 .filter_map(|it| it.into_node())
406 .find_map(ast::Pat::cast) 402 .find_map(ast::Pat::cast)
407 } 403 }
@@ -409,7 +405,7 @@ impl ast::RangePat {
409 pub fn end(&self) -> Option<ast::Pat> { 405 pub fn end(&self) -> Option<ast::Pat> {
410 self.syntax() 406 self.syntax()
411 .children_with_tokens() 407 .children_with_tokens()
412 .skip_while(|it| !ast::RangeSeparator::can_cast(it.kind())) 408 .skip_while(|it| !(it.kind() == T![..] || it.kind() == T![..=]))
413 .filter_map(|it| it.into_node()) 409 .filter_map(|it| it.into_node())
414 .find_map(ast::Pat::cast) 410 .find_map(ast::Pat::cast)
415 } 411 }