clippy: fix "hiding a lifetime" warnings

from mismatched_lifetime_syntaxes lint
This commit is contained in:
Daniel Hofstetter
2025-08-07 16:12:03 +02:00
parent ac527f97b8
commit 30f300c52b
20 changed files with 27 additions and 26 deletions
+1 -1
View File
@@ -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()
+1 -1
View File
@@ -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))
}
+1 -1
View File
@@ -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"\\?";
+1 -1
View File
@@ -239,7 +239,7 @@ impl Drop for SplitWriter<'_> {
}
impl SplitWriter<'_> {
fn new(options: &CsplitOptions) -> SplitWriter {
fn new(options: &CsplitOptions) -> SplitWriter<'_> {
SplitWriter {
options,
counter: 0,
+1 -1
View File
@@ -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 {
+2 -2
View File
@@ -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 {
@@ -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)
+1 -1
View File
@@ -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()
+1 -1
View File
@@ -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()
}
+1 -1
View File
@@ -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))?;
+3 -2
View File
@@ -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
}
}
+1 -1
View File
@@ -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);
+1 -1
View File
@@ -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()));
+3 -3
View File
@@ -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",
@@ -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('-');
@@ -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 {
+1 -1
View File
@@ -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()
}
+1 -1
View File
@@ -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,
+1 -1
View File
@@ -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();
+1 -1
View File
@@ -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);
+1 -1
View File
@@ -344,7 +344,7 @@ pub fn os_str_as_bytes(os_string: &OsStr) -> Result<&[u8], NonUtf8OsStrError> {
///
/// This is always lossless on unix platforms,
/// and wraps [`OsStr::to_string_lossy`] on non-unix platforms.
pub fn os_str_as_bytes_lossy(os_string: &OsStr) -> Cow<[u8]> {
pub fn os_str_as_bytes_lossy(os_string: &OsStr) -> Cow<'_, [u8]> {
#[cfg(unix)]
return Cow::from(os_string.as_bytes());
+1 -1
View File
@@ -1009,7 +1009,7 @@ mod tests_split_iterator {
///
/// It tries to avoid introducing any unnecessary quotes or escape characters,
/// but specifics regarding quoting style are left unspecified.
pub fn quote(s: &str) -> std::borrow::Cow<str> {
pub fn quote(s: &str) -> std::borrow::Cow<'_, str> {
// We are going somewhat out of the way to provide
// minimal amount of quoting in typical cases.
match escape_style(s) {
+3 -3
View File
@@ -2318,12 +2318,12 @@ impl UChild {
}
/// Return a [`UChildAssertion`]
pub fn make_assertion(&mut self) -> UChildAssertion {
pub fn make_assertion(&mut self) -> UChildAssertion<'_> {
UChildAssertion::new(self)
}
/// Convenience function for calling [`UChild::delay`] and then [`UChild::make_assertion`]
pub fn make_assertion_with_delay(&mut self, millis: u64) -> UChildAssertion {
pub fn make_assertion_with_delay(&mut self, millis: u64) -> UChildAssertion<'_> {
self.delay(millis).make_assertion()
}
@@ -2879,7 +2879,7 @@ pub fn whoami() -> String {
/// Add prefix 'g' for `util_name` if not on linux
#[cfg(unix)]
pub fn host_name_for(util_name: &str) -> Cow<str> {
pub fn host_name_for(util_name: &str) -> Cow<'_, str> {
// In some environments, e.g. macOS/freebsd, the GNU coreutils are prefixed with "g"
// to not interfere with the BSD counterparts already in `$PATH`.
#[cfg(not(target_os = "linux"))]