Skip to content

Commit f36bf1d

Browse files
authored
Merge pull request #8446 from cakebaker/clippy_fix_warnings_rust_1_89
clippy: fix warnings introduced with Rust `1.89`
2 parents ac527f9 + 10dbffa commit f36bf1d

File tree

28 files changed

+96
-100
lines changed

28 files changed

+96
-100
lines changed

src/uu/chcon/src/chcon.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ enum SELinuxSecurityContext<'t> {
794794
}
795795

796796
impl SELinuxSecurityContext<'_> {
797-
fn to_c_string(&self) -> Result<Option<Cow<CStr>>> {
797+
fn to_c_string(&self) -> Result<Option<Cow<'_, CStr>>> {
798798
match self {
799799
Self::File(context) => context
800800
.to_c_string()

src/uu/chcon/src/fts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl FTS {
6161
})
6262
}
6363

64-
pub(crate) fn last_entry_ref(&mut self) -> Option<EntryRef> {
64+
pub(crate) fn last_entry_ref(&mut self) -> Option<EntryRef<'_>> {
6565
self.entry.map(move |entry| EntryRef::new(self, entry))
6666
}
6767

src/uu/cp/src/copydir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use crate::{
3434

3535
/// Ensure a Windows path starts with a `\\?`.
3636
#[cfg(target_os = "windows")]
37-
fn adjust_canonicalization(p: &Path) -> Cow<Path> {
37+
fn adjust_canonicalization(p: &Path) -> Cow<'_, Path> {
3838
// In some cases, \\? can be missing on some Windows paths. Add it at the
3939
// beginning unless the path is prefixed with a device namespace.
4040
const VERBATIM_PREFIX: &str = r"\\?";

src/uu/csplit/src/csplit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ impl Drop for SplitWriter<'_> {
239239
}
240240

241241
impl SplitWriter<'_> {
242-
fn new(options: &CsplitOptions) -> SplitWriter {
242+
fn new(options: &CsplitOptions) -> SplitWriter<'_> {
243243
SplitWriter {
244244
options,
245245
counter: 0,

src/uu/cut/src/cut.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ fn cut_files(mut filenames: Vec<String>, mode: &Mode) {
404404

405405
/// Get delimiter and output delimiter from `-d`/`--delimiter` and `--output-delimiter` options respectively
406406
/// Allow either delimiter to have a value that is neither UTF-8 nor ASCII to align with GNU behavior
407-
fn get_delimiters(matches: &ArgMatches) -> UResult<(Delimiter, Option<&[u8]>)> {
407+
fn get_delimiters(matches: &ArgMatches) -> UResult<(Delimiter<'_>, Option<&[u8]>)> {
408408
let whitespace_delimited = matches.get_flag(options::WHITESPACE_DELIMITED);
409409
let delim_opt = matches.get_one::<OsString>(options::DELIMITER);
410410
let delim = match delim_opt {

src/uu/df/src/df.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ mod tests {
688688
fn test_different_dev_id() {
689689
let m1 = mount_info("0", "/mnt/bar");
690690
let m2 = mount_info("1", "/mnt/bar");
691-
assert!(is_best(&[m1.clone()], &m2));
691+
assert!(is_best(std::slice::from_ref(&m1), &m2));
692692
assert!(is_best(&[m2], &m1));
693693
}
694694

@@ -699,7 +699,7 @@ mod tests {
699699
// one condition in this test.
700700
let m1 = mount_info("0", "/mnt/bar");
701701
let m2 = mount_info("0", "/mnt/bar/baz");
702-
assert!(!is_best(&[m1.clone()], &m2));
702+
assert!(!is_best(std::slice::from_ref(&m1), &m2));
703703
assert!(is_best(&[m2], &m1));
704704
}
705705
}

src/uu/install/src/install.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -362,11 +362,13 @@ fn behavior(matches: &ArgMatches) -> UResult<Behavior> {
362362
}
363363

364364
// Check if compare is used with non-permission mode bits
365-
if compare && specified_mode.is_some() {
366-
let mode = specified_mode.unwrap();
367-
let non_permission_bits = 0o7000; // setuid, setgid, sticky bits
368-
if mode & non_permission_bits != 0 {
369-
show_error!("{}", translate!("install-warning-compare-ignored"));
365+
// TODO use a let chain once we have a MSRV of 1.88 or greater
366+
if compare {
367+
if let Some(mode) = specified_mode {
368+
let non_permission_bits = 0o7000; // setuid, setgid, sticky bits
369+
if mode & non_permission_bits != 0 {
370+
show_error!("{}", translate!("install-warning-compare-ignored"));
371+
}
370372
}
371373
}
372374

src/uu/mktemp/src/mktemp.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -198,20 +198,17 @@ impl Params {
198198
// Get the start and end indices of the randomized part of the template.
199199
//
200200
// For example, if the template is "abcXXXXyz", then `i` is 3 and `j` is 7.
201-
let (i, j) = match find_last_contiguous_block_of_xs(&options.template) {
202-
None => {
203-
let s = match options.suffix {
204-
// If a suffix is specified, the error message includes the template without the suffix.
205-
Some(_) => options
206-
.template
207-
.chars()
208-
.take(options.template.len())
209-
.collect::<String>(),
210-
None => options.template,
211-
};
212-
return Err(MkTempError::TooFewXs(s));
213-
}
214-
Some(indices) => indices,
201+
let Some((i, j)) = find_last_contiguous_block_of_xs(&options.template) else {
202+
let s = match options.suffix {
203+
// If a suffix is specified, the error message includes the template without the suffix.
204+
Some(_) => options
205+
.template
206+
.chars()
207+
.take(options.template.len())
208+
.collect::<String>(),
209+
None => options.template,
210+
};
211+
return Err(MkTempError::TooFewXs(s));
215212
};
216213

217214
// Combine the directory given as an option and the prefix of the template.

src/uu/nohup/src/nohup.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,8 @@ fn find_stdout() -> UResult<File> {
143143
Ok(t)
144144
}
145145
Err(e1) => {
146-
let home = match env::var("HOME") {
147-
Err(_) => return Err(NohupError::OpenFailed(internal_failure_code, e1).into()),
148-
Ok(h) => h,
146+
let Ok(home) = env::var("HOME") else {
147+
return Err(NohupError::OpenFailed(internal_failure_code, e1).into());
149148
};
150149
let mut homeout = PathBuf::from(home);
151150
homeout.push(NOHUP_OUT);

src/uu/od/src/formatter_item_info.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use std::fmt;
88

99
#[allow(clippy::enum_variant_names)]
10+
#[allow(unpredictable_function_pointer_comparisons)]
1011
#[derive(Clone, Copy, PartialEq, Eq)]
1112
pub enum FormatWriter {
1213
IntWriter(fn(u64) -> String),

0 commit comments

Comments
 (0)