Skip to content

Commit

Permalink
Merge pull request #4067 from epage/clippy
Browse files Browse the repository at this point in the history
style: Address clippy
  • Loading branch information
epage committed Aug 12, 2022
2 parents 084a6df + 43e961d commit 14b7059
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 64 deletions.
4 changes: 2 additions & 2 deletions clap_complete/src/shells/bash.rs
Expand Up @@ -126,9 +126,9 @@ fn subcommand_details(cmd: &Command) -> String {
return 0
;;",
subcmd = sc.replace('-', "__"),
sc_opts = all_options_for_path(cmd, &*sc),
sc_opts = all_options_for_path(cmd, sc),
level = sc.split("__").map(|_| 1).sum::<u64>(),
opts_details = option_details_for_path(cmd, &*sc)
opts_details = option_details_for_path(cmd, sc)
)
}));

Expand Down
4 changes: 2 additions & 2 deletions clap_complete/src/shells/zsh.rs
Expand Up @@ -235,7 +235,7 @@ fn get_subcommands_of(parent: &Command) -> String {
);
let mut segments = vec![format!("({})", name)];
let subcommand_args = get_args_of(
parser_of(parent, &*bin_name).expect(INTERNAL_ERROR_MSG),
parser_of(parent, bin_name).expect(INTERNAL_ERROR_MSG),
Some(parent),
);

Expand All @@ -244,7 +244,7 @@ fn get_subcommands_of(parent: &Command) -> String {
}

// Get the help text of all child subcommands.
let children = get_subcommands_of(parser_of(parent, &*bin_name).expect(INTERNAL_ERROR_MSG));
let children = get_subcommands_of(parser_of(parent, bin_name).expect(INTERNAL_ERROR_MSG));

if !children.is_empty() {
segments.push(children);
Expand Down
2 changes: 1 addition & 1 deletion clap_derive/src/attrs.rs
Expand Up @@ -1102,7 +1102,7 @@ fn process_author_str(author: &str) -> String {
}

/// Defines the casing for the attributes long representation.
#[derive(Copy, Clone, Debug, PartialEq)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum CasingStyle {
/// Indicate word boundaries with uppercase letter, excluding the first word.
Camel,
Expand Down
2 changes: 1 addition & 1 deletion clap_derive/src/utils/ty.rs
Expand Up @@ -7,7 +7,7 @@ use syn::{
PathSegment, Type, TypePath,
};

#[derive(Copy, Clone, PartialEq, Debug)]
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum Ty {
Vec,
Option,
Expand Down
6 changes: 3 additions & 3 deletions src/builder/arg.rs
Expand Up @@ -112,7 +112,7 @@ impl<'help> Arg<'help> {
#[must_use]
pub fn id<S: Into<&'help str>>(mut self, n: S) -> Self {
let name = n.into();
self.id = Id::from(&*name);
self.id = Id::from(name);
self.name = name;
self
}
Expand Down Expand Up @@ -3976,10 +3976,10 @@ impl<'help> Arg<'help> {
.iter()
.map(|n| format!("<{}>", n))
.collect::<Vec<_>>()
.join(&*delim),
.join(delim),
)
} else {
Cow::Borrowed(self.val_names.get(0).expect(INTERNAL_ERROR_MSG))
Cow::Borrowed(self.val_names.first().expect(INTERNAL_ERROR_MSG))
}
} else {
debug!("Arg::name_no_brackets: just name");
Expand Down
4 changes: 2 additions & 2 deletions src/builder/debug_asserts.rs
Expand Up @@ -67,7 +67,7 @@ pub(crate) fn assert_app(cmd: &Command) {
);

if let Some(s) = arg.short.as_ref() {
short_flags.push(Flag::Arg(format!("-{}", s), &*arg.name));
short_flags.push(Flag::Arg(format!("-{}", s), arg.name));
}

for (short_alias, _) in &arg.short_aliases {
Expand All @@ -76,7 +76,7 @@ pub(crate) fn assert_app(cmd: &Command) {

if let Some(l) = arg.long.as_ref() {
assert!(!l.starts_with('-'), "Argument {}: long {:?} must not start with a `-`, that will be handled by the parser", arg.name, l);
long_flags.push(Flag::Arg(format!("--{}", l), &*arg.name));
long_flags.push(Flag::Arg(format!("--{}", l), arg.name));
}

for (long_alias, _) in &arg.aliases {
Expand Down
2 changes: 1 addition & 1 deletion src/error/kind.rs
@@ -1,5 +1,5 @@
/// Command line argument parser kind of error
#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum ErrorKind {
/// Occurs when an [`Arg`][crate::Arg] has a set of possible values,
Expand Down
4 changes: 2 additions & 2 deletions src/output/usage.rs
Expand Up @@ -38,7 +38,7 @@ impl<'help, 'cmd> Usage<'help, 'cmd> {
pub(crate) fn create_usage_no_title(&self, used: &[Id]) -> String {
debug!("Usage::create_usage_no_title");
if let Some(u) = self.cmd.get_override_usage() {
String::from(&*u)
String::from(u)
} else if used.is_empty() {
self.create_help_usage(true)
} else {
Expand Down Expand Up @@ -134,7 +134,7 @@ impl<'help, 'cmd> Usage<'help, 'cmd> {
if !self.cmd.is_args_conflicts_with_subcommands_set() {
usage.push_str(&*self.create_help_usage(false));
} else {
usage.push_str(&*name);
usage.push_str(name);
}
usage.push_str(" <");
usage.push_str(placeholder);
Expand Down
12 changes: 6 additions & 6 deletions tests/builder/utf8.rs
Expand Up @@ -109,7 +109,7 @@ fn invalid_utf8_positional() {
let m = r.unwrap();
assert!(m.contains_id("arg"));
assert_eq!(
&*m.get_one::<OsString>("arg").unwrap(),
m.get_one::<OsString>("arg").unwrap(),
&*OsString::from_vec(vec![0xe9])
);
}
Expand All @@ -133,7 +133,7 @@ fn invalid_utf8_option_short_space() {
let m = r.unwrap();
assert!(m.contains_id("arg"));
assert_eq!(
&*m.get_one::<OsString>("arg").unwrap(),
m.get_one::<OsString>("arg").unwrap(),
&*OsString::from_vec(vec![0xe9])
);
}
Expand All @@ -156,7 +156,7 @@ fn invalid_utf8_option_short_equals() {
let m = r.unwrap();
assert!(m.contains_id("arg"));
assert_eq!(
&*m.get_one::<OsString>("arg").unwrap(),
m.get_one::<OsString>("arg").unwrap(),
&*OsString::from_vec(vec![0xe9])
);
}
Expand All @@ -179,7 +179,7 @@ fn invalid_utf8_option_short_no_space() {
let m = r.unwrap();
assert!(m.contains_id("arg"));
assert_eq!(
&*m.get_one::<OsString>("arg").unwrap(),
m.get_one::<OsString>("arg").unwrap(),
&*OsString::from_vec(vec![0xe9])
);
}
Expand All @@ -203,7 +203,7 @@ fn invalid_utf8_option_long_space() {
let m = r.unwrap();
assert!(m.contains_id("arg"));
assert_eq!(
&*m.get_one::<OsString>("arg").unwrap(),
m.get_one::<OsString>("arg").unwrap(),
&*OsString::from_vec(vec![0xe9])
);
}
Expand All @@ -226,7 +226,7 @@ fn invalid_utf8_option_long_equals() {
let m = r.unwrap();
assert!(m.contains_id("arg"));
assert_eq!(
&*m.get_one::<OsString>("arg").unwrap(),
m.get_one::<OsString>("arg").unwrap(),
&*OsString::from_vec(vec![0xe9])
);
}
Expand Down
18 changes: 9 additions & 9 deletions tests/derive/flags.rs
Expand Up @@ -17,7 +17,7 @@ use clap::Parser;

#[test]
fn bool_type_is_flag() {
#[derive(Parser, PartialEq, Debug)]
#[derive(Parser, PartialEq, Eq, Debug)]
struct Opt {
#[clap(short, long)]
alice: bool,
Expand Down Expand Up @@ -46,7 +46,7 @@ fn bool_type_is_flag() {
#[test]
#[ignore] // Not a good path for supporting this atm
fn inferred_help() {
#[derive(Parser, PartialEq, Debug)]
#[derive(Parser, PartialEq, Eq, Debug)]
struct Opt {
/// Foo
#[clap(short, long)]
Expand All @@ -63,7 +63,7 @@ fn inferred_help() {
#[test]
#[ignore] // Not a good path for supporting this atm
fn inferred_version() {
#[derive(Parser, PartialEq, Debug)]
#[derive(Parser, PartialEq, Eq, Debug)]
struct Opt {
/// Foo
#[clap(short, long)]
Expand All @@ -82,7 +82,7 @@ fn inferred_version() {

#[test]
fn count() {
#[derive(Parser, PartialEq, Debug)]
#[derive(Parser, PartialEq, Eq, Debug)]
struct Opt {
#[clap(short, long, action = clap::ArgAction::Count)]
alice: u8,
Expand Down Expand Up @@ -116,7 +116,7 @@ fn count() {

#[test]
fn mixed_type_flags() {
#[derive(Parser, PartialEq, Debug)]
#[derive(Parser, PartialEq, Eq, Debug)]
struct Opt {
#[clap(short, long)]
alice: bool,
Expand Down Expand Up @@ -172,7 +172,7 @@ fn mixed_type_flags() {
fn ignore_qualified_bool_type() {
mod inner {
#[allow(non_camel_case_types)]
#[derive(PartialEq, Debug, Clone)]
#[derive(PartialEq, Eq, Debug, Clone)]
pub struct bool(pub String);

impl std::str::FromStr for self::bool {
Expand All @@ -184,7 +184,7 @@ fn ignore_qualified_bool_type() {
}
}

#[derive(Parser, PartialEq, Debug)]
#[derive(Parser, PartialEq, Eq, Debug)]
struct Opt {
arg: inner::bool,
}
Expand All @@ -199,7 +199,7 @@ fn ignore_qualified_bool_type() {

#[test]
fn override_implicit_action() {
#[derive(Parser, PartialEq, Debug)]
#[derive(Parser, PartialEq, Eq, Debug)]
struct Opt {
#[clap(long, action = clap::ArgAction::Set)]
arg: bool,
Expand All @@ -218,7 +218,7 @@ fn override_implicit_action() {

#[test]
fn override_implicit_from_flag_positional() {
#[derive(Parser, PartialEq, Debug)]
#[derive(Parser, PartialEq, Eq, Debug)]
struct Opt {
#[clap(action = clap::ArgAction::Set)]
arg: bool,
Expand Down
4 changes: 2 additions & 2 deletions tests/derive/skip.rs
Expand Up @@ -103,7 +103,7 @@ fn skip_enum() {

#[test]
fn skip_help_doc_comments() {
#[derive(Parser, Debug, PartialEq)]
#[derive(Parser, Debug, PartialEq, Eq)]
pub struct Opt {
#[clap(skip, help = "internal_stuff")]
a: u32,
Expand Down Expand Up @@ -134,7 +134,7 @@ fn skip_help_doc_comments() {

#[test]
fn skip_val() {
#[derive(Parser, Debug, PartialEq)]
#[derive(Parser, Debug, PartialEq, Eq)]
pub struct Opt {
#[clap(long, short)]
number: u32,
Expand Down

0 comments on commit 14b7059

Please sign in to comment.