diff options
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r-- | crates/ra_syntax/src/algo.rs | 9 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/expr_extensions.rs | 12 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/make.rs | 2 | ||||
-rw-r--r-- | crates/ra_syntax/src/parsing/text_token_source.rs | 2 |
4 files changed, 13 insertions, 12 deletions
diff --git a/crates/ra_syntax/src/algo.rs b/crates/ra_syntax/src/algo.rs index acf677e7d..21fca99a6 100644 --- a/crates/ra_syntax/src/algo.rs +++ b/crates/ra_syntax/src/algo.rs | |||
@@ -95,16 +95,17 @@ pub fn diff(from: &SyntaxNode, to: &SyntaxNode) -> TreeDiff { | |||
95 | lhs: SyntaxElement, | 95 | lhs: SyntaxElement, |
96 | rhs: SyntaxElement, | 96 | rhs: SyntaxElement, |
97 | ) { | 97 | ) { |
98 | if lhs.kind() == rhs.kind() && lhs.text_range().len() == rhs.text_range().len() { | 98 | if lhs.kind() == rhs.kind() |
99 | if match (&lhs, &rhs) { | 99 | && lhs.text_range().len() == rhs.text_range().len() |
100 | && match (&lhs, &rhs) { | ||
100 | (NodeOrToken::Node(lhs), NodeOrToken::Node(rhs)) => { | 101 | (NodeOrToken::Node(lhs), NodeOrToken::Node(rhs)) => { |
101 | lhs.green() == rhs.green() || lhs.text() == rhs.text() | 102 | lhs.green() == rhs.green() || lhs.text() == rhs.text() |
102 | } | 103 | } |
103 | (NodeOrToken::Token(lhs), NodeOrToken::Token(rhs)) => lhs.text() == rhs.text(), | 104 | (NodeOrToken::Token(lhs), NodeOrToken::Token(rhs)) => lhs.text() == rhs.text(), |
104 | _ => false, | 105 | _ => false, |
105 | } { | ||
106 | return; | ||
107 | } | 106 | } |
107 | { | ||
108 | return; | ||
108 | } | 109 | } |
109 | if let (Some(lhs), Some(rhs)) = (lhs.as_node(), rhs.as_node()) { | 110 | if let (Some(lhs), Some(rhs)) = (lhs.as_node(), rhs.as_node()) { |
110 | if lhs.children_with_tokens().count() == rhs.children_with_tokens().count() { | 111 | if lhs.children_with_tokens().count() == rhs.children_with_tokens().count() { |
diff --git a/crates/ra_syntax/src/ast/expr_extensions.rs b/crates/ra_syntax/src/ast/expr_extensions.rs index 2e50a095c..77cceb382 100644 --- a/crates/ra_syntax/src/ast/expr_extensions.rs +++ b/crates/ra_syntax/src/ast/expr_extensions.rs | |||
@@ -30,7 +30,7 @@ pub enum ElseBranch { | |||
30 | 30 | ||
31 | impl ast::IfExpr { | 31 | impl ast::IfExpr { |
32 | pub fn then_branch(&self) -> Option<ast::BlockExpr> { | 32 | pub fn then_branch(&self) -> Option<ast::BlockExpr> { |
33 | self.blocks().nth(0) | 33 | self.blocks().next() |
34 | } | 34 | } |
35 | pub fn else_branch(&self) -> Option<ElseBranch> { | 35 | pub fn else_branch(&self) -> Option<ElseBranch> { |
36 | let res = match self.blocks().nth(1) { | 36 | let res = match self.blocks().nth(1) { |
@@ -208,7 +208,7 @@ impl ast::BinExpr { | |||
208 | } | 208 | } |
209 | 209 | ||
210 | pub fn lhs(&self) -> Option<ast::Expr> { | 210 | pub fn lhs(&self) -> Option<ast::Expr> { |
211 | children(self).nth(0) | 211 | children(self).next() |
212 | } | 212 | } |
213 | 213 | ||
214 | pub fn rhs(&self) -> Option<ast::Expr> { | 214 | pub fn rhs(&self) -> Option<ast::Expr> { |
@@ -271,7 +271,7 @@ impl ast::RangeExpr { | |||
271 | 271 | ||
272 | impl ast::IndexExpr { | 272 | impl ast::IndexExpr { |
273 | pub fn base(&self) -> Option<ast::Expr> { | 273 | pub fn base(&self) -> Option<ast::Expr> { |
274 | children(self).nth(0) | 274 | children(self).next() |
275 | } | 275 | } |
276 | pub fn index(&self) -> Option<ast::Expr> { | 276 | pub fn index(&self) -> Option<ast::Expr> { |
277 | children(self).nth(1) | 277 | children(self).nth(1) |
@@ -287,7 +287,7 @@ impl ast::ArrayExpr { | |||
287 | pub fn kind(&self) -> ArrayExprKind { | 287 | pub fn kind(&self) -> ArrayExprKind { |
288 | if self.is_repeat() { | 288 | if self.is_repeat() { |
289 | ArrayExprKind::Repeat { | 289 | ArrayExprKind::Repeat { |
290 | initializer: children(self).nth(0), | 290 | initializer: children(self).next(), |
291 | repeat: children(self).nth(1), | 291 | repeat: children(self).nth(1), |
292 | } | 292 | } |
293 | } else { | 293 | } else { |
@@ -328,10 +328,10 @@ impl ast::Literal { | |||
328 | } | 328 | } |
329 | 329 | ||
330 | pub fn kind(&self) -> LiteralKind { | 330 | pub fn kind(&self) -> LiteralKind { |
331 | const INT_SUFFIXES: [&'static str; 12] = [ | 331 | const INT_SUFFIXES: [&str; 12] = [ |
332 | "u64", "u32", "u16", "u8", "usize", "isize", "i64", "i32", "i16", "i8", "u128", "i128", | 332 | "u64", "u32", "u16", "u8", "usize", "isize", "i64", "i32", "i16", "i8", "u128", "i128", |
333 | ]; | 333 | ]; |
334 | const FLOAT_SUFFIXES: [&'static str; 2] = ["f32", "f64"]; | 334 | const FLOAT_SUFFIXES: [&str; 2] = ["f32", "f64"]; |
335 | 335 | ||
336 | let token = self.token(); | 336 | let token = self.token(); |
337 | 337 | ||
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs index 89d1403e7..7c20fcc10 100644 --- a/crates/ra_syntax/src/ast/make.rs +++ b/crates/ra_syntax/src/ast/make.rs | |||
@@ -152,7 +152,7 @@ pub fn match_arm_list(arms: impl IntoIterator<Item = ast::MatchArm>) -> ast::Mat | |||
152 | format!(" {}{}\n", arm.syntax(), comma) | 152 | format!(" {}{}\n", arm.syntax(), comma) |
153 | }) | 153 | }) |
154 | .collect::<String>(); | 154 | .collect::<String>(); |
155 | return from_text(&format!("{}", arms_str)); | 155 | return from_text(&arms_str); |
156 | 156 | ||
157 | fn from_text(text: &str) -> ast::MatchArmList { | 157 | fn from_text(text: &str) -> ast::MatchArmList { |
158 | ast_from_text(&format!("fn f() {{ match () {{\n{}}} }}", text)) | 158 | ast_from_text(&format!("fn f() {{ match () {{\n{}}} }}", text)) |
diff --git a/crates/ra_syntax/src/parsing/text_token_source.rs b/crates/ra_syntax/src/parsing/text_token_source.rs index e793f93a4..e2433913c 100644 --- a/crates/ra_syntax/src/parsing/text_token_source.rs +++ b/crates/ra_syntax/src/parsing/text_token_source.rs | |||
@@ -48,7 +48,7 @@ impl<'t> TokenSource for TextTokenSource<'t> { | |||
48 | 48 | ||
49 | fn is_keyword(&self, kw: &str) -> bool { | 49 | fn is_keyword(&self, kw: &str) -> bool { |
50 | let pos = self.curr.1; | 50 | let pos = self.curr.1; |
51 | if !(pos < self.tokens.len()) { | 51 | if pos >= self.tokens.len() { |
52 | return false; | 52 | return false; |
53 | } | 53 | } |
54 | let range = TextRange::offset_len(self.start_offsets[pos], self.tokens[pos].len); | 54 | let range = TextRange::offset_len(self.start_offsets[pos], self.tokens[pos].len); |