You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Flag misinterpreted as option when using macros on Rust 1.47.0 #439
It seems that with 1.47.0 macro'ing structopt causes misbehavior in the functionality of structopt. I found out that a flag gets erroneously parsed as an option instead.
In this example:
use structopt::StructOpt;macro_rules! command {(
$(#[derive($($t:tt),+)])?
#[structopt(
name = $name:literal,
about = $about:literal,
$( $var:ident = $val:expr,)*)]struct $command:ident {
$(
$(#[$m:meta])*
$field:ident: $type:ty,)*}) => (
$(#[derive($($t),+)])?
#[structopt(
name = $name,
about = $about,
$( $var = $val,)*)]struct $command {
$(
$(#[$m])*
$field: $type,)*});}command!{
#[derive(Debug,StructOpt)]
#[structopt(
name = "opts",
about = "Opts",)]structOpts{
#[structopt(long = "x", help = "xxx")]
x:bool,}}fnmain(){println!("{:?}",Opts::from_args());}
when compiling with Rust 1.46.0
$ cargo +1.46.0 run -- --help
opts 0.1.0
Opts
USAGE:
x [FLAGS]
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
--x xxx
with Rust 1.47.0
$ cargo +1.47.0 run -- --help
opts 0.1.0
Opts
USAGE:
x --x <x>
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
OPTIONS:
--x <x> xxx
Basically, tokens passed to a macro and assigned to a metavariable ($bool:ty) are wrapped in an invisible Syn::Type::Group. Our type checking doesn't account for that, and bool wasn't recognized as such.
Activity
CreepySkeleton commentedon Oct 12, 2020
This can be further simplified to
Basically, tokens passed to a macro and assigned to a metavariable (
$bool:ty) are wrapped in an invisibleSyn::Type::Group. Our type checking doesn't account for that, and bool wasn't recognized as such.Fix #439
Fix #439
Fix #439