Skip to content

clippy: set MSRV and fix warnings #7957

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 4 commits into from
May 19, 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
1 change: 1 addition & 0 deletions .clippy.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
msrv = "1.85.0"
avoid-breaking-exported-api = false
check-private-items = true
cognitive-complexity-threshold = 24
Expand Down
8 changes: 6 additions & 2 deletions src/uu/cp/src/cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1259,13 +1259,17 @@ fn parse_path_args(
return Err("missing file operand".into());
} else if paths.len() == 1 && options.target_dir.is_none() {
// Only one file specified
return Err(format!("missing destination file operand after {:?}", paths[0]).into());
return Err(format!(
"missing destination file operand after {}",
paths[0].display().to_string().quote()
)
.into());
}

// Return an error if the user requested to copy more than one
// file source to a file target
if options.no_target_dir && options.target_dir.is_none() && paths.len() > 2 {
return Err(format!("extra operand {:?}", paths[2]).into());
return Err(format!("extra operand {:}", paths[2].display().to_string().quote()).into());
}

let target = match options.target_dir {
Expand Down
7 changes: 6 additions & 1 deletion src/uu/cp/src/platform/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ pub(crate) fn copy_on_write(
// support COW).
match reflink_mode {
ReflinkMode::Always => {
return Err(format!("failed to clone {source:?} from {dest:?}: {error}").into());
return Err(format!(
"failed to clone {} from {}: {error}",
source.display(),
dest.display()
)
.into());
}
_ => {
copy_debug.reflink = OffloadReflinkDebug::Yes;
Expand Down
5 changes: 2 additions & 3 deletions src/uu/more/src/more.rs
Original file line number Diff line number Diff line change
Expand Up @@ -900,16 +900,15 @@ mod tests {
if let Some(rows) = self.options.lines {
self.rows = rows;
}
let pager = Pager::new(
Pager::new(
InputType::File(BufReader::new(tmpfile)),
self.rows,
None,
self.next_file,
&self.options,
out,
)
.unwrap();
pager
.unwrap()
}

fn silent(mut self) -> Self {
Expand Down
2 changes: 1 addition & 1 deletion src/uu/mv/src/mv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ fn rename_dir_fallback(
io::ErrorKind::PermissionDenied,
"Permission denied",
)),
_ => Err(io::Error::new(io::ErrorKind::Other, format!("{err:?}"))),
_ => Err(io::Error::other(format!("{err:?}"))),
},
_ => Ok(()),
}
Expand Down
15 changes: 7 additions & 8 deletions tests/by-util/test_cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.

// spell-checker:ignore (flags) reflink (fs) tmpfs (linux) rlimit Rlim NOFILE clob btrfs neve ROOTDIR USERDIR procfs outfile uufs xattrs
// spell-checker:ignore bdfl hlsl IRWXO IRWXG nconfined matchpathcon libselinux-devel
use uutests::at_and_ucmd;
use uutests::new_ucmd;
use uutests::path_concat;
use uucore::display::Quotable;
use uutests::util::TestScenario;
use uutests::util_name;
use uutests::{at_and_ucmd, new_ucmd, path_concat, util_name};

#[cfg(not(windows))]
use std::fs::set_permissions;
Expand Down Expand Up @@ -3946,10 +3945,10 @@ fn test_cp_only_source_no_target() {
let ts = TestScenario::new(util_name!());
let at = &ts.fixtures;
at.touch("a");
ts.ucmd()
.arg("a")
.fails()
.stderr_contains("missing destination file operand after \"a\"");
ts.ucmd().arg("a").fails().stderr_contains(format!(
"missing destination file operand after {}",
"a".quote()
));
}

#[test]
Expand Down
Loading