Coder Social home page Coder Social logo

0.15 breaks Display about strum HOT 11 CLOSED

peternator7 avatar peternator7 commented on May 21, 2024
0.15 breaks Display

from strum.

Comments (11)

D4nte avatar D4nte commented on May 21, 2024 1

Fine after a cargo clean...

from strum.

Peternator7 avatar Peternator7 commented on May 21, 2024

Thanks for reporting this issue! I'm not able to repro it though :( Could you let me know what version of rustc you're using, and potentially try running cargo clean before you build if you've got a little time?

from strum.

D4nte avatar D4nte commented on May 21, 2024

Oh, actually the issue is when running clippy!

"cargo" "clippy" "--" "-W" "clippy::cast_possible_truncation" "-W" "clippy::cast_sign_loss" "-W" "clippy::fallible_impl_from" "-W" "clippy::cast_precision_loss" "-W" "clippy::cast_possible_wrap" "-W" "clippy::print_stdout" "-W" "clippy::dbg_macro" "-D" "warnings"
▶ rustc --version
rustc 1.35.0-nightly (96d700f1b 2019-04-10)
▶ cargo clippy --version
clippy 0.0.212 (37f5c1ec 2019-04-09)

from strum.

D4nte avatar D4nte commented on May 21, 2024

To reproduce, check out 864-ethereum-htlc-crate branch of https://github.com/comit-network/comit-rs

Update strum from 0.14 to 0.15 in ./vendor/blockchain_contracts/Cargo.toml

run the clippy command above

from strum.

D4nte avatar D4nte commented on May 21, 2024

I upgraded to nightly-2019-04-30 and it is fine now. Maybe it's just me...

from strum.

D4nte avatar D4nte commented on May 21, 2024

Ok so now it fails on travis: https://travis-ci.com/comit-network/comit-rs/builds/110209768

If you checkout https://github.com/comit-network/comit-rs branch strum and run the clippy command: "cargo" "clippy" "--" "-W" "clippy::cast_possible_truncation" "-W" "clippy::cast_sign_loss" you should be able to reproduce the issue.

from strum.

Peternator7 avatar Peternator7 commented on May 21, 2024

I think I understand what is happening. This seems like a psuedo-diamond-dependency issue.

0.15 added the ability to rename packages using feature flags, and in your repo, this file sets the "verbose-display-name" feature flag which changes the plugin from Display to StrumDisplay. That appears to be changing the name globally across all your crates.

I was able to set up a tiny repro with 2 crates in the same cargo "workspace." One of them set "verbose-display-name" and the other doesn't. If I call cargo build in the root it fails because Display cannot be found. If I cd into each directory individually though, both build separately. Cargo can't seem to use different combinations of feature flags in the same workspace.

This seems to be a cargo issue (by design?).

from strum.

D4nte avatar D4nte commented on May 21, 2024

@Peternator7 alright, make sense. Any chance you could push the tiny repo somewhere so we can report the issue to cargo?

from strum.

thomaseizinger avatar thomaseizinger commented on May 21, 2024

That appears to be changing the name globally across all your crates.

I think, this is actually expected behaviour within cargo/rust. As soon as there is a dependency within your dependency tree that enables a certain feature, you cannot depend on the same dependency without that feature. I am not sure but depending on different versions might work because they result in different binary code.

from strum.

Peternator7 avatar Peternator7 commented on May 21, 2024

I peeked at your code. Macro renaming is mostly for old versions of rustc. If you're importing derives by path, you shouldn't need to use them. You can do this:

#[derive(Clone, Copy, strum_macros::Display, Debug, Serialize)]
#[strum(serialize_all = "snake_case")]
pub enum DataName {
    SecretHash,
    Expiry,
    RedeemIdentity,
    RefundIdentity,
    TokenQuantity,
    TokenContract,
}

Edit: I will also acknowledge that it's perhaps not worth fixing if it works :)

from strum.

D4nte avatar D4nte commented on May 21, 2024

Thanks!

from strum.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.