summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Hofstetter <daniel.hofstetter@42dh.com>2024-05-02 15:14:46 +0200
committerDaniel Hofstetter <daniel.hofstetter@42dh.com>2024-05-02 16:47:44 +0200
commit19901055a24b7c4cd2446b5e05ab572b1d81318d (patch)
treeb37b4f5c1be4453dd2b19ba68f1b1410b0563b92
parent1c0984911fe726ef43a16abdac784ee20fa07000 (diff)
clippy: fix warnings introduced with Rust 1.78
-rw-r--r--src/uu/cp/src/cp.rs9
-rw-r--r--src/uu/csplit/src/csplit.rs12
-rw-r--r--src/uu/csplit/src/patterns.rs14
-rw-r--r--src/uu/df/src/filesystem.rs1
-rw-r--r--src/uu/env/src/env.rs6
-rw-r--r--src/uu/factor/src/factor.rs4
-rw-r--r--src/uu/hashsum/src/hashsum.rs10
-rw-r--r--src/uu/kill/src/kill.rs2
-rw-r--r--src/uu/nl/src/helper.rs2
-rw-r--r--src/uu/ptx/src/ptx.rs2
-rw-r--r--src/uu/tail/src/follow/watch.rs1
11 files changed, 31 insertions, 32 deletions
diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs
index cb3275ff9..c9d2783a4 100644
--- a/src/uu/cp/src/cp.rs
+++ b/src/uu/cp/src/cp.rs
@@ -1120,6 +1120,7 @@ fn parse_path_args(
};
if options.strip_trailing_slashes {
+ #[allow(clippy::assigning_clones)]
for source in &mut paths {
*source = source.components().as_path().to_owned();
}
@@ -1617,8 +1618,8 @@ fn handle_existing_dest(
// linking.
if options.preserve_hard_links()
- // only try to remove dest file only if the current source
- // is hardlink to a file that is already copied
+ // only try to remove dest file only if the current source
+ // is hardlink to a file that is already copied
&& copied_files.contains_key(
&FileInformation::from_path(
source,
@@ -1734,7 +1735,7 @@ fn handle_copy_mode(
dest: &Path,
options: &Options,
context: &str,
- source_metadata: Metadata,
+ source_metadata: &Metadata,
symlinked_files: &mut HashSet<FileInformation>,
source_in_command_line: bool,
) -> CopyResult<()> {
@@ -2053,7 +2054,7 @@ fn copy_file(
dest,
options,
context,
- source_metadata,
+ &source_metadata,
symlinked_files,
source_in_command_line,
)?;
diff --git a/src/uu/csplit/src/csplit.rs b/src/uu/csplit/src/csplit.rs
index cd55ef7df..7d625d925 100644
--- a/src/uu/csplit/src/csplit.rs
+++ b/src/uu/csplit/src/csplit.rs
@@ -86,17 +86,13 @@ impl CsplitOptions {
/// - [`CsplitError::MatchNotFound`] if no line matched a regular expression.
/// - [`CsplitError::MatchNotFoundOnRepetition`], like previous but after applying the pattern
/// more than once.
-pub fn csplit<T>(
- options: &CsplitOptions,
- patterns: Vec<String>,
- input: T,
-) -> Result<(), CsplitError>
+pub fn csplit<T>(options: &CsplitOptions, patterns: &[String], input: T) -> Result<(), CsplitError>
where
T: BufRead,
{
let mut input_iter = InputSplitter::new(input.lines().enumerate());
let mut split_writer = SplitWriter::new(options);
- let patterns: Vec<patterns::Pattern> = patterns::get_patterns(&patterns[..])?;
+ let patterns: Vec<patterns::Pattern> = patterns::get_patterns(patterns)?;
let ret = do_csplit(&mut split_writer, patterns, &mut input_iter);
// consume the rest, unless there was an error
@@ -568,7 +564,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let options = CsplitOptions::new(&matches);
if file_name == "-" {
let stdin = io::stdin();
- Ok(csplit(&options, patterns, stdin.lock())?)
+ Ok(csplit(&options, &patterns, stdin.lock())?)
} else {
let file = File::open(file_name)
.map_err_context(|| format!("cannot access {}", file_name.quote()))?;
@@ -578,7 +574,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
if !file_metadata.is_file() {
return Err(CsplitError::NotRegularFile(file_name.to_string()).into());
}
- Ok(csplit(&options, patterns, BufReader::new(file))?)
+ Ok(csplit(&options, &patterns, BufReader::new(file))?)
}
}
diff --git a/src/uu/csplit/src/patterns.rs b/src/uu/csplit/src/patterns.rs
index 6e7483b7f..bd6c4fbfa 100644
--- a/src/uu/csplit/src/patterns.rs
+++ b/src/uu/csplit/src/patterns.rs
@@ -25,14 +25,14 @@ pub enum Pattern {
SkipToMatch(Regex, i32, ExecutePattern),
}
-impl ToString for Pattern {
- fn to_string(&self) -> String {
+impl std::fmt::Display for Pattern {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
- Self::UpToLine(n, _) => n.to_string(),
- Self::UpToMatch(regex, 0, _) => format!("/{}/", regex.as_str()),
- Self::UpToMatch(regex, offset, _) => format!("/{}/{:+}", regex.as_str(), offset),
- Self::SkipToMatch(regex, 0, _) => format!("%{}%", regex.as_str()),
- Self::SkipToMatch(regex, offset, _) => format!("%{}%{:+}", regex.as_str(), offset),
+ 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::SkipToMatch(regex, 0, _) => write!(f, "%{}%", regex.as_str()),
+ Self::SkipToMatch(regex, offset, _) => write!(f, "%{}%{:+}", regex.as_str(), offset),
}
}
}
diff --git a/src/uu/df/src/filesystem.rs b/src/uu/df/src/filesystem.rs
index ef5107958..07d24b83f 100644
--- a/src/uu/df/src/filesystem.rs
+++ b/src/uu/df/src/filesystem.rs
@@ -220,6 +220,7 @@ mod tests {
}
#[test]
+ #[allow(clippy::assigning_clones)]
fn test_dev_name_match() {
let tmp = tempfile::TempDir::new().expect("Failed to create temp dir");
let dev_name = std::fs::canonicalize(tmp.path())
diff --git a/src/uu/env/src/env.rs b/src/uu/env/src/env.rs
index 342fb737d..6fad45e5e 100644
--- a/src/uu/env/src/env.rs
+++ b/src/uu/env/src/env.rs
@@ -104,7 +104,7 @@ fn load_config_file(opts: &mut Options) -> UResult<()> {
for (_, prop) in &conf {
// ignore all INI section lines (treat them as comments)
- for (key, value) in prop.iter() {
+ for (key, value) in prop {
env::set_var(key, value);
}
}
@@ -371,7 +371,7 @@ impl EnvAppData {
// no program provided, so just dump all env vars to stdout
print_env(opts.line_ending);
} else {
- return self.run_program(opts, self.do_debug_printing);
+ return self.run_program(&opts, self.do_debug_printing);
}
Ok(())
@@ -379,7 +379,7 @@ impl EnvAppData {
fn run_program(
&mut self,
- opts: Options<'_>,
+ opts: &Options<'_>,
do_debug_printing: bool,
) -> Result<(), Box<dyn UError>> {
let prog = Cow::from(opts.program[0]);
diff --git a/src/uu/factor/src/factor.rs b/src/uu/factor/src/factor.rs
index b56dbf3d1..41fd860b3 100644
--- a/src/uu/factor/src/factor.rs
+++ b/src/uu/factor/src/factor.rs
@@ -51,14 +51,14 @@ fn print_factors_str(
));
}
- write_result(w, x, factorization, print_exponents).map_err_context(|| "write error".into())?;
+ write_result(w, &x, factorization, print_exponents).map_err_context(|| "write error".into())?;
Ok(())
}
fn write_result(
w: &mut io::BufWriter<impl Write>,
- x: BigUint,
+ x: &BigUint,
factorization: BTreeMap<BigUint, usize>,
print_exponents: bool,
) -> io::Result<()> {
diff --git a/src/uu/hashsum/src/hashsum.rs b/src/uu/hashsum/src/hashsum.rs
index d4c5aacbb..708596096 100644
--- a/src/uu/hashsum/src/hashsum.rs
+++ b/src/uu/hashsum/src/hashsum.rs
@@ -831,27 +831,27 @@ where
if !options.status && !skip_summary {
match bad_format.cmp(&1) {
Ordering::Equal => {
- show_warning_caps!("{} line is improperly formatted", bad_format)
+ show_warning_caps!("{} line is improperly formatted", bad_format);
}
Ordering::Greater => {
- show_warning_caps!("{} lines are improperly formatted", bad_format)
+ show_warning_caps!("{} lines are improperly formatted", bad_format);
}
Ordering::Less => {}
};
match failed_cksum.cmp(&1) {
Ordering::Equal => {
- show_warning_caps!("{} computed checksum did NOT match", failed_cksum)
+ show_warning_caps!("{} computed checksum did NOT match", failed_cksum);
}
Ordering::Greater => {
- show_warning_caps!("{} computed checksums did NOT match", failed_cksum)
+ show_warning_caps!("{} computed checksums did NOT match", failed_cksum);
}
Ordering::Less => {}
};
match failed_open_file.cmp(&1) {
Ordering::Equal => {
- show_warning_caps!("{} listed file could not be read", failed_open_file)
+ show_warning_caps!("{} listed file could not be read", failed_open_file);
}
Ordering::Greater => {
show_warning_caps!("{} listed files could not be read", failed_open_file);
diff --git a/src/uu/kill/src/kill.rs b/src/uu/kill/src/kill.rs
index 5446a7f18..6048acfb9 100644
--- a/src/uu/kill/src/kill.rs
+++ b/src/uu/kill/src/kill.rs
@@ -193,7 +193,7 @@ fn list(signals: &Vec<String>) {
} else {
for signal in signals {
if let Err(e) = print_signal(signal) {
- uucore::show!(e)
+ uucore::show!(e);
}
}
}
diff --git a/src/uu/nl/src/helper.rs b/src/uu/nl/src/helper.rs
index ee3f3a0a9..3e5a96b9c 100644
--- a/src/uu/nl/src/helper.rs
+++ b/src/uu/nl/src/helper.rs
@@ -23,7 +23,7 @@ pub fn parse_options(settings: &mut crate::Settings, opts: &clap::ArgMatches) ->
};
}
if let Some(val) = opts.get_one::<String>(options::NUMBER_SEPARATOR) {
- settings.number_separator = val.clone();
+ settings.number_separator.clone_from(val);
}
settings.number_format = opts
.get_one::<String>(options::NUMBER_FORMAT)
diff --git a/src/uu/ptx/src/ptx.rs b/src/uu/ptx/src/ptx.rs
index b952da929..0fb711798 100644
--- a/src/uu/ptx/src/ptx.rs
+++ b/src/uu/ptx/src/ptx.rs
@@ -223,7 +223,7 @@ fn get_config(matches: &clap::ArgMatches) -> UResult<Config> {
if matches.get_flag(options::TRADITIONAL) {
config.gnu_ext = false;
config.format = OutFormat::Roff;
- config.context_regex = "[^ \t\n]+".to_owned();
+ "[^ \t\n]+".clone_into(&mut config.context_regex);
} else {
return Err(PtxError::NotImplemented("GNU extensions").into());
}
diff --git a/src/uu/tail/src/follow/watch.rs b/src/uu/tail/src/follow/watch.rs
index 1836a797a..2e0fc651c 100644
--- a/src/uu/tail/src/follow/watch.rs
+++ b/src/uu/tail/src/follow/watch.rs
@@ -45,6 +45,7 @@ impl WatcherRx {
Tested for notify::InotifyWatcher and for notify::PollWatcher.
*/
if let Some(parent) = path.parent() {
+ #[allow(clippy::assigning_clones)]
if parent.is_dir() {
path = parent.to_owned();
} else {