argopt
argopt copied to clipboard
Did not compile without structopt crate
Projects using argopt did not compile.
Reproduction
$ mkdir reproduction
$ cd reproduction
$ cargo init
Created binary (application) package
$ rustc --version
rustc 1.43.0 (4fb7144ed 2020-04-20)
$ echo 'argopt = "0.1.1"' >> Cargo.toml
$ cat Cargo.toml
[package]
name = "reproduction"
version = "0.1.0"
authors = ["Yusuke Sangenya <[email protected]>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
argopt = "0.1.1"
$ cat > src/main.rs <<SRC
use argopt::cmd;
#[cmd]
fn main(
#[opt(short = "b", long = "bin")] bin: Option<f64>,
#[opt(short = "w", long = "screen-width", default_value = "80")] screen_width: i64,
) {
println!("{:?}", bin);
println!("{}", screen_width);
}
SRC
$ cargo build
Updating crates.io index
Compiling proc-macro2 v1.0.21
Compiling unicode-xid v0.2.1
Compiling syn v1.0.41
Compiling version_check v0.9.2
Compiling libc v0.2.77
Compiling fnv v1.0.7
Compiling strsim v0.9.3
Compiling bitflags v1.2.1
Compiling ident_case v1.0.1
Compiling unicode-width v0.1.8
Compiling unicode-segmentation v1.6.0
Compiling strsim v0.8.0
Compiling vec_map v0.8.2
Compiling ansi_term v0.11.0
Compiling lazy_static v1.4.0
Compiling textwrap v0.11.0
Compiling heck v0.3.1
Compiling proc-macro-error-attr v1.0.4
Compiling proc-macro-error v1.0.4
Compiling quote v1.0.7
Compiling atty v0.2.14
Compiling clap v2.33.3
Compiling darling_core v0.10.2
Compiling structopt-derive v0.4.10
Compiling darling_macro v0.10.2
Compiling darling v0.10.2
Compiling argopt-impl v0.1.0
Compiling structopt v0.3.17
Compiling argopt v0.1.1
Compiling reproduction v0.1.0 (/home/sangenya/dev/reproduction)
error[E0433]: failed to resolve: could not find `structopt` in `{{root}}`
--> src/main.rs:3:1
|
3 | #[cmd]
| ^^^^^^ could not find `structopt` in `{{root}}`
|
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0433]: failed to resolve: could not find `structopt` in `{{root}}`
--> src/main.rs:3:1
|
3 | #[cmd]
| ^^^^^^ could not find `structopt` in `{{root}}`
|
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0433`.
error: could not compile `reproduction`.
To learn more, run the command again with --verbose.
Workaround
Adding structopt
to dependency solved this issue.
$ echo 'structopt = "*"' >> Cargo.toml
$ cargo build
Compiling reproduction v0.1.0 (/home/sangenya/dev/reproduction)
Finished dev [unoptimized + debuginfo] target(s) in 0.73s