summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2022-03-08 20:59:52 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-03-08 20:59:52 +0000
commitb74cbda0410a2a1ee944aa5fcceb23606ce602d3 (patch)
treea7b81493116cc5481899d7d3cce4afea16cb18ac
parentd68c3e4c8a340876004e6a888645a032cb8157a7 (diff)
parente8905e91b8da8278b2b0841530308d44a1b340d9 (diff)
downloadstructopt-derive-b74cbda0410a2a1ee944aa5fcceb23606ce602d3.tar.gz
Merge "Update structopt-derive to 0.4.18" am: e8905e91b8
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/structopt-derive/+/2005115 Change-Id: Ifa7867dc9933c9279b325bd3366b0c0d00c43da6
-rw-r--r--.cargo_vcs_info.json2
-rw-r--r--Android.bp2
-rw-r--r--Cargo.toml11
-rw-r--r--Cargo.toml.orig2
-rw-r--r--METADATA10
-rw-r--r--src/lib.rs14
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 <texitoi@texitoi.eu>"]
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 <texitoi@texitoi.eu>"]
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
});
})
},