diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-10-14 20:10:59 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-14 20:10:59 +0000 |
| commit | bfb8f73fb3f8a1a7fadfa31bda98a17549a91093 (patch) | |
| tree | 890d7b7721c2f446de7e82b6bcf64b4f7c35a444 | |
| parent | 0af9d1fc8aaf07bdcd7ab1e7ccad757b69e5c76f (diff) | |
| parent | 35de195c418a1c076d13bc4c969d0368a64527d2 (diff) | |
| download | rust-bfb8f73fb3f8a1a7fadfa31bda98a17549a91093.tar.gz rust-bfb8f73fb3f8a1a7fadfa31bda98a17549a91093.zip | |
Merge #10545
10545: A few clippy fixes r=Veykril a=Milo123459 A few clippy fixes Co-authored-by: Milo <50248166+Milo123459@users.noreply.github.com>
| -rw-r--r-- | crates/cfg/src/lib.rs | 4 | ||||
| -rw-r--r-- | crates/flycheck/src/lib.rs | 2 | ||||
| -rw-r--r-- | crates/ide/src/goto_declaration.rs | 2 | ||||
| -rw-r--r-- | crates/ide/src/syntax_highlighting/highlight.rs | 2 | ||||
| -rw-r--r-- | crates/syntax/test_data/parser/fuzz-failures/0000.rs | 4 |
5 files changed, 9 insertions, 5 deletions
diff --git a/crates/cfg/src/lib.rs b/crates/cfg/src/lib.rs index 6ba056f3088..417ba609197 100644 --- a/crates/cfg/src/lib.rs +++ b/crates/cfg/src/lib.rs @@ -113,6 +113,10 @@ impl CfgDiff { pub fn len(&self) -> usize { self.enable.len() + self.disable.len() } + + pub fn is_empty(&self) -> bool { + self.len() == 0 + } } impl fmt::Display for CfgDiff { diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs index 34996280caf..1641f744cd3 100644 --- a/crates/flycheck/src/lib.rs +++ b/crates/flycheck/src/lib.rs @@ -297,7 +297,7 @@ impl CargoActor { read_at_least_one_message = true; // Try to deserialize a message from Cargo or Rustc. - let mut deserializer = serde_json::Deserializer::from_str(&line); + let mut deserializer = serde_json::Deserializer::from_str(line); deserializer.disable_recursion_limit(); if let Ok(message) = JsonMessage::deserialize(&mut deserializer) { match message { diff --git a/crates/ide/src/goto_declaration.rs b/crates/ide/src/goto_declaration.rs index 7aef463032b..2c5a24b1d2e 100644 --- a/crates/ide/src/goto_declaration.rs +++ b/crates/ide/src/goto_declaration.rs @@ -57,7 +57,7 @@ mod tests { .unwrap() .expect("no declaration or definition found") .info; - if navs.len() == 0 { + if navs.is_empty() { panic!("unresolved reference") } diff --git a/crates/ide/src/syntax_highlighting/highlight.rs b/crates/ide/src/syntax_highlighting/highlight.rs index d2ec3ca939d..47c0f00c00f 100644 --- a/crates/ide/src/syntax_highlighting/highlight.rs +++ b/crates/ide/src/syntax_highlighting/highlight.rs @@ -741,7 +741,7 @@ fn parents_match(mut node: NodeOrToken<SyntaxNode, SyntaxToken>, mut kinds: &[Sy } // Only true if we matched all expected kinds - kinds.len() == 0 + kinds.is_empty() } #[inline] diff --git a/crates/syntax/test_data/parser/fuzz-failures/0000.rs b/crates/syntax/test_data/parser/fuzz-failures/0000.rs index f1d0dc34382..f977d23c480 100644 --- a/crates/syntax/test_data/parser/fuzz-failures/0000.rs +++ b/crates/syntax/test_data/parser/fuzz-failures/0000.rs @@ -101,7 +101,7 @@ pub /*(meh)*/ fn replace_range(mut text: String, range: TextRange, replace_with: } fn is_balanced(tokens: &[Token]) -> bool { - if tokens.len() == 0 + if tokens.is_empty() || tokens.first().unwrap().kind != L_CURLY || tokens.last().unwrap().kind != R_CURLY { return false @@ -153,7 +153,7 @@ pub /*(meh)*/ fn replace_range(mut text: String, range: TextRange, replace_with: } fn is_balanced(tokens: &[Token]) -> bool { - if tokens.len() == 0 + if tokens.is_empty() || tokens.first().unwrap().kind != L_CURLY || tokens.last().unwrap().kind != R_CURLY { return false |
