From 587efd1d4b59cf989da5625a2908857c6e24fc5c Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Thu, 25 Jul 2024 16:34:02 +0200 Subject: [PATCH] clippy: fix warnings introduced by Rust 1.80 --- src/uu/cp/src/cp.rs | 3 ++- src/uu/csplit/src/csplit.rs | 2 +- src/uu/csplit/src/split_name.rs | 2 +- src/uu/realpath/src/realpath.rs | 10 +++++----- src/uucore/src/lib/features/mode.rs | 13 +++++-------- src/uucore/src/lib/mods/error.rs | 2 +- 6 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index 3b02c2c5827..33c16a0fa71 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -1947,7 +1947,8 @@ fn handle_copy_mode( /// /// * `Ok(Permissions)` - The calculated permissions for the destination file. /// * `Err(CopyError)` - An error occurred while getting the metadata of the destination file. -/// Allow unused variables for Windows (on options) +/// +// Allow unused variables for Windows (on options) #[allow(unused_variables)] fn calculate_dest_permissions( dest: &Path, diff --git a/src/uu/csplit/src/csplit.rs b/src/uu/csplit/src/csplit.rs index 7d625d925fa..9e132b704bf 100644 --- a/src/uu/csplit/src/csplit.rs +++ b/src/uu/csplit/src/csplit.rs @@ -351,7 +351,7 @@ impl<'a> SplitWriter<'a> { /// In addition to errors reading/writing from/to a file, the following errors may be returned: /// - if no line matched, an [`CsplitError::MatchNotFound`]. /// - if there are not enough lines to accommodate the offset, an - /// [`CsplitError::LineOutOfRange`]. + /// [`CsplitError::LineOutOfRange`]. #[allow(clippy::cognitive_complexity)] fn do_to_match( &mut self, diff --git a/src/uu/csplit/src/split_name.rs b/src/uu/csplit/src/split_name.rs index e2432f3ce10..29b626efdbd 100644 --- a/src/uu/csplit/src/split_name.rs +++ b/src/uu/csplit/src/split_name.rs @@ -19,7 +19,7 @@ impl SplitName { /// Creates a new SplitName with the given user-defined options: /// - `prefix_opt` specifies a prefix for all splits. /// - `format_opt` specifies a custom format for the suffix part of the filename, using the - /// `sprintf` format notation. + /// `sprintf` format notation. /// - `n_digits_opt` defines the width of the split number. /// /// # Caveats diff --git a/src/uu/realpath/src/realpath.rs b/src/uu/realpath/src/realpath.rs index b099a5f377c..834d9d08333 100644 --- a/src/uu/realpath/src/realpath.rs +++ b/src/uu/realpath/src/realpath.rs @@ -266,11 +266,11 @@ fn resolve_path( /// Conditionally converts an absolute path to a relative form, /// according to the rules: /// 1. if only `relative_to` is given, the result is relative to `relative_to` -/// 1. if only `relative_base` is given, it checks whether given `path` is a descendant -/// of `relative_base`, on success the result is relative to `relative_base`, otherwise -/// the result is the given `path` -/// 1. if both `relative_to` and `relative_base` are given, the result is relative to `relative_to` -/// if `path` is a descendant of `relative_base`, otherwise the result is `path` +/// 2. if only `relative_base` is given, it checks whether given `path` is a descendant +/// of `relative_base`, on success the result is relative to `relative_base`, otherwise +/// the result is the given `path` +/// 3. if both `relative_to` and `relative_base` are given, the result is relative to `relative_to` +/// if `path` is a descendant of `relative_base`, otherwise the result is `path` /// /// For more information see /// diff --git a/src/uucore/src/lib/features/mode.rs b/src/uucore/src/lib/features/mode.rs index c2da380bf0f..9a7336b348f 100644 --- a/src/uucore/src/lib/features/mode.rs +++ b/src/uucore/src/lib/features/mode.rs @@ -191,14 +191,11 @@ pub fn strip_minus_from_mode(args: &mut Vec) -> bool { break; } if let Some(arg_stripped) = arg.strip_prefix('-') { - if let Some(second) = arg.chars().nth(1) { - match second { - 'r' | 'w' | 'x' | 'X' | 's' | 't' | 'u' | 'g' | 'o' | '0'..='7' => { - *arg = arg_stripped.to_string(); - return true; - } - _ => {} - } + if let Some('r' | 'w' | 'x' | 'X' | 's' | 't' | 'u' | 'g' | 'o' | '0'..='7') = + arg.chars().nth(1) + { + *arg = arg_stripped.to_string(); + return true; } } } diff --git a/src/uucore/src/lib/mods/error.rs b/src/uucore/src/lib/mods/error.rs index 571ed12e26d..3a8af3e7f65 100644 --- a/src/uucore/src/lib/mods/error.rs +++ b/src/uucore/src/lib/mods/error.rs @@ -29,7 +29,7 @@ //! * When `Ok` is returned, the code set with [`set_exit_code`] is used as exit code. If //! [`set_exit_code`] was not used, then `0` is used. //! * When `Err` is returned, the code corresponding with the error is used as exit code and the -//! error message is displayed. +//! error message is displayed. //! //! Additionally, the errors can be displayed manually with the [`crate::show`] and [`crate::show_if_err`] macros: //! ```ignore