Skip to content

Commit 0058c72

Browse files
committed
Add regression test for issue 2844
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
1 parent 29d4f3e commit 0058c72

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
use serde_derive::{Deserialize, Serialize};
2+
3+
macro_rules! declare_in_macro {
4+
($with:literal) => {
5+
#[derive(Serialize, Deserialize)]
6+
pub struct S {
7+
#[serde(with = $with)]
8+
f: i32,
9+
}
10+
};
11+
}
12+
13+
declare_in_macro!("with");
14+
15+
mod with {
16+
use serde::{Deserializer, Serializer};
17+
18+
pub fn serialize<S>(_: &i32, _: S) -> Result<S::Ok, S::Error>
19+
where
20+
S: Serializer,
21+
{
22+
unimplemented!()
23+
}
24+
25+
pub fn deserialize<'de, D>(_: D) -> Result<i32, D::Error>
26+
where
27+
D: Deserializer<'de>,
28+
{
29+
unimplemented!()
30+
}
31+
}

0 commit comments

Comments
 (0)