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

[Bug] alloy-json-abi wrong version is selected causing serde to fail in compile-time. #1546

Closed
dgrr opened this issue Oct 22, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@dgrr
Copy link

dgrr commented Oct 22, 2024

Component

serde

What version of Alloy are you on?

alloy main branch

Operating System

macOS (Apple Silicon)

Describe the bug

Hello,

I've noticed an issue in some of my repos in which I use alloy. I suspect that the error is related to cargo selecting a different version of alloy.
I was not able to reproduce the error in my repos, but I managed to reproduced by cloning alloy and running cargo check. The output is the following:

➜  alloy git:(main) cargo check
    Checking alloy-json-rpc v0.5.2 (/private/tmp/alloy/crates/json-rpc)
    Checking alloy-consensus v0.5.2 (/private/tmp/alloy/crates/consensus)
    Checking hyper v1.5.0
    Checking aws-runtime v1.4.3
    Checking alloy-json-abi v0.8.9
    Checking alloy-rpc-types-mev v0.5.2 (/private/tmp/alloy/crates/rpc-types-mev)
    Checking alloy-rpc-types-anvil v0.5.2 (/private/tmp/alloy/crates/rpc-types-anvil)
    Checking alloy-rpc-types-debug v0.5.2 (/private/tmp/alloy/crates/rpc-types-debug)
    Checking alloy-eip5792 v0.5.2 (/private/tmp/alloy/crates/eip5792)
error[E0424]: expected value, found module `self`
  --> /Users/dario/.cargo/registry/src/index.crates.io-6f17d22bba15001f/alloy-json-abi-0.8.9/src/item.rs:70:42
   |
19 |             #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
   |                                                         --------- this function has a `self` parameter, but a macro invocation can only access identifiers it receives from parameters
...
70 |         #[serde(default, flatten, with = "serde_state_mutability_compat")]
   |                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `self` value is a keyword only available in methods with a `self` parameter

error[E0425]: cannot find value `__s` in this scope
  --> /Users/dario/.cargo/registry/src/index.crates.io-6f17d22bba15001f/alloy-json-abi-0.8.9/src/item.rs:70:42
   |
70 |         #[serde(default, flatten, with = "serde_state_mutability_compat")]
   |                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0424]: expected value, found module `self`
  --> /Users/dario/.cargo/registry/src/index.crates.io-6f17d22bba15001f/alloy-json-abi-0.8.9/src/item.rs:78:42
   |
19 |             #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
   |                                                         --------- this function has a `self` parameter, but a macro invocation can only access identifiers it receives from parameters
...
78 |         #[serde(default, flatten, with = "serde_state_mutability_compat")]
   |                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `self` value is a keyword only available in methods with a `self` parameter

error[E0425]: cannot find value `__s` in this scope
  --> /Users/dario/.cargo/registry/src/index.crates.io-6f17d22bba15001f/alloy-json-abi-0.8.9/src/item.rs:78:42
   |
78 |         #[serde(default, flatten, with = "serde_state_mutability_compat")]
   |                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0424]: expected value, found module `self`
  --> /Users/dario/.cargo/registry/src/index.crates.io-6f17d22bba15001f/alloy-json-abi-0.8.9/src/item.rs:86:42
   |
19 |             #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
   |                                                         --------- this function has a `self` parameter, but a macro invocation can only access identifiers it receives from parameters
...
86 |         #[serde(default, flatten, with = "serde_state_mutability_compat")]
   |                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `self` value is a keyword only available in methods with a `self` parameter

error[E0425]: cannot find value `__s` in this scope
  --> /Users/dario/.cargo/registry/src/index.crates.io-6f17d22bba15001f/alloy-json-abi-0.8.9/src/item.rs:86:42
   |
86 |         #[serde(default, flatten, with = "serde_state_mutability_compat")]
   |                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0424]: expected value, found module `self`
   --> /Users/dario/.cargo/registry/src/index.crates.io-6f17d22bba15001f/alloy-json-abi-0.8.9/src/item.rs:100:42
    |
19  |             #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
    |                                                         --------- this function has a `self` parameter, but a macro invocation can only access identifiers it receives from parameters
...
100 |         #[serde(default, flatten, with = "serde_state_mutability_compat")]
    |                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `self` value is a keyword only available in methods with a `self` parameter

error[E0425]: cannot find value `__s` in this scope
   --> /Users/dario/.cargo/registry/src/index.crates.io-6f17d22bba15001f/alloy-json-abi-0.8.9/src/item.rs:100:42
    |
100 |         #[serde(default, flatten, with = "serde_state_mutability_compat")]
    |                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value `__deserializer` in this scope
  --> /Users/dario/.cargo/registry/src/index.crates.io-6f17d22bba15001f/alloy-json-abi-0.8.9/src/item.rs:93:36
   |
93 |         #[serde(deserialize_with = "validate_identifier")]
   |                                    ^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value `__deserializer` in this scope
   --> /Users/dario/.cargo/registry/src/index.crates.io-6f17d22bba15001f/alloy-json-abi-0.8.9/src/item.rs:107:36
    |
107 |         #[serde(deserialize_with = "validate_identifier")]
    |                                    ^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value `__deserializer` in this scope
   --> /Users/dario/.cargo/registry/src/index.crates.io-6f17d22bba15001f/alloy-json-abi-0.8.9/src/item.rs:120:36
    |
120 |         #[serde(deserialize_with = "validate_identifier")]
    |                                    ^^^^^^^^^^^^^^^^^^^^^ not found in this scope

    Checking alloy-transport v0.5.2 (/private/tmp/alloy/crates/transport)
Some errors have detailed explanations: E0424, E0425.
For more information about an error, try `rustc --explain E0424`.
error: could not compile `alloy-json-abi` (lib) due to 11 previous errors
warning: build failed, waiting for other jobs to finish...
@dgrr dgrr added the bug Something isn't working label Oct 22, 2024
@ivanrg99
Copy link

Same issue if you create an empty project with cargo new sample_project, then cargo add alloy --features full and cargo check after.

Also happens on Ubuntu x64

@laibe
Copy link

laibe commented Oct 22, 2024

can confirm, same issues on macOS as described by @dgrr

rustup --version
rustup 1.27.1 (54dd3d00f 2024-04-24)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.80.0 (051478957 2024-07-21)`

@prestwich
Copy link
Member

cargo update && cargo check will now produce this for every project i've tried

> $ rustup --version
rustup 1.27.1 (54dd3d00f 2024-04-24)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.82.0 (f6e511eec 2024-10-15)

@prestwich
Copy link
Member

this appears to be a breaking change in serde, possibly accidental

It can be resolved as follows

cargo update -p serde --precise 1.0.210 && cargo update -p serde_derive --precise 1.0.210 && cargo c

@DaniPopes
Copy link
Member

Duplicate of alloy-rs/core#778. See alloy-rs/core#778 (comment).

@DaniPopes DaniPopes closed this as not planned Won't fix, can't repro, duplicate, stale Oct 22, 2024
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

5 participants