Reimport of Serialize and Deserialize
Closed this issue · 9 comments
Hi there,
The current master branch is broken because you are reimporting Serialize and Deserialize in the src/serde_impl.rs here.
Please fix.
Can you please describe your problem? The current master works and is not broken. The explanation for importing Deserialize
and Serialize
two times is that the line
use serde::{Deserialize, Deserializer, Serialize, Serializer};
imports the traits and the line
use serde_derive::{Deserialize, Serialize};
imports the derive macros. Therefore different constructs are imported and there is no reimport.
When trying to build my crate, I get the following error:
.cargo/registry/src/github.com-1ecc6299db9ec823/threshold_crypto-0.3.0/src/serde_impl.rs:10:20
|
9 | use serde::{Deserialize, Deserializer, Serialize, Serializer};
| ----------- previous import of the macro Deserialize
here
10 | use serde_derive::{Deserialize, Serialize};
| ^^^^^^^^^^^--
| |
| Deserialize
reimported here
| help: remove unnecessary import
|
= note: Deserialize
must be defined only once in the macro namespace of this module
and get the same for Serialize
Can I see your crate?
I forked threshold_crypto and upgraded to serde 1.0.89 and simply included the "derive" feature. I then removed all mentions of serde_derive and simply use the serde::Serialize and serde::Deserialize.
If you clone threshold_crypto and try cargo test
, it will not work when using 1.33.0 nightly:
rustc 1.33.0-nightly (daa53a52a 2019-01-17)
I would suggest not to make use of serde and serde_derive in the same file.
Also, your code is causing troubles for rand 0.6.5... Overall this crate doesn't build in it's current form (at least on my laptop)
error[E0277]: the trait bound rand_hc::Hc128Rng: rand_core::SeedableRng
is not satisfied
--> /Users/****/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.6.5/src/rngs/std.rs:55:6
|
55 | impl SeedableRng for StdRng {
| ^^^^^^^^^^^ the trait rand_core::SeedableRng
is not implemented for rand_hc::Hc128Rng
error[E0277]: the trait bound rand_isaac::IsaacRng: rand_core::SeedableRng
is not satisfied
--> /Users/****/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.6.5/src/deprecated.rs:50:6
|
50 | impl SeedableRng for IsaacRng {
| ^^^^^^^^^^^ the trait rand_core::SeedableRng
is not implemented for rand_isaac::IsaacRng
error[E0277]: the trait bound rand_isaac::Isaac64Rng: rand_core::SeedableRng
is not satisfied
--> /Users/****/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.6.5/src/deprecated.rs:96:6
|
96 | impl SeedableRng for Isaac64Rng {
| ^^^^^^^^^^^ the trait rand_core::SeedableRng
is not implemented for rand_isaac::Isaac64Rng
error[E0277]: the trait bound rand_chacha::ChaChaRng: rand_core::SeedableRng
is not satisfied
--> /Users/****/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.6.5/src/deprecated.rs:141:6
|
141 | impl SeedableRng for ChaChaRng {
| ^^^^^^^^^^^ the trait rand_core::SeedableRng
is not implemented for rand_chacha::ChaChaRng
error[E0277]: the trait bound rand_hc::Hc128Rng: rand_core::SeedableRng
is not satisfied
--> /Users/****/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.6.5/src/deprecated.rs:198:6
|
198 | impl SeedableRng for Hc128Rng {
| ^^^^^^^^^^^ the trait rand_core::SeedableRng
is not implemented for rand_hc::Hc128Rng
error[E0277]: the trait bound rand_xorshift::XorShiftRng: rand_core::SeedableRng
is not satisfied
--> /Users/****/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.6.5/src/deprecated.rs:239:6
|
239 | impl SeedableRng for XorShiftRng {
| ^^^^^^^^^^^ the trait rand_core::SeedableRng
is not implemented for rand_xorshift::XorShiftRng
error[E0277]: the trait bound rand_hc::Hc128Rng: rand_core::SeedableRng
is not satisfied
--> /Users/****/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.6.5/src/deprecated.rs:279:6
|
279 | impl SeedableRng for StdRng {
| ^^^^^^^^^^^ the trait rand_core::SeedableRng
is not implemented for rand_hc::Hc128Rng
error[E0277]: the trait bound rand_hc::Hc128Core: rand_core::block::BlockRngCore
is not satisfied
--> /Users/****/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.6.5/src/rngs/thread.rs:73:5
|
73 | rng: *mut ReseedingRng<Hc128Core, EntropyRng>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait rand_core::block::BlockRngCore
is not implemented for rand_hc::Hc128Core
|
note: required by rngs::adapter::reseeding::ReseedingRng
Nightly is at 1.35.0 now. I tried cargo clippy
with the current stable 1.33.0 and it compiled OK with no errors. Also I updated the versions of serde_derive
to 0.6.5 and rand
to 1.0.89 and it sill compiled with no errors.
Try stable 1.33 or the latest nightly. Do you have the same errors then?
@vkomenda, yes that is the same patch that applied locally to circumvent this issue.
Thanks, I merged the fix!
(But did you try cargo update
? I imagine that would also have resolved the problems?)