From b8ddcb0652f3ec8683023afc1e1f5166d6a712f4 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 18 Feb 2020 14:53:02 +0200 Subject: Run cargo +nightly fix --clippy -Z unstable-options --- crates/ra_syntax/src/algo.rs | 9 +++++---- crates/ra_syntax/src/ast/expr_extensions.rs | 12 ++++++------ crates/ra_syntax/src/ast/make.rs | 2 +- crates/ra_syntax/src/parsing/text_token_source.rs | 2 +- 4 files changed, 13 insertions(+), 12 deletions(-) (limited to 'crates/ra_syntax') 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 { lhs: SyntaxElement, rhs: SyntaxElement, ) { - if lhs.kind() == rhs.kind() && lhs.text_range().len() == rhs.text_range().len() { - if match (&lhs, &rhs) { + if lhs.kind() == rhs.kind() + && lhs.text_range().len() == rhs.text_range().len() + && match (&lhs, &rhs) { (NodeOrToken::Node(lhs), NodeOrToken::Node(rhs)) => { lhs.green() == rhs.green() || lhs.text() == rhs.text() } (NodeOrToken::Token(lhs), NodeOrToken::Token(rhs)) => lhs.text() == rhs.text(), _ => false, - } { - return; } + { + return; } if let (Some(lhs), Some(rhs)) = (lhs.as_node(), rhs.as_node()) { 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 { impl ast::IfExpr { pub fn then_branch(&self) -> Option { - self.blocks().nth(0) + self.blocks().next() } pub fn else_branch(&self) -> Option { let res = match self.blocks().nth(1) { @@ -208,7 +208,7 @@ impl ast::BinExpr { } pub fn lhs(&self) -> Option { - children(self).nth(0) + children(self).next() } pub fn rhs(&self) -> Option { @@ -271,7 +271,7 @@ impl ast::RangeExpr { impl ast::IndexExpr { pub fn base(&self) -> Option { - children(self).nth(0) + children(self).next() } pub fn index(&self) -> Option { children(self).nth(1) @@ -287,7 +287,7 @@ impl ast::ArrayExpr { pub fn kind(&self) -> ArrayExprKind { if self.is_repeat() { ArrayExprKind::Repeat { - initializer: children(self).nth(0), + initializer: children(self).next(), repeat: children(self).nth(1), } } else { @@ -328,10 +328,10 @@ impl ast::Literal { } pub fn kind(&self) -> LiteralKind { - const INT_SUFFIXES: [&'static str; 12] = [ + const INT_SUFFIXES: [&str; 12] = [ "u64", "u32", "u16", "u8", "usize", "isize", "i64", "i32", "i16", "i8", "u128", "i128", ]; - const FLOAT_SUFFIXES: [&'static str; 2] = ["f32", "f64"]; + const FLOAT_SUFFIXES: [&str; 2] = ["f32", "f64"]; let token = self.token(); 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) -> ast::Mat format!(" {}{}\n", arm.syntax(), comma) }) .collect::(); - return from_text(&format!("{}", arms_str)); + return from_text(&arms_str); fn from_text(text: &str) -> ast::MatchArmList { 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> { fn is_keyword(&self, kw: &str) -> bool { let pos = self.curr.1; - if !(pos < self.tokens.len()) { + if pos >= self.tokens.len() { return false; } let range = TextRange::offset_len(self.start_offsets[pos], self.tokens[pos].len); -- cgit v1.2.3 From f6816c253b96e8436f1156d6bd6b0942ee9fb4d3 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 18 Feb 2020 15:57:41 +0200 Subject: Update versions --- crates/ra_syntax/Cargo.toml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'crates/ra_syntax') diff --git a/crates/ra_syntax/Cargo.toml b/crates/ra_syntax/Cargo.toml index cb72972c5..7891628dc 100644 --- a/crates/ra_syntax/Cargo.toml +++ b/crates/ra_syntax/Cargo.toml @@ -11,12 +11,12 @@ repository = "https://github.com/rust-analyzer/rust-analyzer" doctest = false [dependencies] -itertools = "0.8.0" +itertools = "0.8.2" rowan = "0.9.0" rustc_lexer = "0.1.0" -rustc-hash = "1.0.1" +rustc-hash = "1.1.0" arrayvec = "0.5.1" -once_cell = "1.2.0" +once_cell = "1.3.1" ra_text_edit = { path = "../ra_text_edit" } ra_parser = { path = "../ra_parser" } @@ -24,9 +24,9 @@ ra_parser = { path = "../ra_parser" } # This crate transitively depends on `smol_str` via `rowan`. # ideally, `serde` should be enabled by `rust-analyzer`, but we enable it here # to reduce number of compilations -smol_str = { version = "0.1.12", features = ["serde"] } -serde = { version = "1", features = ["derive"] } +smol_str = { version = "0.1.15", features = ["serde"] } +serde = { version = "1.0.104", features = ["derive"] } [dev-dependencies] test_utils = { path = "../test_utils" } -walkdir = "2.2.0" +walkdir = "2.3.1" -- cgit v1.2.3