Skip to content

Commit

Permalink
Merge pull request #2660 from rami3l/fix-clippy
Browse files Browse the repository at this point in the history
fix(style): eliminate several `clippy` warnings
  • Loading branch information
pksunkara committed Aug 3, 2021
2 parents 286fda0 + ac12c30 commit 9e4ea7d
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion examples/01a_quick_example.rs
Expand Up @@ -64,7 +64,7 @@ fn main() {

// You can check for the existence of subcommands, and if found use their
// matches just as you would the top level app
if let Some(ref matches) = matches.subcommand_matches("test") {
if let Some(matches) = matches.subcommand_matches("test") {
// "$ myapp test" was run
if matches.is_present("list") {
// "$ myapp test -l" was run
Expand Down
2 changes: 1 addition & 1 deletion examples/01b_quick_example.rs
Expand Up @@ -83,7 +83,7 @@ fn main() {

// You can check for the existence of subcommands, and if found use their
// matches just as you would the top level app
if let Some(ref matches) = matches.subcommand_matches("test") {
if let Some(matches) = matches.subcommand_matches("test") {
// "$ myapp test" was run
if matches.is_present("list") {
// "$ myapp test -l" was run
Expand Down
2 changes: 1 addition & 1 deletion examples/08_subcommands.rs
Expand Up @@ -42,7 +42,7 @@ fn main() {
}

// You can get the independent subcommand matches (which function exactly like App matches)
if let Some(ref matches) = matches.subcommand_matches("add") {
if let Some(matches) = matches.subcommand_matches("add") {
// Safe to use unwrap() because of the required() option
println!("Adding file: {}", matches.value_of("input").unwrap());
}
Expand Down
2 changes: 1 addition & 1 deletion examples/18_builder_macro.rs
Expand Up @@ -69,7 +69,7 @@ fn main() {

// You can check for the existence of subcommands, and if found use their
// matches just as you would the top level app
if let Some(ref matches) = matches.subcommand_matches("test") {
if let Some(matches) = matches.subcommand_matches("test") {
// "$ myapp test" was run
if matches.is_present("list") {
// "$ myapp test -l" was run
Expand Down
2 changes: 1 addition & 1 deletion examples/21_aliases.rs
Expand Up @@ -24,7 +24,7 @@ fn main() {
}

// You can get the independent subcommand matches (which function exactly like App matches)
if let Some(ref matches) = matches.subcommand_matches("add") {
if let Some(matches) = matches.subcommand_matches("add") {
// Safe to use unwrap() because of the required() option
println!("Adding file: {}", matches.value_of("input").unwrap());
}
Expand Down
8 changes: 5 additions & 3 deletions src/macros.rs
Expand Up @@ -570,10 +570,12 @@ macro_rules! wlnerr {

#[cfg(feature = "debug")]
macro_rules! debug {
($($arg:tt)*) => {
($($arg:tt)*) => ({
// The `print!` line will make clippy complain about duplicates.
#[allow(clippy::branches_sharing_code)]
print!("[{:>w$}] \t", module_path!(), w = 28);
println!($($arg)*)
}
println!($($arg)*);
})
}

#[cfg(not(feature = "debug"))]
Expand Down
5 changes: 2 additions & 3 deletions src/parse/matches/matched_arg.rs
Expand Up @@ -376,10 +376,9 @@ mod tests {
}

{
let mut m = m.clone();
let mut m = m;
m.remove_vals(9);
let vals1: Vec<&Vec<OsString>> = m.vals().collect();
assert!(vals1.is_empty());
assert_eq!(m.vals().next(), None);
}
}
}
1 change: 1 addition & 0 deletions tests/default_missing_vals.rs
Expand Up @@ -110,6 +110,7 @@ fn opt_default_user_override() {
}

#[test]
#[allow(clippy::bool_assert_comparison)]
fn default_missing_value_flag_value() {
let app = App::new("test").arg(
Arg::new("flag")
Expand Down
16 changes: 8 additions & 8 deletions tests/help.rs
Expand Up @@ -2273,7 +2273,7 @@ fn about_in_subcommands_list() {

#[test]
fn issue_1794_usage() {
static USAGE_WITH_GROUP: &'static str = "hello
static USAGE_WITH_GROUP: &str = "hello
USAGE:
deno <pos1|--option1> [pos2]
Expand Down Expand Up @@ -2306,7 +2306,7 @@ FLAGS:
));
}

static ONLY_CUSTOM_HEADING_FLAGS: &'static str = "test 1.4
static ONLY_CUSTOM_HEADING_FLAGS: &str = "test 1.4
USAGE:
test [OPTIONS]
Expand Down Expand Up @@ -2340,7 +2340,7 @@ fn only_custom_heading_flags() {
));
}

static ONLY_CUSTOM_HEADING_OPTS: &'static str = "test 1.4
static ONLY_CUSTOM_HEADING_OPTS: &str = "test 1.4
USAGE:
test
Expand All @@ -2367,7 +2367,7 @@ fn only_custom_heading_opts() {
));
}

static CUSTOM_HEADING_POS: &'static str = "test 1.4
static CUSTOM_HEADING_POS: &str = "test 1.4
USAGE:
test [ARGS]
Expand Down Expand Up @@ -2398,7 +2398,7 @@ fn custom_heading_pos() {
));
}

static ONLY_CUSTOM_HEADING_POS: &'static str = "test 1.4
static ONLY_CUSTOM_HEADING_POS: &str = "test 1.4
USAGE:
test [speed]
Expand All @@ -2425,7 +2425,7 @@ fn only_custom_heading_pos() {
));
}

static ONLY_CUSTOM_HEADING_FLAGS_NO_ARGS: &'static str = "test 1.4
static ONLY_CUSTOM_HEADING_FLAGS_NO_ARGS: &str = "test 1.4
USAGE:
test
Expand All @@ -2450,7 +2450,7 @@ fn only_custom_heading_flags_no_args() {
));
}

static ONLY_CUSTOM_HEADING_OPTS_NO_ARGS: &'static str = "test 1.4
static ONLY_CUSTOM_HEADING_OPTS_NO_ARGS: &str = "test 1.4
USAGE:
test
Expand All @@ -2475,7 +2475,7 @@ fn only_custom_heading_opts_no_args() {
));
}

static ONLY_CUSTOM_HEADING_POS_NO_ARGS: &'static str = "test 1.4
static ONLY_CUSTOM_HEADING_POS_NO_ARGS: &str = "test 1.4
USAGE:
test [speed]
Expand Down
2 changes: 1 addition & 1 deletion tests/require.rs
Expand Up @@ -937,7 +937,7 @@ fn issue_1158_app() -> App<'static> {

#[test]
fn multiple_required_unless_usage_printing() {
static MULTIPLE_REQUIRED_UNLESS_USAGE: &'static str =
static MULTIPLE_REQUIRED_UNLESS_USAGE: &str =
"error: The following required arguments were not provided:
--a <a>
--b <b>
Expand Down

0 comments on commit 9e4ea7d

Please sign in to comment.