diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2022-02-09 17:17:04 -0500 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2022-02-20 18:58:22 -0500 |
| commit | a421b631ba0af42878250174e57ee25b8f7dbf03 (patch) | |
| tree | 59b47df9a1ab4c1c90a367a3842743c0ee34e789 /compiler/rustc_macros/src | |
| parent | c87060a72d68f7df1feaaa395437ce33e9856399 (diff) | |
Delete read_enum_variant_arg
Diffstat (limited to 'compiler/rustc_macros/src')
| -rw-r--r-- | compiler/rustc_macros/src/serialize.rs | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/compiler/rustc_macros/src/serialize.rs b/compiler/rustc_macros/src/serialize.rs index 8d898291e58..2c4b794ffa1 100644 --- a/compiler/rustc_macros/src/serialize.rs +++ b/compiler/rustc_macros/src/serialize.rs @@ -96,19 +96,20 @@ fn decode_field(field: &syn::Field, index: usize, is_struct: bool) -> proc_macro } else { quote! { ::rustc_serialize::Decodable::decode } }; - let (decode_method, opt_field_name) = if is_struct { + let __decoder = quote! { __decoder }; + let decode_call = if is_struct { let field_name = field.ident.as_ref().map_or_else(|| index.to_string(), |i| i.to_string()); - (proc_macro2::Ident::new("read_struct_field", field_span), quote! { #field_name, }) + let decode_method = proc_macro2::Ident::new("read_struct_field", field_span); + // Use the span of the field for the method call, so + // that backtraces will point to the field. + quote_spanned! {field_span=> + ::rustc_serialize::Decoder::#decode_method( + #__decoder, #field_name, #decode_inner_method) + } } else { - (proc_macro2::Ident::new("read_enum_variant_arg", field_span), quote! {}) - }; - - let __decoder = quote! { __decoder }; - // Use the span of the field for the method call, so - // that backtraces will point to the field. - let decode_call = quote_spanned! {field_span=> - ::rustc_serialize::Decoder::#decode_method( - #__decoder, #opt_field_name #decode_inner_method) + // Use the span of the field for the method call, so + // that backtraces will point to the field. + quote_spanned! {field_span=> #decode_inner_method(#__decoder) } }; quote! { #decode_call } |
