Skip to content
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
26 changes: 13 additions & 13 deletions src/bin/uudoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fn main() -> io::Result<()> {
for platform in ["unix", "macos", "windows", "unix_android"] {
let platform_utils: Vec<String> = String::from_utf8(
std::process::Command::new("./util/show-utils.sh")
.arg(format!("--features=feat_os_{}", platform))
.arg(format!("--features=feat_os_{platform}"))
.output()?
.stdout,
)
Expand Down Expand Up @@ -138,7 +138,7 @@ fn main() -> io::Result<()> {
if name == "[" {
continue;
}
let p = format!("docs/src/utils/{}.md", name);
let p = format!("docs/src/utils/{name}.md");

let markdown = File::open(format!("src/uu/{name}/{name}.md"))
.and_then(|mut f: File| {
Expand All @@ -158,11 +158,11 @@ fn main() -> io::Result<()> {
markdown,
}
.markdown()?;
println!("Wrote to '{}'", p);
println!("Wrote to '{p}'");
} else {
println!("Error writing to {}", p);
println!("Error writing to {p}");
}
writeln!(summary, "* [{0}](utils/{0}.md)", name)?;
writeln!(summary, "* [{name}](utils/{name}.md)")?;
}
Ok(())
}
Expand Down Expand Up @@ -214,7 +214,7 @@ impl MDWriter<'_, '_> {
.iter()
.any(|u| u == self.name)
{
writeln!(self.w, "<i class=\"fa fa-brands fa-{}\"></i>", icon)?;
writeln!(self.w, "<i class=\"fa fa-brands fa-{icon}\"></i>")?;
}
}
writeln!(self.w, "</div>")?;
Expand Down Expand Up @@ -242,7 +242,7 @@ impl MDWriter<'_, '_> {
let usage = usage.replace("{}", self.name);

writeln!(self.w, "\n```")?;
writeln!(self.w, "{}", usage)?;
writeln!(self.w, "{usage}")?;
writeln!(self.w, "```")
} else {
Ok(())
Expand Down Expand Up @@ -293,14 +293,14 @@ impl MDWriter<'_, '_> {
writeln!(self.w)?;
for line in content.lines().skip_while(|l| !l.starts_with('-')) {
if let Some(l) = line.strip_prefix("- ") {
writeln!(self.w, "{}", l)?;
writeln!(self.w, "{l}")?;
} else if line.starts_with('`') {
writeln!(self.w, "```shell\n{}\n```", line.trim_matches('`'))?;
} else if line.is_empty() {
writeln!(self.w)?;
} else {
println!("Not sure what to do with this line:");
println!("{}", line);
println!("{line}");
}
}
writeln!(self.w)?;
Expand Down Expand Up @@ -332,14 +332,14 @@ impl MDWriter<'_, '_> {
write!(self.w, ", ")?;
}
write!(self.w, "<code>")?;
write!(self.w, "--{}", l)?;
write!(self.w, "--{l}")?;
if let Some(names) = arg.get_value_names() {
write!(
self.w,
"={}",
names
.iter()
.map(|x| format!("&lt;{}&gt;", x))
.map(|x| format!("&lt;{x}&gt;"))
.collect::<Vec<_>>()
.join(" ")
)?;
Expand All @@ -353,14 +353,14 @@ impl MDWriter<'_, '_> {
write!(self.w, ", ")?;
}
write!(self.w, "<code>")?;
write!(self.w, "-{}", s)?;
write!(self.w, "-{s}")?;
if let Some(names) = arg.get_value_names() {
write!(
self.w,
" {}",
names
.iter()
.map(|x| format!("&lt;{}&gt;", x))
.map(|x| format!("&lt;{x}&gt;"))
.collect::<Vec<_>>()
.join(" ")
)?;
Expand Down
2 changes: 1 addition & 1 deletion src/uu/basename/src/basename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
//

for path in name_args {
print!("{}{}", basename(path, &suffix), line_ending);
print!("{}{line_ending}", basename(path, &suffix));
}

Ok(())
Expand Down
4 changes: 2 additions & 2 deletions src/uu/cat/src/cat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ enum CatError {
#[error("{0}")]
Nix(#[from] nix::Error),
/// Unknown file type; it's not a regular file, socket, etc.
#[error("unknown filetype: {}", ft_debug)]
#[error("unknown filetype: {ft_debug}")]
UnknownFiletype {
/// A debug print of the file type
ft_debug: String,
Expand Down Expand Up @@ -457,7 +457,7 @@ fn cat_files(files: &[String], options: &OutputOptions) -> UResult<()> {

for path in files {
if let Err(err) = cat_path(path, options, &mut state, out_info.as_ref()) {
error_messages.push(format!("{}: {}", path.maybe_quote(), err));
error_messages.push(format!("{}: {err}", path.maybe_quote()));
}
}
if state.skipped_carriage_return {
Expand Down
17 changes: 6 additions & 11 deletions src/uu/chmod/src/chmod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Err(err) => {
return Err(USimpleError::new(
1,
format!("cannot stat attributes of {}: {}", fref.quote(), err),
format!("cannot stat attributes of {}: {err}", fref.quote()),
));
}
},
Expand Down Expand Up @@ -373,7 +373,7 @@ impl Chmoder {
format!("{}: Permission denied", file.quote()),
));
} else {
return Err(USimpleError::new(1, format!("{}: {}", file.quote(), err)));
return Err(USimpleError::new(1, format!("{}: {err}", file.quote())));
}
}
};
Expand Down Expand Up @@ -441,36 +441,31 @@ impl Chmoder {
if fperm == mode {
if self.verbose && !self.changes {
println!(
"mode of {} retained as {:04o} ({})",
"mode of {} retained as {fperm:04o} ({})",
file.quote(),
fperm,
display_permissions_unix(fperm as mode_t, false),
);
}
Ok(())
} else if let Err(err) = fs::set_permissions(file, fs::Permissions::from_mode(mode)) {
if !self.quiet {
show_error!("{}", err);
show_error!("{err}");
}
if self.verbose {
println!(
"failed to change mode of file {} from {:04o} ({}) to {:04o} ({})",
"failed to change mode of file {} from {fperm:04o} ({}) to {mode:04o} ({})",
file.quote(),
fperm,
display_permissions_unix(fperm as mode_t, false),
mode,
display_permissions_unix(mode as mode_t, false)
);
}
Err(1)
} else {
if self.verbose || self.changes {
println!(
"mode of {} changed from {:04o} ({}) to {:04o} ({})",
"mode of {} changed from {fperm:04o} ({}) to {mode:04o} ({})",
file.quote(),
fperm,
display_permissions_unix(fperm as mode_t, false),
mode,
display_permissions_unix(mode as mode_t, false)
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/uu/cp/src/copydir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ pub(crate) fn copy_directory(
}

// Print an error message, but continue traversing the directory.
Err(e) => show_error!("{}", e),
Err(e) => show_error!("{e}"),
}
}

Expand Down
27 changes: 11 additions & 16 deletions src/uu/cp/src/cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,19 @@ quick_error! {
#[derive(Debug)]
pub enum Error {
/// Simple io::Error wrapper
IoErr(err: io::Error) { from() source(err) display("{}", err)}
IoErr(err: io::Error) { from() source(err) display("{err}")}

/// Wrapper for io::Error with path context
IoErrContext(err: io::Error, path: String) {
display("{}: {}", path, err)
display("{path}: {err}")
context(path: &'a str, err: io::Error) -> (err, path.to_owned())
context(context: String, err: io::Error) -> (err, context)
source(err)
}

/// General copy error
Error(err: String) {
display("{}", err)
display("{err}")
from(err: String) -> (err)
from(err: &'static str) -> (err.to_string())
}
Expand All @@ -75,7 +75,7 @@ quick_error! {
NotAllFilesCopied {}

/// Simple walkdir::Error wrapper
WalkDirErr(err: walkdir::Error) { from() display("{}", err) source(err) }
WalkDirErr(err: walkdir::Error) { from() display("{err}") source(err) }

/// Simple std::path::StripPrefixError wrapper
StripPrefixError(err: StripPrefixError) { from() }
Expand All @@ -87,15 +87,15 @@ quick_error! {
Skipped(exit_with_error:bool) { }

/// Result of a skipped file
InvalidArgument(description: String) { display("{}", description) }
InvalidArgument(description: String) { display("{description}") }

/// All standard options are included as an an implementation
/// path, but those that are not implemented yet should return
/// a NotImplemented error.
NotImplemented(opt: String) { display("Option '{}' not yet implemented.", opt) }
NotImplemented(opt: String) { display("Option '{opt}' not yet implemented.") }

/// Invalid arguments to backup
Backup(description: String) { display("{}\nTry '{} --help' for more information.", description, uucore::execution_phrase()) }
Backup(description: String) { display("{description}\nTry '{} --help' for more information.", uucore::execution_phrase()) }

NotADirectory(path: PathBuf) { display("'{}' is not a directory", path.display()) }
}
Expand Down Expand Up @@ -791,7 +791,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
// code should still be EXIT_ERR as does GNU cp
Error::NotAllFilesCopied => {}
// Else we caught a fatal bubbled-up error, log it to stderr
_ => show_error!("{}", error),
_ => show_error!("{error}"),
};
set_exit_code(EXIT_ERR);
}
Expand Down Expand Up @@ -1283,7 +1283,7 @@ fn show_error_if_needed(error: &Error) {
// should return an error from GNU 9.2
}
_ => {
show_error!("{}", error);
show_error!("{error}");
}
}
}
Expand Down Expand Up @@ -1686,18 +1686,13 @@ pub(crate) fn copy_attributes(
handle_preserve(&attributes.context, || -> CopyResult<()> {
let context = selinux::SecurityContext::of_path(source, false, false).map_err(|e| {
format!(
"failed to get security context of {}: {}",
"failed to get security context of {}: {e}",
source.display(),
e
)
})?;
if let Some(context) = context {
context.set_for_path(dest, false, false).map_err(|e| {
format!(
"failed to set security context for {}: {}",
dest.display(),
e
)
format!("failed to set security context for {}: {e}", dest.display(),)
})?;
}

Expand Down
6 changes: 3 additions & 3 deletions src/uu/csplit/src/patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ impl std::fmt::Display for Pattern {
match self {
Self::UpToLine(n, _) => write!(f, "{n}"),
Self::UpToMatch(regex, 0, _) => write!(f, "/{}/", regex.as_str()),
Self::UpToMatch(regex, offset, _) => write!(f, "/{}/{:+}", regex.as_str(), offset),
Self::UpToMatch(regex, offset, _) => write!(f, "/{}/{offset:+}", regex.as_str()),
Self::SkipToMatch(regex, 0, _) => write!(f, "%{}%", regex.as_str()),
Self::SkipToMatch(regex, offset, _) => write!(f, "%{}%{:+}", regex.as_str(), offset),
Self::SkipToMatch(regex, offset, _) => write!(f, "%{}%{offset:+}", regex.as_str()),
}
}
}
Expand Down Expand Up @@ -168,7 +168,7 @@ fn validate_line_numbers(patterns: &[Pattern]) -> Result<(), CsplitError> {
(_, 0) => Err(CsplitError::LineNumberIsZero),
// two consecutive numbers should not be equal
(n, m) if n == m => {
show_warning!("line number '{}' is the same as preceding line number", n);
show_warning!("line number '{n}' is the same as preceding line number");
Ok(n)
}
// a number cannot be greater than the one that follows
Expand Down
2 changes: 1 addition & 1 deletion src/uu/dd/src/numbers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub(crate) fn to_magnitude_and_suffix(n: u128, suffix_type: SuffixType) -> Strin
if quotient < 10.0 {
format!("{quotient:.1} {suffix}")
} else {
format!("{} {}", quotient.round(), suffix)
format!("{} {suffix}", quotient.round())
}
}

Expand Down
11 changes: 5 additions & 6 deletions src/uu/dd/src/parseargs/unit_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,28 @@ fn unimplemented_flags_should_error_non_linux() {
"noctty",
"nofollow",
] {
let args = vec![format!("iflag={}", flag)];
let args = vec![format!("iflag={flag}")];

if Parser::new()
.parse(&args.iter().map(AsRef::as_ref).collect::<Vec<_>>()[..])
.is_ok()
{
succeeded.push(format!("iflag={}", flag));
succeeded.push(format!("iflag={flag}"));
}

let args = vec![format!("oflag={}", flag)];
let args = vec![format!("oflag={flag}")];

if Parser::new()
.parse(&args.iter().map(AsRef::as_ref).collect::<Vec<_>>()[..])
.is_ok()
{
succeeded.push(format!("iflag={}", flag));
succeeded.push(format!("iflag={flag}"));
}
}

assert!(
succeeded.is_empty(),
"The following flags did not panic as expected: {:?}",
succeeded
"The following flags did not panic as expected: {succeeded:?}",
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/uu/df/src/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ pub(crate) fn to_magnitude_and_suffix(n: u128, suffix_type: SuffixType) -> Strin
if rem % (bases[i] / 10) == 0 {
format!("{quot}.{tenths_place}{suffix}")
} else if tenths_place + 1 == 10 || quot >= 10 {
format!("{}{}", quot + 1, suffix)
format!("{}{suffix}", quot + 1)
} else {
format!("{}.{}{}", quot, tenths_place + 1, suffix)
format!("{quot}.{}{suffix}", tenths_place + 1)
}
}
}
Expand Down
Loading
Loading