Skip to content

Commit

Permalink
clippy (#1686)
Browse files Browse the repository at this point in the history
  • Loading branch information
dandavison committed May 4, 2024
1 parent 711353b commit d995bf7
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/delta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl<'a> StateMachine<'a> {
self.config.max_line_length,
);
self.raw_line = raw_line[..truncated_len].to_string();
self.line = self.raw_line.clone();
self.line.clone_from(&self.raw_line);
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/handlers/diff_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ impl<'a> StateMachine<'a> {
{
self.painter.emit()?;
self._handle_diff_header_header_line(self.source == Source::DiffUnified)?;
self.handled_diff_header_header_line_file_pair = self.current_file_pair.clone();
self.handled_diff_header_header_line_file_pair
.clone_from(&self.current_file_pair);
}
Ok(handled_line)
}
Expand Down Expand Up @@ -255,7 +256,8 @@ impl<'a> StateMachine<'a> {
&& self.handled_diff_header_header_line_file_pair != self.current_file_pair
{
self._handle_diff_header_header_line(self.source == Source::DiffUnified)?;
self.handled_diff_header_header_line_file_pair = self.current_file_pair.clone();
self.handled_diff_header_header_line_file_pair
.clone_from(&self.current_file_pair);
Ok(())
} else {
Ok(())
Expand Down
6 changes: 3 additions & 3 deletions src/handlers/diff_header_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ impl<'a> StateMachine<'a> {
};
self.handle_pending_line_with_diff_name()?;
self.handled_diff_header_header_line_file_pair = None;
self.diff_line = self.line.clone();
self.diff_line.clone_from(&self.line);

// Pre-fill header fields from the diff line. For added, removed or renamed files
// these are updated precisely on actual header minus and header plus lines.
// But for modified binary files which are not added, removed or renamed, there
// are no minus and plus lines. Without the code below, in such cases the file names
// would remain unchanged from the previous diff, or empty for the very first diff.
let name = get_repeated_file_path_from_diff_line(&self.line).unwrap_or_default();
self.minus_file = name.clone();
self.plus_file = name.clone();
self.minus_file.clone_from(&name);
self.plus_file.clone_from(&name);
self.minus_file_event = FileEvent::Change;
self.plus_file_event = FileEvent::Change;
self.current_file_pair = Some((self.minus_file.clone(), self.plus_file.clone()));
Expand Down
3 changes: 2 additions & 1 deletion src/handlers/diff_header_misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ impl<'a> StateMachine<'a> {
// This can happen in output of standalone diff or git diff --no-index.
if self.minus_file.is_empty() && self.plus_file.is_empty() {
self.emit_line_unchanged()?;
self.handled_diff_header_header_line_file_pair = self.current_file_pair.clone();
self.handled_diff_header_header_line_file_pair
.clone_from(&self.current_file_pair);
return Ok(true);
}

Expand Down
4 changes: 2 additions & 2 deletions src/options/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub fn set_options(
}
opt.navigate = opt.navigate || opt.env.navigate.is_some();
if opt.syntax_theme.is_none() {
opt.syntax_theme = opt.env.bat_theme.clone();
opt.syntax_theme.clone_from(&opt.env.bat_theme);
}

let option_names = cli::Opt::get_argument_and_option_names();
Expand Down Expand Up @@ -632,7 +632,7 @@ fn set_true_color(opt: &mut cli::Opt) {
// It's equal to its default, so the user might be using the deprecated
// --24-bit-color option.
if let Some(_24_bit_color) = opt._24_bit_color.as_ref() {
opt.true_color = _24_bit_color.clone();
opt.true_color.clone_from(_24_bit_color);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/options/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ fn detect_light_mode() -> bool {
#[cfg(test)]
pub(crate) mod test_utils {
thread_local! {
pub(super) static DETECT_LIGHT_MODE_OVERRIDE: std::cell::Cell<Option<bool>> = std::cell::Cell::new(None);
pub(super) static DETECT_LIGHT_MODE_OVERRIDE: std::cell::Cell<Option<bool>> = const { std::cell::Cell::new(None) };
}

pub(crate) struct DetectLightModeOverride {
Expand Down
2 changes: 1 addition & 1 deletion src/tests/ansi_test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ pub mod ansi_test_utils {
config: &Config,
) {
assert!(
filename_for_highlighting.contains("."),
filename_for_highlighting.contains('.'),
"expecting filename, not just a file extension"
);
let line = output.lines().nth(line_number).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion src/utils/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ pub mod tests {
use std::rc::Rc;

thread_local! {
static FAKE_ARGS: RefCell<TlsState<Vec<String>>> = RefCell::new(TlsState::None);
static FAKE_ARGS: RefCell<TlsState<Vec<String>>> = const { RefCell::new(TlsState::None) };
}

#[derive(Debug, PartialEq)]
Expand Down

0 comments on commit d995bf7

Please sign in to comment.