summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorclnoll <clnoll@users.noreply.github.com>2022-11-13 23:54:39 +0000
committerGitHub <noreply@github.com>2022-11-13 18:54:39 -0500
commit6b2d0b7fc8b3e5017f8407c09100e4b54ed65091 (patch)
tree9405ff16089aa9af4fc5f19d016fe9b49b2985ae
parent5ce2efbc6b7355a6e3da7b3b2c85d6deaa0d0d46 (diff)
Fix clippy warnings (#1236)
-rw-r--r--src/features/line_numbers.rs4
-rw-r--r--src/handlers/blame.rs2
-rw-r--r--src/handlers/diff_header.rs10
-rw-r--r--src/handlers/grep.rs2
-rw-r--r--src/subcommands/diff.rs2
-rw-r--r--src/subcommands/list_syntax_themes.rs6
-rw-r--r--src/utils/path.rs2
7 files changed, 13 insertions, 15 deletions
diff --git a/src/features/line_numbers.rs b/src/features/line_numbers.rs
index 88850434..d9ab7948 100644
--- a/src/features/line_numbers.rs
+++ b/src/features/line_numbers.rs
@@ -167,12 +167,12 @@ impl<'a> LineNumbersData<'a> {
format_data: MinusPlus::new(
format::parse_line_number_format(
&format[Left],
- &*LINE_NUMBERS_PLACEHOLDER_REGEX,
+ &LINE_NUMBERS_PLACEHOLDER_REGEX,
false,
),
format::parse_line_number_format(
&format[Right],
- &*LINE_NUMBERS_PLACEHOLDER_REGEX,
+ &LINE_NUMBERS_PLACEHOLDER_REGEX,
insert_center_space_on_odd_width,
),
),
diff --git a/src/handlers/blame.rs b/src/handlers/blame.rs
index 0e21f6bc..a1ec97b8 100644
--- a/src/handlers/blame.rs
+++ b/src/handlers/blame.rs
@@ -43,7 +43,7 @@ impl<'a> StateMachine<'a> {
// Format blame metadata
let format_data = format::parse_line_number_format(
&self.config.blame_format,
- &*BLAME_PLACEHOLDER_REGEX,
+ &BLAME_PLACEHOLDER_REGEX,
false,
);
let mut formatted_blame_metadata =
diff --git a/src/handlers/diff_header.rs b/src/handlers/diff_header.rs
index 5038efd5..75763b82 100644
--- a/src/handlers/diff_header.rs
+++ b/src/handlers/diff_header.rs
@@ -88,7 +88,7 @@ impl<'a> StateMachine<'a> {
parse_diff_header_line(&self.line, self.source == Source::GitDiff);
self.minus_file = utils::path::relativize_path_maybe(&path_or_mode, self.config)
- .map(|p| p.to_string_lossy().to_owned().to_string())
+ .map(|p| p.to_string_lossy().into_owned())
.unwrap_or(path_or_mode);
self.minus_file_event = file_event;
@@ -125,7 +125,7 @@ impl<'a> StateMachine<'a> {
parse_diff_header_line(&self.line, self.source == Source::GitDiff);
self.plus_file = utils::path::relativize_path_maybe(&path_or_mode, self.config)
- .map(|p| p.to_string_lossy().to_owned().to_string())
+ .map(|p| p.to_string_lossy().into_owned())
.unwrap_or(path_or_mode);
self.plus_file_event = file_event;
self.painter
@@ -162,8 +162,7 @@ impl<'a> StateMachine<'a> {
let mut handled_line = false;
let (_mode_info, file_event) =
parse_diff_header_line(&self.line, self.source == Source::GitDiff);
- let name = get_repeated_file_path_from_diff_line(&self.diff_line)
- .unwrap_or_else(|| "".to_string());
+ let name = get_repeated_file_path_from_diff_line(&self.diff_line).unwrap_or_default();
match file_event {
FileEvent::Removed => {
self.minus_file = name;
@@ -242,8 +241,7 @@ impl<'a> StateMachine<'a> {
_ => Cow::from(file),
};
let label = format_label(&self.config.file_modified_label);
- let name = get_repeated_file_path_from_diff_line(&self.diff_line)
- .unwrap_or_else(|| "".to_string());
+ let name = get_repeated_file_path_from_diff_line(&self.diff_line).unwrap_or_default();
let line = format!("{}{}", label, format_file(&name));
write_generic_diff_header_header_line(
&line,
diff --git a/src/handlers/grep.rs b/src/handlers/grep.rs
index 986de386..2eadd1f3 100644
--- a/src/handlers/grep.rs
+++ b/src/handlers/grep.rs
@@ -439,7 +439,7 @@ pub fn parse_grep_line(line: &str) -> Option<GrepLine> {
&*GREP_LINE_REGEX_ASSUMING_NO_INTERNAL_SEPARATOR_CHARS,
]
.iter()
- .find_map(|regex| _parse_grep_line(*regex, line)),
+ .find_map(|regex| _parse_grep_line(regex, line)),
_ => None,
}
}
diff --git a/src/subcommands/diff.rs b/src/subcommands/diff.rs
index 6c7fbf00..30d4e64b 100644
--- a/src/subcommands/diff.rs
+++ b/src/subcommands/diff.rs
@@ -40,7 +40,7 @@ pub fn diff(
let diff_process = process::Command::new(diff_path)
.args(&diff_cmd[1..])
- .args(&[minus_file, plus_file])
+ .args([minus_file, plus_file])
.stdout(process::Stdio::piped())
.spawn();
diff --git a/src/subcommands/list_syntax_themes.rs b/src/subcommands/list_syntax_themes.rs
index 34a7b0b4..e8bdc319 100644
--- a/src/subcommands/list_syntax_themes.rs
+++ b/src/subcommands/list_syntax_themes.rs
@@ -19,11 +19,11 @@ pub fn _list_syntax_themes_for_humans(writer: &mut dyn Write) -> std::io::Result
let assets = utils::bat::assets::load_highlighting_assets();
writeln!(writer, "Light syntax themes:")?;
- for theme in assets.themes().filter(|t| is_light_syntax_theme(*t)) {
+ for theme in assets.themes().filter(|t| is_light_syntax_theme(t)) {
writeln!(writer, " {}", theme)?;
}
writeln!(writer, "\nDark syntax themes:")?;
- for theme in assets.themes().filter(|t| !is_light_syntax_theme(*t)) {
+ for theme in assets.themes().filter(|t| !is_light_syntax_theme(t)) {
writeln!(writer, " {}", theme)?;
}
writeln!(
@@ -35,7 +35,7 @@ pub fn _list_syntax_themes_for_humans(writer: &mut dyn Write) -> std::io::Result
pub fn _list_syntax_themes_for_machines(writer: &mut dyn Write) -> std::io::Result<()> {
let assets = utils::bat::assets::load_highlighting_assets();
- for theme in assets.themes().sorted_by_key(|t| is_light_syntax_theme(*t)) {
+ for theme in assets.themes().sorted_by_key(|t| is_light_syntax_theme(t)) {
writeln!(
writer,
"{}\t{}",
diff --git a/src/utils/path.rs b/src/utils/path.rs
index 6891e81a..524ef910 100644
--- a/src/utils/path.rs
+++ b/src/utils/path.rs
@@ -29,7 +29,7 @@ pub fn absolute_path(relative_path: &str, config: &Config) -> Option<PathBuf> {
pub fn relativize_path_maybe(path: &str, config: &Config) -> Option<PathBuf> {
if config.relative_paths && !calling_process().paths_in_input_are_relative_to_cwd() {
if let Some(base) = config.cwd_relative_to_repo_root.as_deref() {
- pathdiff::diff_paths(&path, base)
+ pathdiff::diff_paths(path, base)
} else {
None
}