Skip to content

Commit

Permalink
Fix clippy and bump MSRV
Browse files Browse the repository at this point in the history
  • Loading branch information
CreepySkeleton committed Mar 13, 2020
1 parent 1cff111 commit b61a807
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ stages:
jobs:
- job:
variables:
rust: 1.36.0
rust: 1.40.0
strategy:
matrix:
Windows 32-bit (MSVC):
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ jobs:
fast_finish: true
include:
- os: osx
rust: 1.36.0
- rust: 1.36.0
rust: 1.40.0
- rust: 1.40.0
- {}
- rust: beta
- rust: nightly
Expand Down
2 changes: 1 addition & 1 deletion clap_derive/tests/macro-errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed

#[rustversion::attr(any(not(stable), before(1.39)), ignore)]
#[rustversion::attr(any(not(stable), before(1.42)), ignore)]
#[test]
fn ui() {
let t = trybuild::TestCases::new();
Expand Down
4 changes: 2 additions & 2 deletions src/build/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl<'b> App<'b> {

/// Get the name of the binary
pub fn get_bin_name(&self) -> Option<&str> {
self.bin_name.as_ref().map(String::as_str)
self.bin_name.as_deref()
}

/// Sets a string of author(s) that will be displayed to the user when they
Expand Down Expand Up @@ -1957,7 +1957,7 @@ impl<'a> From<&'a Yaml> for App<'a> {
App::new(name)
} else {
let yaml_hash = yaml.as_hash().unwrap();
let sc_key = yaml_hash.keys().nth(0).unwrap();
let sc_key = yaml_hash.keys().next().unwrap();
is_sc = Some(yaml_hash.get(sc_key).unwrap());
App::new(sc_key.as_str().unwrap())
};
Expand Down
6 changes: 3 additions & 3 deletions src/build/arg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl<'help> Arg<'help> {
#[allow(clippy::cognitive_complexity)]
pub fn from_yaml(y: &yaml_rust::yaml::Hash) -> Arg {
// We WANT this to panic on error...so expect() is good.
let name_yml = y.keys().nth(0).unwrap();
let name_yml = y.keys().next().unwrap();
let name_str = name_yml.as_str().unwrap();
let mut a = Arg::with_name(name_str);
let arg_settings = y.get(name_yml).unwrap().as_hash().unwrap();
Expand Down Expand Up @@ -817,7 +817,7 @@ impl<'help> Arg<'help> {
/// assert!(res.is_err());
/// assert_eq!(res.unwrap_err().kind, ErrorKind::ArgumentConflict);
/// ```
///
///
/// [`Arg::conflicts_with_all(names)`]: ./struct.Arg.html#method.conflicts_with_all
/// [`Arg::exclusive(true)`]: ./struct.Arg.html#method.exclusive

Expand Down Expand Up @@ -2115,7 +2115,7 @@ impl<'help> Arg<'help> {
self.setb(ArgSettings::UseValueDelimiter);
self.val_delim = Some(
d.chars()
.nth(0)
.next()
.expect("Failed to get value_delimiter from arg"),
);
self
Expand Down
2 changes: 1 addition & 1 deletion src/build/arg_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ impl<'a> From<&'a yaml_rust::yaml::Hash> for ArgGroup<'a> {
// We WANT this to panic on error...so expect() is good.
let mut a = ArgGroup::default();
let group_settings = if b.len() == 1 {
let name_yml = b.keys().nth(0).expect("failed to get name");
let name_yml = b.keys().next().expect("failed to get name");
let name_str = name_yml
.as_str()
.expect("failed to convert arg YAML name to str");
Expand Down
2 changes: 1 addition & 1 deletion src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ macro_rules! clap_app {
$crate::clap_app!{ @arg ($arg.long(stringify!($long))) $modes $($tail)* }
};
(@arg ($arg:expr) $modes:tt -$short:ident $($tail:tt)*) => {
$crate::clap_app!{ @arg ($arg.short(stringify!($short).chars().nth(0).unwrap())) $modes $($tail)* }
$crate::clap_app!{ @arg ($arg.short(stringify!($short).chars().next().unwrap())) $modes $($tail)* }
};
(@arg ($arg:expr) (-) <$var:ident> $($tail:tt)*) => {
$crate::clap_app!{ @arg ($arg.value_name(stringify!($var))) (+) +takes_value +required $($tail)* }
Expand Down

1 comment on commit b61a807

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: b61a807 Previous: bc738e1 Ratio
build_empty 113 ns/iter (+/- 2) 105 ns/iter (+/- 1) 1.1
parse_empty 1135 ns/iter (+/- 18) 1090 ns/iter (+/- 12) 1.0
parse_simple_with_complex 4159 ns/iter (+/- 74) 4056 ns/iter (+/- 53) 1.0
parse_simple_with_pos 3394 ns/iter (+/- 49) 3222 ns/iter (+/- 34) 1.1
parse_simple_with_opt 3824 ns/iter (+/- 67) 3412 ns/iter (+/- 47) 1.1
parse_simple_with_flag 3183 ns/iter (+/- 65) 2933 ns/iter (+/- 27) 1.1
build_with_pos_ref 265 ns/iter (+/- 5) 270 ns/iter (+/- 2) 0.98
build_with_pos 203 ns/iter (+/- 2) 193 ns/iter (+/- 2) 1.1
build_with_opt_ref 368 ns/iter (+/- 3) 360 ns/iter (+/- 5) 1.0
build_with_opt 316 ns/iter (+/- 6) 298 ns/iter (+/- 4) 1.1
build_with_flag_ref 316 ns/iter (+/- 3) 314 ns/iter (+/- 5) 1.0
build_with_flag 268 ns/iter (+/- 2) 256 ns/iter (+/- 2) 1.0
build_simple 860 ns/iter (+/- 14) 769 ns/iter (+/- 10) 1.1
build_from_usage 4931 ns/iter (+/- 63) 4608 ns/iter (+/- 63) 1.1
build_from_builder 2835 ns/iter (+/- 52) 2916 ns/iter (+/- 30) 0.97
build_from_macros 2831 ns/iter (+/- 31) 2710 ns/iter (+/- 36) 1.0
parse_complex 8479 ns/iter (+/- 122) 7976 ns/iter (+/- 202) 1.1
parse_complex_with_flag 9705 ns/iter (+/- 194) 9536 ns/iter (+/- 160) 1.0
parse_complex_with_opt 10049 ns/iter (+/- 131) 9545 ns/iter (+/- 178) 1.1
parse_complex_with_pos 9780 ns/iter (+/- 170) 9552 ns/iter (+/- 220) 1.0
parse_complex_with_sc 11766 ns/iter (+/- 284) 11229 ns/iter (+/- 125) 1.0
parse_complex_with_sc_flag 12979 ns/iter (+/- 145) 12581 ns/iter (+/- 127) 1.0
parse_complex_with_sc_opt 12987 ns/iter (+/- 246) 12418 ns/iter (+/- 186) 1.0
parse_complex_with_sc_pos 12680 ns/iter (+/- 187) 12154 ns/iter (+/- 182) 1.0
parse_complex1 16188 ns/iter (+/- 303) 14999 ns/iter (+/- 192) 1.1
parse_complex2 17751 ns/iter (+/- 374) 17195 ns/iter (+/- 206) 1.0
parse_args_negate_scs 18096 ns/iter (+/- 259) 17121 ns/iter (+/- 184) 1.1
parse_complex_with_sc_complex 14818 ns/iter (+/- 289) 13474 ns/iter (+/- 245) 1.1
example1 17512 ns/iter (+/- 258) 17720 ns/iter (+/- 124) 0.99
example2 365624 ns/iter (+/- 36,852) 414250 ns/iter (+/- 56,461) 0.88
example3 18401 ns/iter (+/- 216) 19436 ns/iter (+/- 341) 0.95
example4 13263 ns/iter (+/- 291) 13634 ns/iter (+/- 204) 0.97
example5 464985 ns/iter (+/- 38,865) 484799 ns/iter (+/- 34,537) 0.96
example6 10390 ns/iter (+/- 156) 10698 ns/iter (+/- 218) 0.97
example7 14756 ns/iter (+/- 234) 14897 ns/iter (+/- 215) 0.99
example8 14840 ns/iter (+/- 220) 14775 ns/iter (+/- 204) 1.0
example10 423362 ns/iter (+/- 36,849) 448771 ns/iter (+/- 49,422) 0.94
example4_template 12595 ns/iter (+/- 151) 12442 ns/iter (+/- 190) 1.0
build_rg_with_short_help 13075 ns/iter (+/- 299) 12182 ns/iter (+/- 195) 1.1
build_rg_with_long_help 13977 ns/iter (+/- 300) 12861 ns/iter (+/- 152) 1.1
write_rg_short_help 115111 ns/iter (+/- 1,504) 114389 ns/iter (+/- 1,663) 1.0
write_rg_long_help 248328 ns/iter (+/- 7,154) 260055 ns/iter (+/- 7,194) 0.95
parse_rg 28516 ns/iter (+/- 455) 26206 ns/iter (+/- 386) 1.1
parse_rg_with_complex 39699 ns/iter (+/- 634) 37610 ns/iter (+/- 604) 1.1
parse_rg_with_lots 883644 ns/iter (+/- 17,332) 847968 ns/iter (+/- 9,587) 1.0
build_rustup 17428 ns/iter (+/- 227) 14562 ns/iter (+/- 230) 1.2
parse_rustup 21468 ns/iter (+/- 356) 18150 ns/iter (+/- 271) 1.2
parse_rustup_with_sc 19854 ns/iter (+/- 369) 17755 ns/iter (+/- 166) 1.1

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.