Skip to content

Commit

Permalink
Update deprecated function and provide more info about the parsing error
Browse files Browse the repository at this point in the history
  • Loading branch information
sphynx committed Jun 1, 2019
1 parent 8068f96 commit ed941e4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion structopt-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ license = "Apache-2.0/MIT"
travis-ci = { repository = "TeXitoi/structopt" }

[dependencies]
syn = "0.15"
syn = "0.15.10"
quote = "0.6"
proc-macro2 = "0.4"
heck = "^0.3.0"
Expand Down
39 changes: 19 additions & 20 deletions structopt-derive/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,26 +153,25 @@ impl Attrs {
use Meta::*;
use NestedMeta::*;

let structopt_attrs =
attrs
.iter()
.filter_map(|attr| {
let path = &attr.path;
match quote!(#path).to_string().as_ref() {
"structopt" => Some(attr.interpret_meta().unwrap_or_else(|| {
panic!("invalid structopt syntax: {}", quote!(#attr))
})),
_ => None,
}
})
.flat_map(|m| match m {
List(l) => l.nested,
tokens => panic!("unsupported syntax: {}", quote!(#tokens).to_string()),
})
.map(|m| match m {
Meta(m) => m,
ref tokens => panic!("unsupported syntax: {}", quote!(#tokens).to_string()),
});
let structopt_attrs = attrs
.iter()
.filter_map(|attr| {
let path = &attr.path;
match quote!(#path).to_string().as_ref() {
"structopt" => Some(attr.parse_meta().unwrap_or_else(|e| {
panic!("invalid structopt syntax: {}: {}", e, quote!(#attr))
})),
_ => None,
}
})
.flat_map(|m| match m {
List(l) => l.nested,
tokens => panic!("unsupported syntax: {}", quote!(#tokens).to_string()),
})
.map(|m| match m {
Meta(m) => m,
ref tokens => panic!("unsupported syntax: {}", quote!(#tokens).to_string()),
});

for attr in structopt_attrs {
match attr {
Expand Down

0 comments on commit ed941e4

Please sign in to comment.