Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clippy warnings #1236

Merged
merged 1 commit into from
Nov 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/features/line_numbers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
),
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/blame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
10 changes: 4 additions & 6 deletions src/handlers/diff_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/grep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/subcommands/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
6 changes: 3 additions & 3 deletions src/subcommands/list_syntax_themes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand All @@ -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{}",
Expand Down
2 changes: 1 addition & 1 deletion src/utils/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down