-
-
Notifications
You must be signed in to change notification settings - Fork 785
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2845 from dtolnay/withlocal
Fix hygiene of macro-generated local variable accesses in serde(with) wrappers
- Loading branch information
Showing
4 changed files
with
45 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
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!() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters