Skip to content

Commit

Permalink
Substitute Self in output of Serialize derive
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jan 25, 2021
1 parent 4d66e94 commit 9f0fbe8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions serde_derive/src/lib.rs
Expand Up @@ -79,8 +79,8 @@ mod try;

#[proc_macro_derive(Serialize, attributes(serde))]
pub fn derive_serialize(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as DeriveInput);
ser::expand_derive_serialize(&input)
let mut input = parse_macro_input!(input as DeriveInput);
ser::expand_derive_serialize(&mut input)
.unwrap_or_else(to_compile_errors)
.into()
}
Expand Down
8 changes: 6 additions & 2 deletions serde_derive/src/ser.rs
Expand Up @@ -6,10 +6,14 @@ use bound;
use dummy;
use fragment::{Fragment, Match, Stmts};
use internals::ast::{Container, Data, Field, Style, Variant};
use internals::{attr, Ctxt, Derive};
use internals::{attr, replace_receiver, Ctxt, Derive};
use pretend;

pub fn expand_derive_serialize(input: &syn::DeriveInput) -> Result<TokenStream, Vec<syn::Error>> {
pub fn expand_derive_serialize(
input: &mut syn::DeriveInput,
) -> Result<TokenStream, Vec<syn::Error>> {
replace_receiver(input);

let ctxt = Ctxt::new();
let cont = match Container::from_ast(&ctxt, input, Derive::Serialize) {
Some(cont) => cont,
Expand Down

0 comments on commit 9f0fbe8

Please sign in to comment.