Skip to content

Fix clippy::needless_borrow #271

New issue

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

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

Already on GitHub? # to your account

Merged
merged 1 commit into from
Sep 29, 2024
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
2 changes: 1 addition & 1 deletion sys/ps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ fn main() {

// Print the header
for field in &output_fields {
let header = posix_fields.get(*field).unwrap_or(&field);
let header = posix_fields.get(*field).unwrap_or(field);
print!("{:<10} ", header);
}
println!();
Expand Down
2 changes: 1 addition & 1 deletion text/diff_util/dir_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ impl DirData {
}

pub fn path_str(&self) -> &str {
&self.path.to_str().unwrap_or(COULD_NOT_UNWRAP_FILENAME)
self.path.to_str().unwrap_or(COULD_NOT_UNWRAP_FILENAME)
}
}
10 changes: 5 additions & 5 deletions text/diff_util/dir_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl<'a> DirDiff<'a> {
let mut dir1: DirData = DirData::load(PathBuf::from(path1))?;
let mut dir2: DirData = DirData::load(PathBuf::from(path2))?;

let mut dir_diff = DirDiff::new(&mut dir1, &mut dir2, &format_options, recursive);
let mut dir_diff = DirDiff::new(&mut dir1, &mut dir2, format_options, recursive);
return dir_diff.analyze();
}

Expand Down Expand Up @@ -177,13 +177,13 @@ impl<'a> DirDiff<'a> {
} else {
let (file, dir) = if in_dir1_is_file && !in_dir2_is_file {
(
path1.to_str().unwrap_or(&COULD_NOT_UNWRAP_FILENAME),
path2.to_str().unwrap_or(&COULD_NOT_UNWRAP_FILENAME),
path1.to_str().unwrap_or(COULD_NOT_UNWRAP_FILENAME),
path2.to_str().unwrap_or(COULD_NOT_UNWRAP_FILENAME),
)
} else {
(
path2.to_str().unwrap_or(&COULD_NOT_UNWRAP_FILENAME),
path1.to_str().unwrap_or(&COULD_NOT_UNWRAP_FILENAME),
path2.to_str().unwrap_or(COULD_NOT_UNWRAP_FILENAME),
path1.to_str().unwrap_or(COULD_NOT_UNWRAP_FILENAME),
)
};

Expand Down
2 changes: 1 addition & 1 deletion text/diff_util/file_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,6 @@ impl FileData {
}

pub fn path(&self) -> &str {
self.path.to_str().unwrap_or(&COULD_NOT_UNWRAP_FILENAME)
self.path.to_str().unwrap_or(COULD_NOT_UNWRAP_FILENAME)
}
}
22 changes: 11 additions & 11 deletions text/diff_util/file_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl<'a> FileDiff<'a> {

if path1_file_type.is_file() {
let path1_file = path1.clone();
let path1_file = path1_file.file_name().expect(&COULD_NOT_UNWRAP_FILENAME);
let path1_file = path1_file.file_name().expect(COULD_NOT_UNWRAP_FILENAME);
let path2 = path2.join(path1_file);

if !check_existance(&path2)? {
Expand All @@ -98,7 +98,7 @@ impl<'a> FileDiff<'a> {
return FileDiff::file_diff(path1, path2, format_options, None);
} else {
let path2_file = path2.clone();
let path2_file = path2_file.file_name().expect(&COULD_NOT_UNWRAP_FILENAME);
let path2_file = path2_file.file_name().expect(COULD_NOT_UNWRAP_FILENAME);
let path1 = path1.join(path2_file);

if !check_existance(&path1)? {
Expand Down Expand Up @@ -151,22 +151,22 @@ impl<'a> FileDiff<'a> {
for hunk_index in 0..hunks_count {
let hunk = self.hunks.hunk_at_mut(hunk_index);
match self.format_options.output_format {
OutputFormat::Debug => hunk.print_debug(&self.file1, &self.file2),
OutputFormat::Debug => hunk.print_debug(self.file1, self.file2),
OutputFormat::Default => {
hunk.print_default(&self.file1, &self.file2, hunk_index == hunks_count - 1)
hunk.print_default(self.file1, self.file2, hunk_index == hunks_count - 1)
}
OutputFormat::EditScript => hunk.print_edit_script(
&self.file1,
&self.file2,
self.file1,
self.file2,
hunk_index == hunks_count - 1,
),
OutputFormat::Context(_) => {
eprintln!("OutputFormat::Context should be handled in other place");
return Ok(DiffExitStatus::Trouble);
}
OutputFormat::ForwardEditScript => hunk.print_forward_edit_script(
&self.file1,
&self.file2,
self.file1,
self.file2,
hunk_index == hunks_count - 1,
),
OutputFormat::Unified(_) => {
Expand Down Expand Up @@ -209,7 +209,7 @@ impl<'a> FileDiff<'a> {

for i in 1..=n {
for j in 1..=m {
let cost = if self.compare_lines(&self.file1.line(i - 1), &self.file2.line(j - 1)) {
let cost = if self.compare_lines(self.file1.line(i - 1), self.file2.line(j - 1)) {
if !file1_considered_lines.contains(&i) && !file2_considered_lines.contains(&j)
{
file1_considered_lines.push(i);
Expand Down Expand Up @@ -242,7 +242,7 @@ impl<'a> FileDiff<'a> {

i -= 1
} else {
if !self.compare_lines(&self.file1.line(i - 1), &self.file2.line(j - 1)) {
if !self.compare_lines(self.file1.line(i - 1), self.file2.line(j - 1)) {
self.add_change(Change::Substitute(ChangeData::new(i, j)));
}

Expand Down Expand Up @@ -287,7 +287,7 @@ impl<'a> FileDiff<'a> {
.hunks
.hunks()
.iter()
.filter(|hunk| !Change::is_none(&hunk.kind()) && !Change::is_unchanged(&hunk.kind()))
.filter(|hunk| !Change::is_none(hunk.kind()) && !Change::is_unchanged(hunk.kind()))
.map(|hunk| {
(
hunk.ln1_start() as i64,
Expand Down
6 changes: 3 additions & 3 deletions tree/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@ fn process_single_dir(
target_path
};

let entry = Entry::new(target_path, file_name_raw, &metadata, config)
let entry = Entry::new(target_path, file_name_raw, metadata, config)
.map_err(|e| io::Error::other(format!("'{path_str}': {e}")))?;

let mut include_entry = false;
Expand Down Expand Up @@ -1245,7 +1245,7 @@ fn process_single_dir(
}
print_contents(
config,
&current_dir_ref,
current_dir_ref,
&mut entries,
&mut errors,
&exit_code,
Expand All @@ -1270,7 +1270,7 @@ fn process_single_dir(
if dir_parent != current_dir_ref.as_path() {
print_contents(
config,
&current_dir_ref,
current_dir_ref,
&mut entries,
&mut errors,
&exit_code,
Expand Down