Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build error on stable #53

Closed
MikailBag opened this issue Feb 29, 2020 · 5 comments
Closed

Build error on stable #53

MikailBag opened this issue Feb 29, 2020 · 5 comments
Labels
bug Something isn't working

Comments

@MikailBag
Copy link

Command:

cargo install cargo-udeps --force

fails with error:

error: unsupported expression; enable syn\'s features=[\"full\"]
   --> /home/mb/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-udeps-0.1.7/src/lib.rs:194:19
    |
194 |         possible_values(&["human", "json", "short"]),
    |                         ^

This also reproduces on CI: https://github.com/jjs-dev/jjs/pull/262/checks?check_run_id=476888019#step:3:398

Command to build syn looks like:

rustc --edition=2018 --crate-name syn /home/mb/.cargo/registry/src/github.com-1ecc6299db9ec823/syn-1.0.16/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 --cfg 'feature="clone-impls"' --cfg 'feature="default"' --cfg 'feature="derive"' --cfg 'feature="extra-traits"' --cfg 'feature="parsing"' --cfg 'feature="printing"' --cfg 'feature="proc-macro"' --cfg 'feature="quote"' --cfg 'feature="visit"' -C metadata=a6e633c5c00a1fe7 -C extra-filename=-a6e633c5c00a1fe7 --out-dir /tmp/cargo-installTSKC0Y/release/deps -L dependency=/tmp/cargo-installTSKC0Y/release/deps --extern proc_macro2=/tmp/cargo-installTSKC0Y/release/deps/libproc_macro2-a3069c7ac662c1f8.rmeta --extern quote=/tmp/cargo-installTSKC0Y/release/deps/libquote-a1723bc5a5d8fc45.rmeta --extern unicode_xid=/tmp/cargo-installTSKC0Y/release/deps/libunicode_xid-d0c8361b0afb9c55.rmeta --cap-lints allow --cfg syn_disable_nightly_tests

Command to build cargo-udeps looks like:

rustc --edition=2018 --crate-name cargo_udeps /home/mb/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-udeps-0.1.7/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C metadata=0ac0c05e5495504f -C extra-filename=-0ac0c05e5495504f --out-dir /tmp/cargo-installTSKC0Y/release/deps -L dependency=/tmp/cargo-installTSKC0Y/release/deps --extern ansi_term=/tmp/cargo-installTSKC0Y/release/deps/libansi_term-71bbe583c380e991.rmeta --extern cargo=/tmp/cargo-installTSKC0Y/release/deps/libcargo-340f2e91cf127365.rmeta --extern failure=/tmp/cargo-installTSKC0Y/release/deps/libfailure-4c2aa744f50822db.rmeta --extern serde=/tmp/cargo-installTSKC0Y/release/deps/libserde-430505ed9b89d689.rmeta --extern serde_json=/tmp/cargo-installTSKC0Y/release/deps/libserde_json-79bd17e09973d55a.rmeta --extern structopt=/tmp/cargo-installTSKC0Y/release/deps/libstructopt-bc4d30492e2c5942.rmeta --cap-lints allow -L native=/usr/lib/x86_64-linux-gnu -L native=/tmp/cargo-installTSKC0Y/release/build/libnghttp2-sys-fd029bbaf17bc55d/out/i/lib -L native=/usr/lib/x86_64-linux-gnu -L native=/tmp/cargo-installTSKC0Y/release/build/backtrace-sys-071d1247008507ba/out -L native=/tmp/cargo-installTSKC0Y/release/build/libgit2-sys-05494346cf6a118a/out/build -L native=/tmp/cargo-installTSKC0Y/release/build/libssh2-sys-205529daa70e2991/out/build

Git master version builds fine.

I'm using rustc 1.41.0 (5e1a79984 2020-01-27).

@est31
Copy link
Owner

est31 commented Feb 29, 2020

Thanks for the report. I guess that some dependency of ours used syn in full mode and now doesn't use it any more. You can run cargo install cargo-udeps --locked --force instead, that works for me.

@qryxip
Copy link
Collaborator

qryxip commented Feb 29, 2020

That is due to TeXitoi/structopt#326. Probably they had expect that it was a breaking change as it was a part of minor version release. But #[structopt(method($expr))] should be expected usage. Or rather, even #[structopt(method = $expr)] should require syn/full. syn/full seems to be enabled for the tests of structopt by chance.

// error: expected `string literal` or `expression` after `=`
//   --> src/main.rs:18:22
//    |
// 18 | #[structopt(settings = &[AppSettings::DeriveDisplayOrder, AppSettings::UnifiedHelpMessage])]
//    |                      ^

//! ## Cargo.toml
//!
//! ```toml
//! [package]
//! name = "a"
//! version = "0.0.0"
//! edition = "2018"
//!
//! [dependencies]
//! structopt = "0.3.9"
//! syn = { version = "1.0.16", default-features = false, features = ["clone-impls"] }
//! ```

use structopt::clap::AppSettings;
use structopt::StructOpt;

#[derive(StructOpt)]
#[structopt(settings = &[AppSettings::DeriveDisplayOrder, AppSettings::UnifiedHelpMessage])] // same as `#[structopt(settings(..))]`
struct Opt {}

fn main() {
    println!("Hello, world!");
}

Moreover, I found structopt cannot be build with the default features..

//    Compiling structopt-derive v0.4.2
// error[E0277]: the trait bound `syn::expr::Expr: std::clone::Clone` is not satisfied
//   --> /home/ryo/.cargo/registry/src/github.com-1ecc6299db9ec823/structopt-derive-0.4.2/src/attrs.rs:28:10
//    |
// 28 |     Skip(Option<Expr>),
//    |          ^^^^^^^^^^^^
//    |          |
//    |          expected an implementor of trait `std::clone::Clone`
//    |          help: consider borrowing here: `&Option<Expr>`
//    |
//    = note: required because of the requirements on the impl of `std::clone::Clone` for `std::option::Option<syn::expr::Expr>`
//    = note: required by `std::clone::Clone::clone`
//
// error[E0277]: the trait bound `syn::ty::Type: std::clone::Clone` is not satisfied
//   --> /home/ryo/.cargo/registry/src/github.com-1ecc6299db9ec823/structopt-derive-0.4.2/src/attrs.rs:81:5
//    |
// 81 |     ty: Option<Type>,
//    |     ^^^^^^^^^^^^^^^^
//    |     |
//    |     expected an implementor of trait `std::clone::Clone`
//    |     help: consider borrowing here: `&ty: Option<Type>`
//    |
//    = note: required because of the requirements on the impl of `std::clone::Clone` for `std::option::Option<syn::ty::Type>`
//    = note: required by `std::clone::Clone::clone`
//
// error[E0599]: no method named `clone` found for type `syn::ty::Type` in the current scope
//    --> /home/ryo/.cargo/registry/src/github.com-1ecc6299db9ec823/structopt-derive-0.4.2/src/attrs.rs:425:27
//     |
// 425 |             Some(field.ty.clone()),
//     |                           ^^^^^ method not found in `syn::ty::Type`
//
// error[E0277]: the trait bound `syn::token::Eq: std::clone::Clone` is not satisfied
//    --> /home/ryo/.cargo/registry/src/github.com-1ecc6299db9ec823/structopt-derive-0.4.2/src/parse.rs:198:5
//     |
// 198 |     pub eq_token: Option<Token![=]>,
//     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//     |     |
//     |     expected an implementor of trait `std::clone::Clone`
//     |     help: consider borrowing here: `&pub eq_token: Option<Token![=]>`
//     |
//     = note: required because of the requirements on the impl of `std::clone::Clone` for `std::option::Option<syn::token::Eq>`
//     = note: required by `std::clone::Clone::clone`
//
// error[E0277]: the trait bound `syn::expr::Expr: std::clone::Clone` is not satisfied
//    --> /home/ryo/.cargo/registry/src/github.com-1ecc6299db9ec823/structopt-derive-0.4.2/src/parse.rs:199:5
//     |
// 199 |     pub parse_func: Option<Expr>,
//     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//     |     |
//     |     expected an implementor of trait `std::clone::Clone`
//     |     help: consider borrowing here: `&pub parse_func: Option<Expr>`
//     |
//     = note: required because of the requirements on the impl of `std::clone::Clone` for `std::option::Option<syn::expr::Expr>`
//     = note: required by `std::clone::Clone::clone`
//
// error: aborting due to 5 previous errors
//
// Some errors have detailed explanations: E0277, E0599.
// For more information about an error, try `rustc --explain E0277`.
// error: could not compile `structopt-derive`.

//! ## Cargo.toml
//!
//! ```toml
//! [package]
//! name = "a"
//! version = "0.0.0"
//! edition = "2018"
//!
//! [dependencies]
//! structopt = "0.3.9" # `syn/clone-impls` is necessary!
//! ```

fn main() {}

@est31
Copy link
Owner

est31 commented Feb 29, 2020

Yeah, cargo update removes the rustversion dep because of the update of the proc-macro-error and proc-macro-error-attr crates.

For some reason, when I run cargo update on master, I can't reproduce the issue...

Anyways, I think we should just add the full feature to syn in Cargo.toml and call it a day.

@est31
Copy link
Owner

est31 commented Feb 29, 2020

Yeah I can reproduce when I 1. cargo update and 2. do cargo +nightly check -Z features=dev_dep.

@qryxip
Copy link
Collaborator

qryxip commented Feb 29, 2020

I reproduce the issue with cargo install.

cargo-udepspretty_assertions (dev) → ctor seems to enable syn/full in cargo build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants