@@ -96,19 +96,20 @@ fn decode_field(field: &syn::Field, index: usize, is_struct: bool) -> proc_macro
96
96
} else {
97
97
quote ! { :: rustc_serialize:: Decodable :: decode }
98
98
} ;
99
- let ( decode_method, opt_field_name) = if is_struct {
99
+ let __decoder = quote ! { __decoder } ;
100
+ let decode_call = if is_struct {
100
101
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
+ }
102
109
} 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) }
112
113
} ;
113
114
114
115
quote ! { #decode_call }
0 commit comments