Conversation
|
Running |
|
For some reason serde_codegen by itself builds three times as fast this way, which I didn't expect. I guess quasi_macros is slow? |
fewer generics? |
|
I did some testing with rusoto in rusoto/rusoto#364 (comment) to see how performance of this PR compares with the current serde_macros (runtime performance, after they have been compiled). They come out about even which is great. |
Conflicts:
serde_codegen/Cargo.toml
serde_codegen_internals/Cargo.toml
serde_derive/Cargo.toml
Conflicts:
serde_codegen/src/ser.rs
|
There is a lot of work left here but let's take a moment to celebrate 9a86e68 the first syntex-free green build. |
Conflicts:
serde_codegen/Cargo.toml
|
@oli-obk @erickt this is ready for review. There were a few places that I uncovered strange behavior in the old codegen (just unusually placed semicolons / parentheses / braces) that I went out of my way to preserve. I left comments and I can clean that up in a separate PR. I confirmed that this PR expands the test suite byte-for-byte identical to master. I filed #562 to follow up. I filed #561 as another follow-up task. I don't think that needs to block this PR. |
|
Awesome progress @dtolnay! |
oli-obk
left a comment
There was a problem hiding this comment.
This is totally great. I have no complaints that should be seen as blockers. Let's do this!
serde_codegen/src/de.rs
Outdated
| Some(quote!(::<#(ty_param_idents),*>)) | ||
| }; | ||
|
|
||
| let phantom_exprs = (0 .. num_phantoms).map(|_| quote!(::std::marker::PhantomData)); |
There was a problem hiding this comment.
std::iter::repeat(quote!(::std::marker::PhantomData)).take(num_phantoms) runs the expanded quote code only once. Not really relevant though.
| struct __Visitor #generics ( #(phantom_types),* ) #where_clause; | ||
| }, | ||
| quote!(__Visitor <#(all_params),*> ), | ||
| quote!(__Visitor #ty_param_idents ( #(phantom_exprs),* )), |
| extern crate aster; | ||
| extern crate quasi; | ||
| // The `quote!` macro requires deep recursion. | ||
| #![recursion_limit = "192"] |
There was a problem hiding this comment.
I'm through with serde_codegen. Big 👍 on the quote! call readability.
There was a problem hiding this comment.
I agree. I love how've much simpler everything looks.
| use std::cell::RefCell; | ||
|
|
||
| #[derive(Default)] | ||
| pub struct Ctxt { |
There was a problem hiding this comment.
I'm not very happy with the Ctxt structure and it's usage. I'd much rather have regular Result type error reporting, but we can leave that to a future refactoring. Maybe the code gets horribly cluttered with Result
There was a problem hiding this comment.
I filed #563 to follow up in a future refactoring.
erickt
left a comment
There was a problem hiding this comment.
This wasn't amazing. Great work.
| extern crate aster; | ||
| extern crate quasi; | ||
| // The `quote!` macro requires deep recursion. | ||
| #![recursion_limit = "192"] |
There was a problem hiding this comment.
I agree. I love how've much simpler everything looks.
| $type_ident::$variant_ident(ref __simple_value) => $block | ||
| ) | ||
| quote! { | ||
| // The braces are unnecessary but quasi used to put them in. We |
There was a problem hiding this comment.
If I recall correctly, quote_block required the extra braces, so shouldn't be a problem to remove them later.
Conflicts:
serde_macros/tests/compile-fail/reject-unknown-attributes.rs
rustc_macro_deriverust-lang/rust#36211Follow-up tasks: