@@ -96,19 +96,20 @@ fn decode_field(field: &syn::Field, index: usize, is_struct: bool) -> proc_macro
9696 } else {
9797 quote ! { :: rustc_serialize:: Decodable :: decode }
9898 } ;
99- let ( decode_method, opt_field_name) = if is_struct {
99+ let __decoder = quote ! { __decoder } ;
100+ let decode_call = if is_struct {
100101 let field_name = field. ident . as_ref ( ) . map_or_else ( || index. to_string ( ) , |i| i. to_string ( ) ) ;
101- ( proc_macro2:: Ident :: new ( "read_struct_field" , field_span) , quote ! { #field_name, } )
102+ let decode_method = proc_macro2:: Ident :: new ( "read_struct_field" , field_span) ;
103+ // Use the span of the field for the method call, so
104+ // that backtraces will point to the field.
105+ quote_spanned ! { field_span=>
106+ :: rustc_serialize:: Decoder :: #decode_method(
107+ #__decoder, #field_name, #decode_inner_method)
108+ }
102109 } else {
103- ( proc_macro2:: Ident :: new ( "read_enum_variant_arg" , field_span) , quote ! { } )
104- } ;
105-
106- let __decoder = quote ! { __decoder } ;
107- // Use the span of the field for the method call, so
108- // that backtraces will point to the field.
109- let decode_call = quote_spanned ! { field_span=>
110- :: rustc_serialize:: Decoder :: #decode_method(
111- #__decoder, #opt_field_name #decode_inner_method)
110+ // Use the span of the field for the method call, so
111+ // that backtraces will point to the field.
112+ quote_spanned ! { field_span=> #decode_inner_method( #__decoder) }
112113 } ;
113114
114115 quote ! { #decode_call }
0 commit comments