summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormliszcz <liszcz.michal@gmail.com>2022-08-16 13:41:06 +0200
committerDan Davison <dandavison7@gmail.com>2022-08-16 18:17:10 -0400
commitb99e6c5d9c9c099d9c97f59e6e27a2f1ba53d863 (patch)
treedef4d1d845387e9147f274d58863824a5988c395
parent6d96b78502d0fd41bd0a30dd2826723aaed18e96 (diff)
Fix clippy warnings after rust 1.63 upgrade
Following fixes are included: * derive_partial_eq_without_eq: Eq trait was added by running `cargo clippy --fix --no-deps`. * get_first: Function was replaced by running `cargo clippy --fix --no-deps`. * unnecessary_to_owned: This check was disabled for ANSIString as to_string call is required to enforce formatting. Otherwise the underlying string was returned directly (probably due to Deref implementation). * type_complexity: Closure type was simplified and Box<> usage was removed.
-rw-r--r--src/align.rs2
-rw-r--r--src/ansi/iterator.rs2
-rw-r--r--src/cli.rs4
-rw-r--r--src/delta.rs10
-rw-r--r--src/features/side_by_side.rs1
-rw-r--r--src/format.rs6
-rw-r--r--src/git_config/git_config_entry.rs2
-rw-r--r--src/handlers/diff_header.rs2
-rw-r--r--src/handlers/draw.rs11
-rw-r--r--src/handlers/grep.rs4
-rw-r--r--src/handlers/hunk_header.rs2
-rw-r--r--src/handlers/merge_conflict.rs2
-rw-r--r--src/paint.rs6
-rw-r--r--src/utils/bat/output.rs2
-rw-r--r--src/utils/process.rs6
15 files changed, 32 insertions, 30 deletions
diff --git a/src/align.rs b/src/align.rs
index 6da05cc1..92262cb1 100644
--- a/src/align.rs
+++ b/src/align.rs
@@ -5,7 +5,7 @@ const SUBSTITUTION_COST: usize = 1;
const DELETION_COST: usize = 1;
const INSERTION_COST: usize = 1;
-#[derive(Clone, Copy, Debug, PartialEq)]
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Operation {
NoOp,
Substitution,
diff --git a/src/ansi/iterator.rs b/src/ansi/iterator.rs
index 18309525..f9952162 100644
--- a/src/ansi/iterator.rs
+++ b/src/ansi/iterator.rs
@@ -129,7 +129,7 @@ impl vte::Perform for Performer {
return;
}
- if let ('m', None) = (c, intermediates.get(0)) {
+ if let ('m', None) = (c, intermediates.first()) {
if params.is_empty() {
// Attr::Reset
// Probably doesn't need to be handled: https://github.com/dandavison/delta/pull/431#discussion_r536883568
diff --git a/src/cli.rs b/src/cli.rs
index ead9b2e2..4e5e8815 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -1102,7 +1102,7 @@ pub struct ComputedValues {
pub true_color: bool,
}
-#[derive(Clone, Debug, PartialEq)]
+#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Width {
Fixed(usize),
Variable,
@@ -1114,7 +1114,7 @@ impl Default for Width {
}
}
-#[derive(Clone, Debug, PartialEq)]
+#[derive(Clone, Debug, PartialEq, Eq)]
pub enum InspectRawLines {
True,
False,
diff --git a/src/delta.rs b/src/delta.rs
index 5cda5266..741d3c63 100644
--- a/src/delta.rs
+++ b/src/delta.rs
@@ -15,7 +15,7 @@ use crate::paint::Painter;
use crate::style::DecorationStyle;
use crate::utils;
-#[derive(Clone, Debug, PartialEq)]
+#[derive(Clone, Debug, PartialEq, Eq)]
pub enum State {
CommitMeta, // In commit metadata section
DiffHeader(DiffType), // In diff metadata section, between (possible) commit metadata and first hunk
@@ -36,21 +36,21 @@ pub enum State {
HunkPlusWrapped, // Wrapped added line
}
-#[derive(Clone, Debug, PartialEq)]
+#[derive(Clone, Debug, PartialEq, Eq)]
pub enum DiffType {
Unified,
// https://git-scm.com/docs/git-diff#_combined_diff_format
Combined(MergeParents, InMergeConflict),
}
-#[derive(Clone, Debug, PartialEq)]
+#[derive(Clone, Debug, PartialEq, Eq)]
pub enum MergeParents {
Number(usize), // Number of parent commits == (number of @s in hunk header) - 1
Prefix(String), // Hunk line prefix, length == number of parent commits
Unknown,
}
-#[derive(Clone, Debug, PartialEq)]
+#[derive(Clone, Debug, PartialEq, Eq)]
pub enum InMergeConflict {
Yes,
No,
@@ -69,7 +69,7 @@ impl DiffType {
}
}
-#[derive(Debug, PartialEq)]
+#[derive(Debug, PartialEq, Eq)]
pub enum Source {
GitDiff, // Coming from a `git diff` command
DiffUnified, // Coming from a `diff -u` command
diff --git a/src/features/side_by_side.rs b/src/features/side_by_side.rs
index e23ae21f..f175fa2a 100644
--- a/src/features/side_by_side.rs
+++ b/src/features/side_by_side.rs
@@ -526,6 +526,7 @@ fn pad_panel_line_to_width<'a>(
}
Some(BgFillMethod::Spaces) if text_width >= panel_width => (),
Some(BgFillMethod::Spaces) => panel_line.push_str(
+ #[allow(clippy::unnecessary_to_owned)]
&fill_style
.paint(" ".repeat(panel_width - text_width))
.to_string(),
diff --git a/src/format.rs b/src/format.rs
index 07cb39f7..d40e417f 100644
--- a/src/format.rs
+++ b/src/format.rs
@@ -6,7 +6,7 @@ use unicode_segmentation::UnicodeSegmentation;
use crate::features::side_by_side::ansifill::ODD_PAD_CHAR;
-#[derive(Debug, PartialEq)]
+#[derive(Debug, PartialEq, Eq)]
pub enum Placeholder<'a> {
NumberMinus,
NumberPlus,
@@ -25,7 +25,7 @@ impl<'a> TryFrom<Option<&'a str>> for Placeholder<'a> {
}
}
-#[derive(Debug, Copy, Clone, PartialEq)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum Align {
Left,
Center,
@@ -48,7 +48,7 @@ impl TryFrom<Option<&str>> for Align {
}
}
-#[derive(Debug, PartialEq, Clone)]
+#[derive(Debug, PartialEq, Eq, Clone)]
pub struct FormatStringPlaceholderDataAnyPlaceholder<T> {
pub prefix: SmolStr,
pub prefix_len: usize,
diff --git a/src/git_config/git_config_entry.rs b/src/git_config/git_config_entry.rs
index ff5670a5..66a9f840 100644
--- a/src/git_config/git_config_entry.rs
+++ b/src/git_config/git_config_entry.rs
@@ -12,7 +12,7 @@ pub enum GitConfigEntry {
GitRemote(GitRemoteRepo),
}
-#[derive(Clone, Debug, PartialEq)]
+#[derive(Clone, Debug, PartialEq, Eq)]
pub enum GitRemoteRepo {
GitHubRepo { repo_slug: String },
GitLabRepo { repo_slug: String },
diff --git a/src/handlers/diff_header.rs b/src/handlers/diff_header.rs
index 39262c1b..5038efd5 100644
--- a/src/handlers/diff_header.rs
+++ b/src/handlers/diff_header.rs
@@ -12,7 +12,7 @@ use crate::{features, utils};
// https://git-scm.com/docs/git-config#Documentation/git-config.txt-diffmnemonicPrefix
const DIFF_PREFIXES: [&str; 6] = ["a/", "b/", "c/", "i/", "o/", "w/"];
-#[derive(Debug, PartialEq)]
+#[derive(Debug, PartialEq, Eq)]
pub enum FileEvent {
Added,
Change,
diff --git a/src/handlers/draw.rs b/src/handlers/draw.rs
index c1eb2236..d73a31fc 100644
--- a/src/handlers/draw.rs
+++ b/src/handlers/draw.rs
@@ -223,12 +223,11 @@ fn _write_under_or_over_lined(
Width::Fixed(n) => max(n, text_width),
Width::Variable => text_width,
};
- let mut write_line: Box<dyn FnMut(&mut dyn Write) -> std::io::Result<()>> =
- Box::new(|writer| {
- write_horizontal_line(writer, line_width, text_style, decoration_style)?;
- writeln!(writer)?;
- Ok(())
- });
+ let write_line = |writer: &mut dyn Write| -> std::io::Result<()> {
+ write_horizontal_line(writer, line_width, text_style, decoration_style)?;
+ writeln!(writer)?;
+ Ok(())
+ };
match underoverline {
UnderOverline::Under => {}
_ => write_line(writer)?,
diff --git a/src/handlers/grep.rs b/src/handlers/grep.rs
index 88e4130a..986de386 100644
--- a/src/handlers/grep.rs
+++ b/src/handlers/grep.rs
@@ -12,7 +12,7 @@ use crate::paint::{self, expand_tabs, BgShouldFill, StyleSectionSpecifier};
use crate::style::Style;
use crate::utils::process;
-#[derive(Debug, PartialEq)]
+#[derive(Debug, PartialEq, Eq)]
pub struct GrepLine<'b> {
pub path: Cow<'b, str>,
pub line_number: Option<usize>,
@@ -21,7 +21,7 @@ pub struct GrepLine<'b> {
pub submatches: Option<Vec<(usize, usize)>>,
}
-#[derive(Clone, Copy, Debug, PartialEq, Deserialize)]
+#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum LineType {
ContextHeader,
diff --git a/src/handlers/hunk_header.rs b/src/handlers/hunk_header.rs
index 7a9e2a1c..add903d6 100644
--- a/src/handlers/hunk_header.rs
+++ b/src/handlers/hunk_header.rs
@@ -30,7 +30,7 @@ use crate::delta::{self, DiffType, InMergeConflict, MergeParents, State, StateMa
use crate::paint::{self, BgShouldFill, Painter, StyleSectionSpecifier};
use crate::style::DecorationStyle;
-#[derive(Clone, Default, Debug, PartialEq)]
+#[derive(Clone, Default, Debug, PartialEq, Eq)]
pub struct ParsedHunkHeader {
code_fragment: String,
line_numbers_and_hunk_lengths: Vec<(usize, usize)>,
diff --git a/src/handlers/merge_conflict.rs b/src/handlers/merge_conflict.rs
index 31cb2bda..d7c4524d 100644
--- a/src/handlers/merge_conflict.rs
+++ b/src/handlers/merge_conflict.rs
@@ -11,7 +11,7 @@ use crate::minusplus::MinusPlus;
use crate::paint::{self, prepare};
use crate::style::Style;
-#[derive(Clone, Debug, PartialEq)]
+#[derive(Clone, Debug, PartialEq, Eq)]
pub enum MergeConflictCommit {
Ours,
Ancestral,
diff --git a/src/paint.rs b/src/paint.rs
index 8da56cda..3ad20f24 100644
--- a/src/paint.rs
+++ b/src/paint.rs
@@ -41,7 +41,7 @@ pub struct Painter<'p> {
}
// How the background of a line is filled up to the end
-#[derive(Debug, PartialEq, Clone, Copy)]
+#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum BgFillMethod {
// Fill the background with ANSI spaces if possible,
// but might fallback to Spaces (e.g. in the left side-by-side panel),
@@ -51,7 +51,7 @@ pub enum BgFillMethod {
}
// If the background of a line extends to the end, and if configured to do so, how.
-#[derive(Debug, PartialEq, Clone, Copy)]
+#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum BgShouldFill {
With(BgFillMethod),
No,
@@ -230,6 +230,7 @@ impl<'p> Painter<'p> {
} else if let Some(BgFillMethod::Spaces) = bg_fill_mode {
let text_width = ansi::measure_text_width(&line);
line.push_str(
+ #[allow(clippy::unnecessary_to_owned)]
&fill_style
.paint(" ".repeat(config.available_terminal_width - text_width))
.to_string(),
@@ -363,6 +364,7 @@ impl<'p> Painter<'p> {
/// current buffer position.
pub fn mark_empty_line(empty_line_style: &Style, line: &mut String, marker: Option<&str>) {
line.push_str(
+ #[allow(clippy::unnecessary_to_owned)]
&empty_line_style
.paint(marker.unwrap_or(ansi::ANSI_CSI_CLEAR_TO_BOL))
.to_string(),
diff --git a/src/utils/bat/output.rs b/src/utils/bat/output.rs
index 22697d4d..c3ee6a89 100644
--- a/src/utils/bat/output.rs
+++ b/src/utils/bat/output.rs
@@ -13,7 +13,7 @@ use crate::env::DeltaEnv;
use crate::fatal;
use crate::features::navigate;
-#[derive(Debug, Clone, Copy, PartialEq)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[allow(dead_code)]
pub enum PagingMode {
Always,
diff --git a/src/utils/process.rs b/src/utils/process.rs
index 0e7eced3..1f24aa02 100644
--- a/src/utils/process.rs
+++ b/src/utils/process.rs
@@ -7,7 +7,7 @@ use sysinfo::{Pid, PidExt, Process, ProcessExt, ProcessRefreshKind, SystemExt};
pub type DeltaPid = u32;
-#[derive(Clone, Debug, PartialEq)]
+#[derive(Clone, Debug, PartialEq, Eq)]
pub enum CallingProcess {
GitDiff(CommandLine),
GitShow(CommandLine, Option<String>), // element 2 is file extension
@@ -32,7 +32,7 @@ impl CallingProcess {
}
}
-#[derive(Clone, Debug, PartialEq)]
+#[derive(Clone, Debug, PartialEq, Eq)]
pub struct CommandLine {
pub long_options: HashSet<String>,
pub short_options: HashSet<String>,
@@ -100,7 +100,7 @@ fn determine_calling_process() -> CallingProcess {
// Return value of `extract_args(args: &[String]) -> ProcessArgs<T>` function which is
// passed to `calling_process_cmdline()`.
-#[derive(Debug, PartialEq)]
+#[derive(Debug, PartialEq, Eq)]
pub enum ProcessArgs<T> {
// A result has been successfully extracted from args.
Args(T),