From 2c6972c1b2b8e725ef4cd9887cdf937af60dcaf6 Mon Sep 17 00:00:00 2001 From: QuarticCat Date: Wed, 28 Sep 2022 05:43:35 +0800 Subject: [PATCH] Fix more clippy warnings --- src/diff/graph.rs | 2 +- src/display/style.rs | 2 +- src/main.rs | 11 +++++------ src/parse/guess_language.rs | 2 +- src/parse/syntax.rs | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/diff/graph.rs b/src/diff/graph.rs index f68e65556b..40020ca5ee 100644 --- a/src/diff/graph.rs +++ b/src/diff/graph.rs @@ -731,7 +731,7 @@ pub fn get_set_neighbours<'syn, 'b>( } } assert!( - res.len() > 0, + !res.is_empty(), "Must always find some next steps if node is not the end" ); diff --git a/src/display/style.rs b/src/display/style.rs index f7a81264aa..aa6ba4bfe8 100644 --- a/src/display/style.rs +++ b/src/display/style.rs @@ -130,7 +130,7 @@ pub fn split_and_apply( let end_col = span.end_col as usize; // The remaining spans are beyond the end of this line_part. - if start_col >= part_start + byte_len(&line_part) { + if start_col >= part_start + byte_len(line_part) { break; } diff --git a/src/main.rs b/src/main.rs index 415f48917c..f039828e42 100644 --- a/src/main.rs +++ b/src/main.rs @@ -55,7 +55,6 @@ use diff::sliders::fix_all_sliders; use options::{DisplayMode, DisplayOptions, FileArgument, Mode, DEFAULT_TAB_WIDTH}; use owo_colors::OwoColorize; use rayon::prelude::*; -use std::path::PathBuf; use std::{env, path::Path}; use summary::{DiffResult, FileContent}; use syntax::init_next_prev; @@ -142,7 +141,7 @@ fn main() { print!("{}", name); let mut extensions: Vec<&str> = (*extensions).into(); - extensions.sort(); + extensions.sort_unstable(); for extension in extensions { print!(" .{}", extension); @@ -179,8 +178,8 @@ fn main() { options::FileArgument::NamedPath(rhs_path), ) if lhs_path.is_dir() && rhs_path.is_dir() => { diff_directories( - &lhs_path, - &rhs_path, + lhs_path, + rhs_path, &display_options, graph_limit, byte_limit, @@ -403,8 +402,8 @@ fn diff_file_content( /// When more than one file is modified, the hg extdiff extension passes directory /// paths with the all the modified files. fn diff_directories<'a>( - lhs_dir: &'a PathBuf, - rhs_dir: &'a PathBuf, + lhs_dir: &'a Path, + rhs_dir: &'a Path, display_options: &DisplayOptions, graph_limit: usize, byte_limit: usize, diff --git a/src/parse/guess_language.rs b/src/parse/guess_language.rs index 23c3eec2cf..a82831144d 100644 --- a/src/parse/guess_language.rs +++ b/src/parse/guess_language.rs @@ -120,7 +120,7 @@ pub fn language_name(language: Language) -> &'static str { } } -pub const LANG_EXTENSIONS: &'static [(Language, &[&str])] = &[ +pub const LANG_EXTENSIONS: &[(Language, &[&str])] = &[ ( Bash, &[ diff --git a/src/parse/syntax.rs b/src/parse/syntax.rs index bc5f8d7fc2..b1829fbeb8 100644 --- a/src/parse/syntax.rs +++ b/src/parse/syntax.rs @@ -246,7 +246,7 @@ impl<'a> Syntax<'a> { ) -> &'a Syntax<'a> { // If a parser hasn't cleaned up \r on CRLF files with // comments, discard it. - if content.ends_with("\r") { + if content.ends_with('\r') { content = &content[..content.len() - 1]; }