mirror of
https://github.com/serde-rs/serde.git
synced 2025-10-01 15:01:49 +00:00

error[E0424]: expected value, found module `self` --> test_suite/tests/regression/issue2844.rs:13:19 | 5 | #[derive(Serialize, Deserialize)] | --------- this function has a `self` parameter, but a macro invocation can only access identifiers it receives from parameters ... 13 | declare_in_macro!("with"); | ^^^^^^ `self` value is a keyword only available in methods with a `self` parameter error[E0425]: cannot find value `__s` in this scope --> test_suite/tests/regression/issue2844.rs:13:19 | 13 | declare_in_macro!("with"); | ^^^^^^ not found in this scope error[E0425]: cannot find value `__deserializer` in this scope --> test_suite/tests/regression/issue2844.rs:13:19 | 13 | declare_in_macro!("with"); | ^^^^^^ not found in this scope
32 lines
603 B
Rust
32 lines
603 B
Rust
use serde_derive::{Deserialize, Serialize};
|
|
|
|
macro_rules! declare_in_macro {
|
|
($with:literal) => {
|
|
#[derive(Serialize, Deserialize)]
|
|
pub struct S {
|
|
#[serde(with = $with)]
|
|
f: i32,
|
|
}
|
|
};
|
|
}
|
|
|
|
declare_in_macro!("with");
|
|
|
|
mod with {
|
|
use serde::{Deserializer, Serializer};
|
|
|
|
pub fn serialize<S>(_: &i32, _: S) -> Result<S::Ok, S::Error>
|
|
where
|
|
S: Serializer,
|
|
{
|
|
unimplemented!()
|
|
}
|
|
|
|
pub fn deserialize<'de, D>(_: D) -> Result<i32, D::Error>
|
|
where
|
|
D: Deserializer<'de>,
|
|
{
|
|
unimplemented!()
|
|
}
|
|
}
|