8000 clippy: fix warnings from Rust 1.86 by cakebaker · Pull Request #522 · uutils/findutils · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

clippy: fix warnings from Rust 1.86 #522

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

Merged
merged 2 commits into from
Apr 4, 2025
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 src/find/matchers/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ impl WalkEntry {
Entry::Explicit(path, _) => {
// Path::file_name() only works if the last component is normal
path.components()
.last()
.next_back()
.map(|c| c.as_os_str())
.unwrap_or_else(|| path.as_os_str())
}
Expand Down
2 changes: 1 addition & 1 deletion src/find/matchers/printf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@
// even though it's arguably not 100% correct.
if *large_blocks {
// Ceiling divide in half.
(blocks + 1) / 2
blocks.div_ceil(2)

Check warning on line 404 in src/find/matchers/printf.rs

View check run for this annotation

Codecov / codecov/patch

src/find/matchers/printf.rs#L404

Added line #L404 was not covered by tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might as well make the same fix right above:

let blocks = (meta()?.len() + STANDARD_BLOCK_SIZE - 1) / STANDARD_BLOCK_SIZE;

Side note: I think the code here is wrong, but that can be fixed in a different PR. It should be more like

let blocks = meta()?.blocks();
let len = blocks * STANDARD_BLOCK_SIZE;
let bs = if *large_blocks { 1024 } else { 512 };
blocks.div_ceil(len, bs)

} else {
blocks
}
Expand Down
8000
12 changes: 7 additions & 5 deletions src/xargs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -799,11 +799,13 @@ fn normalize_options<'a>(
);
let lines_index = matches
.indices_of(options::MAX_LINES)
.and_then(|v| v.last());
let args_index = matches.indices_of(options::MAX_ARGS).and_then(|v| v.last());
.and_then(|mut v| v.next_back());
let args_index = matches
.indices_of(options::MAX_ARGS)
.and_then(|mut v| v.next_back());
let replace_index = [options::REPLACE, options::REPLACE_I]
.iter()
.flat_map(|o| matches.indices_of(o).and_then(|v| v.last()))
.flat_map(|o| matches.indices_of(o).and_then(|mut v| v.next_back()))
.max();
if lines_index > args_index && lines_index > replace_index {
(None, options.max_lines, &None)
Expand All @@ -817,8 +819,8 @@ fn normalize_options<'a>(

let delimiter = match (options.delimiter, options.null) {
(Some(delimiter), true) => {
if matches.indices_of(options::NULL).unwrap().last()
> matches.indices_of(options::DELIMITER).unwrap().last()
if matches.indices_of(options::NULL).unwrap().next_back()
> matches.indices_of(options::DELIMITER).unwrap().next_back()
{
Some(b'\0')
} else {
Expand Down
Loading
0