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
2 changes: 1 addition & 1 deletion src/uu/chcon/src/chcon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ enum SELinuxSecurityContext<'t> {
}

impl SELinuxSecurityContext<'_> {
fn to_c_string(&self) -> Result<Option<Cow<CStr>>> {
fn to_c_string(&self) -> Result<Option<Cow<'_, CStr>>> {
match self {
Self::File(context) => context
.to_c_string()
Expand Down
2 changes: 1 addition & 1 deletion src/uu/chcon/src/fts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl FTS {
})
}

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

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 @@ -34,7 +34,7 @@ use crate::{

/// Ensure a Windows path starts with a `\\?`.
#[cfg(target_os = "windows")]
fn adjust_canonicalization(p: &Path) -> Cow<Path> {
fn adjust_canonicalization(p: &Path) -> Cow<'_, Path> {
// In some cases, \\? can be missing on some Windows paths. Add it at the
// beginning unless the path is prefixed with a device namespace.
const VERBATIM_PREFIX: &str = r"\\?";
Expand Down
2 changes: 1 addition & 1 deletion src/uu/csplit/src/csplit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ impl Drop for SplitWriter<'_> {
}

impl SplitWriter<'_> {
fn new(options: &CsplitOptions) -> SplitWriter {
fn new(options: &CsplitOptions) -> SplitWriter<'_> {
SplitWriter {
options,
counter: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/uu/cut/src/cut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ fn cut_files(mut filenames: Vec<String>, mode: &Mode) {

/// Get delimiter and output delimiter from `-d`/`--delimiter` and `--output-delimiter` options respectively
/// Allow either delimiter to have a value that is neither UTF-8 nor ASCII to align with GNU behavior
fn get_delimiters(matches: &ArgMatches) -> UResult<(Delimiter, Option<&[u8]>)> {
fn get_delimiters(matches: &ArgMatches) -> UResult<(Delimiter<'_>, Option<&[u8]>)> {
let whitespace_delimited = matches.get_flag(options::WHITESPACE_DELIMITED);
let delim_opt = matches.get_one::<OsString>(options::DELIMITER);
let delim = match delim_opt {
Expand Down
4 changes: 2 additions & 2 deletions src/uu/df/src/df.rs
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ mod tests {
fn test_different_dev_id() {
let m1 = mount_info("0", "/mnt/bar");
let m2 = mount_info("1", "/mnt/bar");
assert!(is_best(&[m1.clone()], &m2));
assert!(is_best(std::slice::from_ref(&m1), &m2));
assert!(is_best(&[m2], &m1));
}

Expand All @@ -699,7 +699,7 @@ mod tests {
// one condition in this test.
let m1 = mount_info("0", "/mnt/bar");
let m2 = mount_info("0", "/mnt/bar/baz");
assert!(!is_best(&[m1.clone()], &m2));
assert!(!is_best(std::slice::from_ref(&m1), &m2));
assert!(is_best(&[m2], &m1));
}
}
Expand Down
12 changes: 7 additions & 5 deletions src/uu/install/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,13 @@ fn behavior(matches: &ArgMatches) -> UResult<Behavior> {
}

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

Expand Down
25 changes: 11 additions & 14 deletions src/uu/mktemp/src/mktemp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,20 +198,17 @@ impl Params {
// Get the start and end indices of the randomized part of the template.
//
// For example, if the template is "abcXXXXyz", then `i` is 3 and `j` is 7.
let (i, j) = match find_last_contiguous_block_of_xs(&options.template) {
None => {
let s = match options.suffix {
// If a suffix is specified, the error message includes the template without the suffix.
Some(_) => options
.template
.chars()
.take(options.template.len())
.collect::<String>(),
None => options.template,
};
return Err(MkTempError::TooFewXs(s));
}
Some(indices) => indices,
let Some((i, j)) = find_last_contiguous_block_of_xs(&options.template) else {
let s = match options.suffix {
// If a suffix is specified, the error message includes the template without the suffix.
Some(_) => options
.template
.chars()
.take(options.template.len())
.collect::<String>(),
None => options.template,
};
return Err(MkTempError::TooFewXs(s));
};

// Combine the directory given as an option and the prefix of the template.
Expand Down
5 changes: 2 additions & 3 deletions src/uu/nohup/src/nohup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,8 @@ fn find_stdout() -> UResult<File> {
Ok(t)
}
Err(e1) => {
let home = match env::var("HOME") {
Err(_) => return Err(NohupError::OpenFailed(internal_failure_code, e1).into()),
Ok(h) => h,
let Ok(home) = env::var("HOME") else {
return Err(NohupError::OpenFailed(internal_failure_code, e1).into());
};
let mut homeout = PathBuf::from(home);
homeout.push(NOHUP_OUT);
Expand Down
1 change: 1 addition & 0 deletions src/uu/od/src/formatter_item_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use std::fmt;

#[allow(clippy::enum_variant_names)]
#[allow(unpredictable_function_pointer_comparisons)]
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum FormatWriter {
IntWriter(fn(u64) -> String),
Expand Down
4 changes: 2 additions & 2 deletions src/uu/od/src/input_decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl<I> InputDecoder<'_, I> {
normal_length: usize,
peek_length: usize,
byte_order: ByteOrder,
) -> InputDecoder<I> {
) -> InputDecoder<'_, I> {
let bytes = vec![0; normal_length + peek_length];

InputDecoder {
Expand All @@ -64,7 +64,7 @@ where
{
/// calls `peek_read` on the internal stream to (re)fill the buffer. Returns a
/// `MemoryDecoder` providing access to the result or returns an i/o error.
pub fn peek_read(&mut self) -> io::Result<MemoryDecoder> {
pub fn peek_read(&mut self) -> io::Result<MemoryDecoder<'_>> {
match self
.input
.peek_read(self.data.as_mut_slice(), self.reserved_peek_length)
Expand Down
2 changes: 1 addition & 1 deletion src/uu/od/src/od.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ fn open_input_peek_reader(
input_strings: &[String],
skip_bytes: u64,
read_bytes: Option<u64>,
) -> PeekReader<BufReader<PartialReader<MultifileReader>>> {
) -> PeekReader<BufReader<PartialReader<MultifileReader<'_>>>> {
// should return "impl PeekRead + Read + HasError" when supported in (stable) rust
let inputs = input_strings
.iter()
Expand Down
2 changes: 1 addition & 1 deletion src/uu/od/src/output_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub struct OutputInfo {

impl OutputInfo {
/// Returns an iterator over the `SpacedFormatterItemInfo` vector.
pub fn spaced_formatters_iter(&self) -> Iter<SpacedFormatterItemInfo> {
pub fn spaced_formatters_iter(&self) -> Iter<'_, SpacedFormatterItemInfo> {
self.spaced_formatters.iter()
}

Expand Down
2 changes: 1 addition & 1 deletion src/uu/od/src/prn_float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ fn format_float(f: f64, width: usize, precision: usize) -> String {
} else if l == -1 {
format!("{f:width$.precision$}")
} else {
return format_f64_exp_precision(f, width, precision - 1); // subnormal numbers
format_f64_exp_precision(f, width, precision - 1) // subnormal numbers
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/uu/runcon/src/runcon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ fn get_plain_context(context: &OsStr) -> Result<OpaqueSecurityContext> {
.map_err(|r| Error::from_selinux("runcon-operation-creating-context", r))
}

fn get_transition_context(command: &OsStr) -> Result<SecurityContext> {
fn get_transition_context(command: &OsStr) -> Result<SecurityContext<'_>> {
// Generate context based on process transition.
let sec_class = SecurityClass::from_name("process")
.map_err(|r| Error::from_selinux("runcon-operation-getting-process-class", r))?;
Expand Down
5 changes: 3 additions & 2 deletions src/uu/sort/src/chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,11 @@ impl Chunk {
}
}

pub fn lines(&self) -> &Vec<Line> {
pub fn lines(&self) -> &Vec<Line<'_>> {
&self.borrow_dependent().lines
}
pub fn line_data(&self) -> &LineData {

pub fn line_data(&self) -> &LineData<'_> {
&self.borrow_dependent().line_data
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/uu/sort/src/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ pub fn merge_with_file_limit<
fn merge_without_limit<M: MergeInput + 'static, F: Iterator<Item = UResult<M>>>(
files: F,
settings: &GlobalSettings,
) -> UResult<FileMerger> {
) -> UResult<FileMerger<'_>> {
let (request_sender, request_receiver) = channel();
let mut reader_files = Vec::with_capacity(files.size_hint().0);
let mut loaded_receivers = Vec::with_capacity(files.size_hint().0);
Expand Down
8 changes: 4 additions & 4 deletions src/uu/split/src/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,9 +630,9 @@ where
} else if input == "-" {
// STDIN stream that did not fit all content into a buffer
// Most likely continuous/infinite input stream
return Err(io::Error::other(
Err(io::Error::other(
translate!("split-error-cannot-determine-input-size", "input" => input),
));
))
} else {
// Could be that file size is larger than set read limit
// Get the file size from filesystem metadata
Expand All @@ -655,9 +655,9 @@ where
// Give up and return an error
// TODO It might be possible to do more here
// to address all possible file types and edge cases
return Err(io::Error::other(
Err(io::Error::other(
translate!("split-error-cannot-determine-file-size", "input" => input),
));
))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/uu/stat/src/stat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ impl ScanUtil for str {
}
}

fn group_num(s: &str) -> Cow<str> {
fn group_num(s: &str) -> Cow<'_, str> {
let is_negative = s.starts_with('-');
assert!(is_negative || s.chars().take(1).all(|c| c.is_ascii_digit()));
assert!(s.chars().skip(1).all(|c| c.is_ascii_digit()));
Expand Down
6 changes: 3 additions & 3 deletions src/uu/stty/src/stty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ fn string_to_combo(arg: &str) -> Option<&str> {
.map(|_| arg)
}

fn string_to_baud(arg: &str) -> Option<AllFlags> {
fn string_to_baud(arg: &str) -> Option<AllFlags<'_>> {
// BSDs use a u32 for the baud rate, so any decimal number applies.
#[cfg(any(
target_os = "freebsd",
Expand Down Expand Up @@ -595,7 +595,7 @@ fn string_to_baud(arg: &str) -> Option<AllFlags> {
}

/// return `Some(flag)` if the input is a valid flag, `None` if not
fn string_to_flag(option: &str) -> Option<AllFlags> {
fn string_to_flag(option: &str) -> Option<AllFlags<'_>> {
let remove = option.starts_with('-');
let name = option.trim_start_matches('-');

Expand Down Expand Up @@ -868,7 +868,7 @@ fn string_to_control_char(s: &str) -> Result<u8, ControlCharMappingError> {
}

// decomposes a combination argument into a vec of corresponding flags
fn combo_to_flags(combo: &str) -> Vec<ArgOptions> {
fn combo_to_flags(combo: &str) -> Vec<ArgOptions<'_>> {
let mut flags = Vec::new();
let mut ccs = Vec::new();
match combo {
Expand Down
2 changes: 1 addition & 1 deletion src/uu/tail/src/follow/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl FileHandling {
self.get_mut(path).metadata.as_ref()
}

pub fn keys(&self) -> Keys<PathBuf, PathData> {
pub fn keys(&self) -> Keys<'_, PathBuf, PathData> {
self.map.keys()
}

Expand Down
2 changes: 1 addition & 1 deletion src/uu/wc/src/utf8/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl<B: BufRead> BufReadDecoder<B> {
/// except that decoded chunks borrow the decoder (~iterator)
/// so they need to be handled or copied before the next chunk can start decoding.
#[allow(clippy::cognitive_complexity)]
pub fn next_strict(&mut self) -> Option<Result<&str, BufReadDecoderError>> {
pub fn next_strict(&mut self) -> Option<Result<&str, BufReadDecoderError<'_>>> {
enum BytesSource {
BufRead(usize),
Incomplete,
Expand Down
2 changes: 1 addition & 1 deletion src/uu/wc/src/wc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ impl<'a> Input<'a> {
}

/// Converts input to title that appears in stats.
fn to_title(&self) -> Option<Cow<OsStr>> {
fn to_title(&self) -> Option<Cow<'_, OsStr>> {
match self {
Self::Path(path) => {
let path = path.as_os_str();
Expand Down
4 changes: 2 additions & 2 deletions src/uucore/src/lib/features/checksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ fn get_filename_for_output(filename: &OsStr, input_is_stdin: bool) -> String {
fn get_expected_digest_as_hex_string(
line_info: &LineInfo,
len_hint: Option<usize>,
) -> Option<Cow<str>> {
) -> Option<Cow<'_, str>> {
let ck = &line_info.checksum;

let against_hint = |len| len_hint.is_none_or(|l| l == len);
Expand Down Expand Up @@ -989,7 +989,7 @@ fn process_checksum_line(
process_non_algo_based_line(i, &line_info, cli_algo, cli_algo_length, opts)
} else {
// We have no clue of what algorithm to use
return Err(LineCheckError::ImproperlyFormatted);
Err(LineCheckError::ImproperlyFormatted)
}
}

Expand Down
Loading
Loading