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

serde 1.0.211 breaks with = "" inside of macros #2844

Closed
DaniPopes opened this issue Oct 22, 2024 · 3 comments · Fixed by #2845
Closed

serde 1.0.211 breaks with = "" inside of macros #2844

DaniPopes opened this issue Oct 22, 2024 · 3 comments · Fixed by #2845

Comments

@DaniPopes
Copy link

I tried this code:

macro_rules! declare_in_macro {
    ($with:literal) => {
        #[derive(serde::Serialize)]
        pub struct S {
            #[serde(with = $with)]
            f: i32,
        }
    };
}
declare_in_macro!("display");

mod display {
    pub fn serialize<S: serde::ser::Serializer>(_: &i32, _: S) -> Result<S::Ok, S::Error> {
        unimplemented!()
    }
}

with feature "derive":

  • serde 1.0.210 compiles
  • serde 1.0.211 fails with:
    error[E0424]: expected value, found module `self`
      --> src/lib.rs:10:19
       |
    3  |         #[derive(serde::Serialize)]
       |                  ---------------- this function has a `self` parameter, but a macro invocation can only access identifiers it receives from parameters
    ...
    10 | declare_in_macro!("display");
       |                   ^^^^^^^^^ `self` value is a keyword only available in methods with a `self` parameter
    
    error[E0425]: cannot find value `__s` in this scope
      --> src/lib.rs:10:19
       |
    10 | declare_in_macro!("display");
       |                   ^^^^^^^^^ not found in this scope

Also reported at #2558 (comment)

@OscarHedeby
Copy link

Not sure if this is the same error, also worked on serde v1.0.210 but not on v1.0.211

error[E0425]: cannot find value `__deserializer` in this scope
   --> /cargo-0.83.0/src/cargo/core/features.rs:759:32
    |
759 |     #[serde(deserialize_with = "deserialize_build_std")]
    |                                ^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value `__deserializer` in this scope
   --> /cargo-0.83.0/src/cargo/core/features.rs:770:32
    |
770 |     #[serde(deserialize_with = "deserialize_git_features")]
    |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value `__deserializer` in this scope
   --> /cargo-0.83.0/src/cargo/core/features.rs:772:32
    |
772 |     #[serde(deserialize_with = "deserialize_gitoxide_features")]
    |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

@oli-obk
Copy link
Member

oli-obk commented Oct 22, 2024

I wonder if this is a hygiene issue

@sffc
Copy link

sffc commented Oct 22, 2024

Serde 1.0.211 breaks ICU4X with errors such as

error[E0425]: cannot find value `__deserializer` in this scope
   --> /path/to/icu4x/components/datetime/src/provider/calendar/symbols.rs:269:40
    |
269 | ... = "icu_provider::serde_borrow_de_utils::array_of_cow"
    |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

hubot pushed a commit to aosp-mirror/platform_development that referenced this issue Oct 23, 2024
Versions since 1.0.211 cause a compilation failure in cargo:
serde-rs/serde#2844

Bug: http://b/374934724
Test: treehugger
Change-Id: I1672919865c6fdb96ab5dcdc0444a419a000de2f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

4 participants