From b66219a18a03255903ed391318a8b32e4a70fc01 Mon Sep 17 00:00:00 2001 From: David LeGare Date: Wed, 2 Mar 2022 16:21:26 +0000 Subject: Update structopt-derive to 0.4.18 Test: cd external/rust/crates && atest --host -c Change-Id: I01c0867da7538adb52ee56fd3143c39d23fbf22c --- .cargo_vcs_info.json | 2 +- Android.bp | 2 +- Cargo.toml | 11 +++++------ Cargo.toml.orig | 2 +- METADATA | 10 +++++----- src/lib.rs | 14 ++++++++------ 6 files changed, 21 insertions(+), 20 deletions(-) diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 0057313..d24b4cf 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "88e5402df017c052f1524f293b2e13bd01810819" + "sha1": "da1fff81aded1c239ffcbd0a27ccdc7f28f74ff2" } } diff --git a/Android.bp b/Android.bp index 2b0bac2..e008611 100644 --- a/Android.bp +++ b/Android.bp @@ -43,7 +43,7 @@ rust_proc_macro { name: "libstructopt_derive", crate_name: "structopt_derive", cargo_env_compat: true, - cargo_pkg_version: "0.4.16", + cargo_pkg_version: "0.4.18", srcs: ["src/lib.rs"], edition: "2018", rustlibs: [ diff --git a/Cargo.toml b/Cargo.toml index 7a10314..5a9f8b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,17 +3,16 @@ # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies +# to registry (e.g., crates.io) dependencies. # -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. [package] edition = "2018" name = "structopt-derive" -version = "0.4.16" +version = "0.4.18" authors = ["Guillaume Pinot "] description = "Parse command line argument by defining a struct, derive crate." documentation = "https://docs.rs/structopt-derive" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index b41ac8a..e081f89 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "structopt-derive" -version = "0.4.16" +version = "0.4.18" edition = "2018" authors = ["Guillaume Pinot "] description = "Parse command line argument by defining a struct, derive crate." diff --git a/METADATA b/METADATA index 6f27d42..d4549b4 100644 --- a/METADATA +++ b/METADATA @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/structopt-derive/structopt-derive-0.4.16.crate" + value: "https://static.crates.io/crates/structopt-derive/structopt-derive-0.4.18.crate" } - version: "0.4.16" + version: "0.4.18" license_type: NOTICE last_upgrade_date { - year: 2021 - month: 9 - day: 22 + year: 2022 + month: 3 + day: 1 } } diff --git a/src/lib.rs b/src/lib.rs index b2835b4..0838f50 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -520,9 +520,14 @@ fn gen_augment_clap_enum( _ => { let app_var = Ident::new("subcommand", Span::call_site()); + let from_attrs = attrs.top_level_methods(); + let version = attrs.version(); + let arg_block = match variant.fields { + // If the variant is named, then gen_augmentation already generates the + // top level methods (#from_attrs) and version. Named(ref fields) => gen_augmentation(&fields.named, &app_var, &attrs), - Unit => quote!( #app_var ), + Unit => quote!( #app_var#from_attrs#version ), Unnamed(FieldsUnnamed { ref unnamed, .. }) if unnamed.len() == 1 => { let ty = &unnamed[0]; quote_spanned! { ty.span()=> @@ -536,7 +541,7 @@ fn gen_augment_clap_enum( ) } else { #app_var - } + }#from_attrs#version } } } @@ -544,13 +549,10 @@ fn gen_augment_clap_enum( }; let name = attrs.cased_name(); - let from_attrs = attrs.top_level_methods(); - let version = attrs.version(); Some(quote! { let app = app.subcommand({ let #app_var = ::structopt::clap::SubCommand::with_name(#name); - let #app_var = #arg_block; - #app_var#from_attrs#version + #arg_block }); }) }, -- cgit v1.2.3