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

Project doesn't build with tonic dependency #60

Closed
herr-seppia opened this issue Nov 29, 2021 · 0 comments · Fixed by #61
Closed

Project doesn't build with tonic dependency #60

herr-seppia opened this issue Nov 29, 2021 · 0 comments · Fixed by #61
Assignees
Labels
fix:bug Something isn't working team:WebTech End to End UX / UI and blockchain

Comments

@herr-seppia
Copy link
Member

Describe the bug
The project doesn't compile if the tonic dependency is added

To Reproduce
Add tonic dependency to Cargo.toml (I used 0.5 to avoid switching to Edition2021)

[dependencies]
...
tonic = "0.5.0"

Execute cargo check

$ cargo check
    Checking kadcast v0.1.0
error[E0382]: use of moved value: `nodes`
   --> src/lib.rs:111:17
    |
107 |         table_read.all_sorted().for_each(|(h, nodes)| {
    |                                               ----- move occurs because `nodes` has type `impl Iterator`, which does not implement the `Copy` trait
...
111 |                 nodes.map(|p| p.value().address()).join(",")
    |                 ^^^^^ ---------------------------- `nodes` moved due to this method call
    |                 |
    |                 value used here after move
    |
note: this function takes ownership of the receiver `self`, which moves `nodes`
   --> ~/.rustup/toolchains/nightly-2021-06-06-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:681:18
    |
681 |     fn map<B, F>(self, f: F) -> Map<Self, F>
    |                  ^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0382`.
error: could not compile `kadcast`

To learn more, run the command again with --verbose.

Expected behaviour

$ cargo b
   Compiling kadcast v0.1.0
    Finished dev [unoptimized + debuginfo] target(s) in 7.63s
@herr-seppia herr-seppia added fix:bug Something isn't working team:WebTech End to End UX / UI and blockchain labels Nov 29, 2021
@herr-seppia herr-seppia self-assigned this Nov 29, 2021
herr-seppia added a commit that referenced this issue Nov 29, 2021
herr-seppia added a commit that referenced this issue Nov 30, 2021
First issue:
The expanded code of `info!` macro changes when the `log` feature is
enable on the `tracing` crate. The expanded code performs a `move` of
the input parameters.
Said that, you will receive a compilation error if you are passing a
param which calls a `move` by itself (unless the param supports the
`Copy` trait)

For futher information related to the compilation error see:
#60

Second issue:
I suspect that `Cargo` is behaving wrong, because it enables a nested
dependency feature even if this feature is not explicit declared.
This happens for both `edition = "2021"` and `resolver = "2"`.
Indeed, in the case of the original issue, the `tonic` crate add the
`tower` traversal dependency which use the `tracing` crate with the
`log` feature enabled.

For futher information related to tower dependency see:
https://github.com/tower-rs/tower/blob/b20b3cbd5788727996510fb2e8db04623f60f8ee/tower/Cargo.toml#L27

Refactoring this way, we are sure there will be at most only one `move`

Resolves #60
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix:bug Something isn't working team:WebTech End to End UX / UI and blockchain
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant