Skip to content

Commit

Permalink
Merge pull request #5172 from epage/style
Browse files Browse the repository at this point in the history
style: Make clippy happy
  • Loading branch information
epage committed Oct 12, 2023
2 parents 5ab2bab + dfebb54 commit deebc1f
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 23 deletions.
2 changes: 1 addition & 1 deletion clap_builder/src/builder/command.rs
Expand Up @@ -746,7 +746,7 @@ impl Command {
I: IntoIterator<Item = T>,
T: Into<OsString> + Clone,
{
let mut raw_args = clap_lex::RawArgs::new(itr.into_iter());
let mut raw_args = clap_lex::RawArgs::new(itr);
let mut cursor = raw_args.cursor();

if self.settings.is_set(AppSettings::Multicall) {
Expand Down
16 changes: 8 additions & 8 deletions clap_builder/src/builder/debug_asserts.rs
Expand Up @@ -405,6 +405,12 @@ impl PartialEq for Flag<'_> {

impl PartialOrd for Flag<'_> {
fn partial_cmp(&self, other: &Flag) -> Option<Ordering> {
Some(self.cmp(other))
}
}

impl Ord for Flag<'_> {
fn cmp(&self, other: &Self) -> Ordering {
use Flag::*;

match (self, other) {
Expand All @@ -413,21 +419,15 @@ impl PartialOrd for Flag<'_> {
| (Command(s1, _), Arg(s2, _))
| (Arg(s1, _), Command(s2, _)) => {
if s1 == s2 {
Some(Ordering::Equal)
Ordering::Equal
} else {
s1.partial_cmp(s2)
s1.cmp(s2)
}
}
}
}
}

impl Ord for Flag<'_> {
fn cmp(&self, other: &Self) -> Ordering {
self.partial_cmp(other).unwrap()
}
}

fn detect_duplicate_flags(flags: &[Flag], short_or_long: &str) {
use Flag::*;

Expand Down
2 changes: 1 addition & 1 deletion clap_builder/src/builder/os_str.rs
Expand Up @@ -316,7 +316,7 @@ impl PartialEq for Inner {

impl PartialOrd for Inner {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.as_os_str().partial_cmp(other.as_os_str())
Some(self.cmp(other))
}
}

Expand Down
2 changes: 1 addition & 1 deletion clap_builder/src/builder/str.rs
Expand Up @@ -290,7 +290,7 @@ impl PartialEq for Inner {

impl PartialOrd for Inner {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.as_str().partial_cmp(other.as_str())
Some(self.cmp(other))
}
}

Expand Down
2 changes: 1 addition & 1 deletion clap_builder/src/util/any_value.rs
Expand Up @@ -65,7 +65,7 @@ impl Eq for AnyValueId {}

impl PartialOrd for AnyValueId {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.type_id.partial_cmp(&other.type_id)
Some(self.cmp(other))
}
}

Expand Down
2 changes: 1 addition & 1 deletion clap_complete/src/dynamic/completer.rs
Expand Up @@ -35,7 +35,7 @@ pub fn complete(
) -> Result<Vec<(std::ffi::OsString, Option<StyledStr>)>, std::io::Error> {
cmd.build();

let raw_args = clap_lex::RawArgs::new(args.into_iter());
let raw_args = clap_lex::RawArgs::new(args);
let mut cursor = raw_args.cursor();
let mut target_cursor = raw_args.cursor();
raw_args.seek(
Expand Down
2 changes: 2 additions & 0 deletions clap_derive/src/derives/args.rs
Expand Up @@ -104,6 +104,7 @@ pub fn gen_for_struct(
clippy::cargo,
clippy::suspicious_else_formatting,
clippy::almost_swapped,
clippy::redundant_locals,
)]
#[automatically_derived]
impl #impl_generics clap::FromArgMatches for #item_name #ty_generics #where_clause {
Expand Down Expand Up @@ -146,6 +147,7 @@ pub fn gen_for_struct(
clippy::cargo,
clippy::suspicious_else_formatting,
clippy::almost_swapped,
clippy::redundant_locals,
)]
#[automatically_derived]
impl #impl_generics clap::Args for #item_name #ty_generics #where_clause {
Expand Down
2 changes: 2 additions & 0 deletions clap_derive/src/derives/into_app.rs
Expand Up @@ -47,6 +47,7 @@ pub fn gen_for_struct(
clippy::cargo,
clippy::suspicious_else_formatting,
clippy::almost_swapped,
clippy::redundant_locals,
)]
#[automatically_derived]
impl #impl_generics clap::CommandFactory for #item_name #ty_generics #where_clause {
Expand Down Expand Up @@ -94,6 +95,7 @@ pub fn gen_for_enum(
clippy::cargo,
clippy::suspicious_else_formatting,
clippy::almost_swapped,
clippy::redundant_locals,
)]
#[automatically_derived]
impl #impl_generics clap::CommandFactory for #item_name #ty_generics #where_clause {
Expand Down
1 change: 1 addition & 0 deletions clap_derive/src/derives/parser.rs
Expand Up @@ -89,6 +89,7 @@ fn gen_for_struct(
#[automatically_derived]
#[allow(
unused_qualifications,
clippy::redundant_locals,
)]
impl #impl_generics clap::Parser for #item_name #ty_generics #where_clause {}

Expand Down
2 changes: 2 additions & 0 deletions clap_derive/src/derives/subcommand.rs
Expand Up @@ -84,6 +84,7 @@ pub fn gen_for_enum(
clippy::cargo,
clippy::suspicious_else_formatting,
clippy::almost_swapped,
clippy::redundant_locals,
)]
#[automatically_derived]
impl #impl_generics clap::FromArgMatches for #item_name #ty_generics #where_clause {
Expand Down Expand Up @@ -117,6 +118,7 @@ pub fn gen_for_enum(
clippy::cargo,
clippy::suspicious_else_formatting,
clippy::almost_swapped,
clippy::redundant_locals,
)]
#[automatically_derived]
impl #impl_generics clap::Subcommand for #item_name #ty_generics #where_clause {
Expand Down
1 change: 1 addition & 0 deletions clap_derive/src/derives/value_enum.rs
Expand Up @@ -69,6 +69,7 @@ pub fn gen_for_enum(
clippy::cargo,
clippy::suspicious_else_formatting,
clippy::almost_swapped,
clippy::redundant_locals,
)]
#[automatically_derived]
impl clap::ValueEnum for #item_name {
Expand Down
10 changes: 2 additions & 8 deletions tests/builder/multiple_occurrences.rs
Expand Up @@ -71,18 +71,12 @@ fn multiple_occurrences_of_flags_large_quantity() {
let cmd = Command::new("mo_flags_large_qty")
.arg(arg!(-m --multflag "allowed multiple flag").action(ArgAction::Count));

let args: Vec<&str> = vec![""]
.into_iter()
.chain(vec!["-m"; 200].into_iter())
.collect();
let args: Vec<&str> = vec![""].into_iter().chain(vec!["-m"; 200]).collect();
let m = cmd.clone().try_get_matches_from(args).unwrap();
assert!(m.contains_id("multflag"));
assert_eq!(m.get_one::<u8>("multflag").copied(), Some(200));

let args: Vec<&str> = vec![""]
.into_iter()
.chain(vec!["-m"; 500].into_iter())
.collect();
let args: Vec<&str> = vec![""].into_iter().chain(vec!["-m"; 500]).collect();
let m = cmd.try_get_matches_from(args).unwrap();
assert!(m.contains_id("multflag"));
assert_eq!(m.get_one::<u8>("multflag").copied(), Some(u8::MAX));
Expand Down
4 changes: 2 additions & 2 deletions tests/derive/doc_comments_help.rs
Expand Up @@ -153,7 +153,7 @@ fn verbatim_doc_comment() {
}

let help = utils::get_long_help::<SeeFigure1>();
let sample = r#"
let sample = r"
()
|
( () )
Expand All @@ -168,7 +168,7 @@ fn verbatim_doc_comment() {
(( ||
\\ ||
( () ||
( () ) )"#;
( () ) )";

assert!(help.contains(sample))
}
Expand Down

0 comments on commit deebc1f

Please sign in to comment.