Skip to content
Myr

Merge pull request #2558 from Mingun/correct-span

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Improve error reporting about mismatched signature in `with` and `default` attributes

authored by Oli Scherer · committed by GitHub · parents 8b0f482, 74b538b · Browse files · 27 files+628 added−13 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

27 files+628 added−13 removed

  • tests:+569 added−0 removed
  • other:+59 added−13 removed

27 files+628 added−13 removed

modified:serde_derive/src/internals/attr.rs+5 added-4 removed
6 unmodified lines
7use std::iter::FromIterator;8use syn::meta::ParseNestedMeta;9use syn::parse::ParseStream;10use syn::punctuated::Punctuated;11use syn::spanned::Spanned;12use syn::{parse_quote, token, Ident, Lifetime, Token};1314// This module handles parsing of `#[serde(...)]` attributes. The entrypoints15// are `attr::Container::from_ast`, `attr::Variant::from_ast`, and
872 unmodified lines
888 let mut ser_path = path.clone();889 ser_path890 .path891 .segments891 .push(Ident::new("serialize", Span::call_site()).into());892 .push(Ident::new("serialize", ser_path.span()).into());893 serialize_with.set(&meta.path, ser_path);894 let mut de_path = path;895 de_path896 .path897 .segments897 .push(Ident::new("deserialize", Span::call_site()).into());898 .push(Ident::new("deserialize", de_path.span()).into());899 deserialize_with.set(&meta.path, de_path);900 }901 } else if meta.path == SERIALIZE_WITH {902 // #[serde(serialize_with = "...")]
267 unmodified lines
1170 let mut ser_path = path.clone();1171 ser_path1172 .path1173 .segments1173 .push(Ident::new("serialize", Span::call_site()).into());1174 .push(Ident::new("serialize", ser_path.span()).into());1175 serialize_with.set(&meta.path, ser_path);1176 let mut de_path = path;1177 de_path1178 .path1179 .segments1179 .push(Ident::new("deserialize", Span::call_site()).into());1180 .push(Ident::new("deserialize", de_path.span()).into());1181 deserialize_with.set(&meta.path, de_path);1182 }1183 } else if meta.path == BOUND {1184 // #[serde(bound = "T: SomeBound")]
688 unmodified lines
modified:serde_derive/src/de.rs+47 added-8 removed
369 unmodified lines
370 quote!(#member: __transparent)371 } else {372 let value = match field.attrs.default() {373 attr::Default::Default => quote!(_serde::__private::Default::default()),374 // If #path returns wrong type, error will be reported here (^^^^^).375 // We attach span of the path to the function so it will be reported376 // on the #[serde(default = "...")]377 // ^^^^^374 attr::Default::Path(path) => quote!(#path()),378 attr::Default::Path(path) => quote_spanned!(path.span()=> #path()),379 attr::Default::None => quote!(_serde::__private::PhantomData),380 };381 quote!(#member: #value)382 }
377 unmodified lines
760 let let_default = match cattrs.default() {761 attr::Default::Default => Some(quote!(762 let __default: Self::Value = _serde::__private::Default::default();763 )),764 // If #path returns wrong type, error will be reported here (^^^^^).765 // We attach span of the path to the function so it will be reported766 // on the #[serde(default = "...")]767 // ^^^^^760 attr::Default::Path(path) => Some(quote!(768 attr::Default::Path(path) => Some(quote_spanned!(path.span()=>769 let __default: Self::Value = #path();770 )),771 attr::Default::None => {772 // We don't need the default value, to prevent an unused variable warning
73 unmodified lines
846 let let_default = match cattrs.default() {847 attr::Default::Default => Some(quote!(848 let __default: #this_type #ty_generics = _serde::__private::Default::default();849 )),850 // If #path returns wrong type, error will be reported here (^^^^^).851 // We attach span of the path to the function so it will be reported852 // on the #[serde(default = "...")]853 // ^^^^^842 attr::Default::Path(path) => Some(quote!(854 attr::Default::Path(path) => Some(quote_spanned!(path.span()=>855 let __default: #this_type #ty_generics = #path();856 )),857 attr::Default::None => {858 // We don't need the default value, to prevent an unused variable warning
25 unmodified lines
884 #func(__e)?885 }886 }887 Some(path) => {876 quote! {888 // If #path returns wrong type, error will be reported here (^^^^^).889 // We attach span of the path to the function so it will be reported890 // on the #[serde(with = "...")]891 // ^^^^^892 quote_spanned! {path.span()=>893 #path(__e)?894 }895 }896 };
1765 unmodified lines
2662 let let_default = match cattrs.default() {2663 attr::Default::Default => Some(quote!(2664 let __default: Self::Value = _serde::__private::Default::default();2665 )),2666 // If #path returns wrong type, error will be reported here (^^^^^).2667 // We attach span of the path to the function so it will be reported2668 // on the #[serde(default = "...")]2669 // ^^^^^2650 attr::Default::Path(path) => Some(quote!(2670 attr::Default::Path(path) => Some(quote_spanned!(path.span()=>2671 let __default: Self::Value = #path();2672 )),2673 attr::Default::None => {2674 // We don't need the default value, to prevent an unused variable warning
161 unmodified lines
2836 let let_default = match cattrs.default() {2837 attr::Default::Default => Some(quote!(2838 let __default: #this_type #ty_generics = _serde::__private::Default::default();2839 )),2840 // If #path returns wrong type, error will be reported here (^^^^^).2841 // We attach span of the path to the function so it will be reported2842 // on the #[serde(default = "...")]2843 // ^^^^^2820 attr::Default::Path(path) => Some(quote!(2844 attr::Default::Path(path) => Some(quote_spanned!(path.span()=>2845 let __default: #this_type #ty_generics = #path();2846 )),2847 attr::Default::None => {2848 // We don't need the default value, to prevent an unused variable warning
30 unmodified lines
2879 let (de_impl_generics, de_ty_generics, ty_generics, where_clause) =2880 split_with_de_lifetime(params);2881 let delife = params.borrowed.de_lifetime();28822883 // If #deserialize_with returns wrong type, error will be reported here (^^^^^).2884 // We attach span of the path to the function so it will be reported2885 // on the #[serde(with = "...")]2886 // ^^^^^2887 let value = quote_spanned! {deserialize_with.span()=>2888 #deserialize_with(__deserializer)?2889 };2890 let wrapper = quote! {2891 #[doc(hidden)]2892 struct __DeserializeWith #de_impl_generics #where_clause {2893 value: #value_ty,
6 unmodified lines
2900 where2901 __D: _serde::Deserializer<#delife>,2902 {2903 _serde::__private::Ok(__DeserializeWith {2873 value: #deserialize_with(__deserializer)?,2904 value: #value,2905 phantom: _serde::__private::PhantomData,2906 lifetime: _serde::__private::PhantomData,2907 })2908 }
82 unmodified lines
2991 let func = quote_spanned!(span=> _serde::__private::Default::default);2992 return quote_expr!(#func());2993 }2994 attr::Default::Path(path) => {2964 return quote_expr!(#path());2995 // If #path returns wrong type, error will be reported here (^^^^^).2996 // We attach span of the path to the function so it will be reported2997 // on the #[serde(default = "...")]2998 // ^^^^^2999 return Fragment::Expr(quote_spanned!(path.span()=> #path()));3000 }3001 attr::Default::None => { /* below */ }3002 }3003
34 unmodified lines
3038 let span = field.original.span();3039 return quote_spanned!(span=> #assign_to _serde::__private::Default::default());3040 }3041 attr::Default::Path(path) => {3042 // If #path returns wrong type, error will be reported here (^^^^^).3043 // We attach span of the path to the function so it will be reported3044 // on the #[serde(default = "...")]3045 // ^^^^^3046 return quote_spanned!(path.span()=> #assign_to #path());3047 }3048 attr::Default::None => { /* below */ }3049 }
162 unmodified lines
modified:serde_derive/src/ser.rs+7 added-1 removed
1218 unmodified lines
1219 span: Span::call_site(),1220 })1221 });12221223 quote!({1223 // If #serialize_with returns wrong type, error will be reported on here.1224 // We attach span of the path to this piece so error will be reported1225 // on the #[serde(with = "...")]1226 // ^^^^^1227 quote_spanned!(serialize_with.span()=> {1228 #[doc(hidden)]1229 struct __SerializeWith #wrapper_impl_generics #where_clause {1230 // If #field_tys is empty, `values` does not used1231 #[allow(dead_code)]1232 values: (#(&'__a #field_tys, )*),1233 phantom: _serde::__private::PhantomData<#this_type #ty_generics>,1234 }1235
121 unmodified lines
added:test_suite/tests/ui/default-attribute/incorrect_type_enum_adjacently_tagged.rs+22 added
1//! Ensures that error message points to the path in attribute2use serde_derive::Deserialize;34#[derive(Deserialize)]5#[serde(tag = "tag", content = "content")]6enum Enum {7 // Newtype variants does not use the provided path, so it is forbidden here8 // Newtype(#[serde(default = "main")] u8),9 Tuple(10 u8,11 #[serde(default = "main")] i8,12 ),13 Struct {14 #[serde(default = "main")]15 f1: u8,16 f2: u8,17 #[serde(default = "main")]18 f3: i8,19 },20}2122fn main() {}
added:test_suite/tests/ui/default-attribute/incorrect_type_enum_adjacently_tagged.stderr+35 added
1error[E0308]: `match` arms have incompatible types2 --> tests/ui/default-attribute/incorrect_type_enum_adjacently_tagged.rs:11:273 |44 | #[derive(Deserialize)]5 | -----------6 | |7 | this is found to be of type `i8`8 | `match` arms have incompatible types9...1011 | #[serde(default = "main")] i8,11 | ^^^^^^ expected `i8`, found `()`1213error[E0308]: `match` arms have incompatible types14 --> tests/ui/default-attribute/incorrect_type_enum_adjacently_tagged.rs:14:2715 |164 | #[derive(Deserialize)]17 | -----------18 | |19 | this is found to be of type `u8`20 | `match` arms have incompatible types21...2214 | #[serde(default = "main")]23 | ^^^^^^ expected `u8`, found `()`2425error[E0308]: `match` arms have incompatible types26 --> tests/ui/default-attribute/incorrect_type_enum_adjacently_tagged.rs:17:2727 |284 | #[derive(Deserialize)]29 | -----------30 | |31 | this is found to be of type `i8`32 | `match` arms have incompatible types33...3417 | #[serde(default = "main")]35 | ^^^^^^ expected `i8`, found `()`
added:test_suite/tests/ui/default-attribute/incorrect_type_enum_externally_tagged.rs+21 added
1//! Ensures that error message points to the path in attribute2use serde_derive::Deserialize;34#[derive(Deserialize)]5enum Enum {6 // Newtype variants does not use the provided path, so it is forbidden here7 // Newtype(#[serde(default = "main")] u8),8 Tuple(9 u8,10 #[serde(default = "main")] i8,11 ),12 Struct {13 #[serde(default = "main")]14 f1: u8,15 f2: u8,16 #[serde(default = "main")]17 f3: i8,18 },19}2021fn main() {}
added:test_suite/tests/ui/default-attribute/incorrect_type_enum_externally_tagged.stderr+35 added
1error[E0308]: `match` arms have incompatible types2 --> tests/ui/default-attribute/incorrect_type_enum_externally_tagged.rs:10:273 |44 | #[derive(Deserialize)]5 | -----------6 | |7 | this is found to be of type `i8`8 | `match` arms have incompatible types9...1010 | #[serde(default = "main")] i8,11 | ^^^^^^ expected `i8`, found `()`1213error[E0308]: `match` arms have incompatible types14 --> tests/ui/default-attribute/incorrect_type_enum_externally_tagged.rs:13:2715 |164 | #[derive(Deserialize)]17 | -----------18 | |19 | this is found to be of type `u8`20 | `match` arms have incompatible types21...2213 | #[serde(default = "main")]23 | ^^^^^^ expected `u8`, found `()`2425error[E0308]: `match` arms have incompatible types26 --> tests/ui/default-attribute/incorrect_type_enum_externally_tagged.rs:16:2727 |284 | #[derive(Deserialize)]29 | -----------30 | |31 | this is found to be of type `i8`32 | `match` arms have incompatible types33...3416 | #[serde(default = "main")]35 | ^^^^^^ expected `i8`, found `()`
added:test_suite/tests/ui/default-attribute/incorrect_type_enum_internally_tagged.rs+19 added
1//! Ensures that error message points to the path in attribute2use serde_derive::Deserialize;34#[derive(Deserialize)]5#[serde(tag = "tag")]6enum Enum {7 // Newtype variants does not use the provided path, so it is forbidden here8 // Newtype(#[serde(default = "main")] u8),9 // Tuple variants does not supported in internally tagged enums10 Struct {11 #[serde(default = "main")]12 f1: u8,13 f2: u8,14 #[serde(default = "main")]15 f3: i8,16 },17}1819fn main() {}
added:test_suite/tests/ui/default-attribute/incorrect_type_enum_internally_tagged.stderr+23 added
1error[E0308]: `match` arms have incompatible types2 --> tests/ui/default-attribute/incorrect_type_enum_internally_tagged.rs:11:273 |44 | #[derive(Deserialize)]5 | -----------6 | |7 | this is found to be of type `u8`8 | `match` arms have incompatible types9...1011 | #[serde(default = "main")]11 | ^^^^^^ expected `u8`, found `()`1213error[E0308]: `match` arms have incompatible types14 --> tests/ui/default-attribute/incorrect_type_enum_internally_tagged.rs:14:2715 |164 | #[derive(Deserialize)]17 | -----------18 | |19 | this is found to be of type `i8`20 | `match` arms have incompatible types21...2214 | #[serde(default = "main")]23 | ^^^^^^ expected `i8`, found `()`
added:test_suite/tests/ui/default-attribute/incorrect_type_enum_untagged.rs+22 added
1//! Ensures that error message points to the path in attribute2use serde_derive::Deserialize;34#[derive(Deserialize)]5#[serde(untagged)]6enum Enum {7 // Newtype variants does not use the provided path, so it is forbidden here8 // Newtype(#[serde(default = "main")] u8),9 Tuple(10 u8,11 #[serde(default = "main")] i8,12 ),13 Struct {14 #[serde(default = "main")]15 f1: u8,16 f2: u8,17 #[serde(default = "main")]18 f3: i8,19 },20}2122fn main() {}
added:test_suite/tests/ui/default-attribute/incorrect_type_enum_untagged.stderr+35 added
1error[E0308]: `match` arms have incompatible types2 --> tests/ui/default-attribute/incorrect_type_enum_untagged.rs:11:273 |44 | #[derive(Deserialize)]5 | -----------6 | |7 | this is found to be of type `i8`8 | `match` arms have incompatible types9...1011 | #[serde(default = "main")] i8,11 | ^^^^^^ expected `i8`, found `()`1213error[E0308]: `match` arms have incompatible types14 --> tests/ui/default-attribute/incorrect_type_enum_untagged.rs:14:2715 |164 | #[derive(Deserialize)]17 | -----------18 | |19 | this is found to be of type `u8`20 | `match` arms have incompatible types21...2214 | #[serde(default = "main")]23 | ^^^^^^ expected `u8`, found `()`2425error[E0308]: `match` arms have incompatible types26 --> tests/ui/default-attribute/incorrect_type_enum_untagged.rs:17:2727 |284 | #[derive(Deserialize)]29 | -----------30 | |31 | this is found to be of type `i8`32 | `match` arms have incompatible types33...3417 | #[serde(default = "main")]35 | ^^^^^^ expected `i8`, found `()`
added:test_suite/tests/ui/default-attribute/incorrect_type_newtype.rs+8 added
1//! Ensures that error message points to the path in attribute2use serde_derive::Deserialize;34#[derive(Deserialize)]5#[serde(default = "main")]6struct Newtype(#[serde(default = "main")] u8);78fn main() {}
added:test_suite/tests/ui/default-attribute/incorrect_type_newtype.stderr+37 added
1error[E0308]: mismatched types2 --> tests/ui/default-attribute/incorrect_type_newtype.rs:5:193 |45 | #[serde(default = "main")]5 | ^^^^^^6 | |7 | expected `Newtype`, found `()`8 | expected due to this910error[E0308]: `match` arms have incompatible types11 --> tests/ui/default-attribute/incorrect_type_newtype.rs:6:3412 |134 | #[derive(Deserialize)]14 | -----------15 | |16 | this is found to be of type `u8`17 | `match` arms have incompatible types185 | #[serde(default = "main")]196 | struct Newtype(#[serde(default = "main")] u8);20 | ^^^^^^ expected `u8`, found `()`2122error[E0308]: mismatched types23 --> tests/ui/default-attribute/incorrect_type_newtype.rs:5:1924 |255 | #[serde(default = "main")]26 | ^^^^^^ expected `Newtype`, found `()`276 | struct Newtype(#[serde(default = "main")] u8);28 | ------- expected due to this2930error[E0308]: mismatched types31 --> tests/ui/default-attribute/incorrect_type_newtype.rs:6:3432 |334 | #[derive(Deserialize)]34 | ----------- expected due to the type of this binding355 | #[serde(default = "main")]366 | struct Newtype(#[serde(default = "main")] u8);37 | ^^^^^^ expected `u8`, found `()`
added:test_suite/tests/ui/default-attribute/incorrect_type_struct.rs+14 added
1//! Ensures that error message points to the path in attribute2use serde_derive::Deserialize;34#[derive(Deserialize)]5#[serde(default = "main")]6struct Struct {7 #[serde(default = "main")]8 f1: u8,9 f2: u8,10 #[serde(default = "main")]11 f3: i8,12}1314fn main() {}
added:test_suite/tests/ui/default-attribute/incorrect_type_struct.stderr+58 added
1error[E0308]: mismatched types2 --> tests/ui/default-attribute/incorrect_type_struct.rs:5:193 |45 | #[serde(default = "main")]5 | ^^^^^^6 | |7 | expected `Struct`, found `()`8 | expected due to this910error[E0308]: `match` arms have incompatible types11 --> tests/ui/default-attribute/incorrect_type_struct.rs:7:2312 |134 | #[derive(Deserialize)]14 | -----------15 | |16 | this is found to be of type `u8`17 | `match` arms have incompatible types18...197 | #[serde(default = "main")]20 | ^^^^^^ expected `u8`, found `()`2122error[E0308]: `match` arms have incompatible types23 --> tests/ui/default-attribute/incorrect_type_struct.rs:10:2324 |254 | #[derive(Deserialize)]26 | -----------27 | |28 | this is found to be of type `i8`29 | `match` arms have incompatible types30...3110 | #[serde(default = "main")]32 | ^^^^^^ expected `i8`, found `()`3334error[E0308]: mismatched types35 --> tests/ui/default-attribute/incorrect_type_struct.rs:5:1936 |375 | #[serde(default = "main")]38 | ^^^^^^ expected `Struct`, found `()`396 | struct Struct {40 | ------ expected due to this4142error[E0308]: mismatched types43 --> tests/ui/default-attribute/incorrect_type_struct.rs:7:2344 |454 | #[derive(Deserialize)]46 | ----------- expected due to the type of this binding47...487 | #[serde(default = "main")]49 | ^^^^^^ expected `u8`, found `()`5051error[E0308]: mismatched types52 --> tests/ui/default-attribute/incorrect_type_struct.rs:10:2353 |544 | #[derive(Deserialize)]55 | ----------- expected due to the type of this binding56...5710 | #[serde(default = "main")]58 | ^^^^^^ expected `i8`, found `()`
added:test_suite/tests/ui/default-attribute/incorrect_type_tuple.rs+11 added
1//! Ensures that error message points to the path in attribute2use serde_derive::Deserialize;34#[derive(Deserialize)]5#[serde(default = "main")]6struct Tuple(7 u8,8 #[serde(default = "main")] i8,9);1011fn main() {}
added:test_suite/tests/ui/default-attribute/incorrect_type_tuple.stderr+37 added
1error[E0308]: mismatched types2 --> tests/ui/default-attribute/incorrect_type_tuple.rs:5:193 |45 | #[serde(default = "main")]5 | ^^^^^^6 | |7 | expected `Tuple`, found `()`8 | expected due to this910error[E0308]: `match` arms have incompatible types11 --> tests/ui/default-attribute/incorrect_type_tuple.rs:8:2312 |134 | #[derive(Deserialize)]14 | -----------15 | |16 | this is found to be of type `i8`17 | `match` arms have incompatible types18...198 | #[serde(default = "main")] i8,20 | ^^^^^^ expected `i8`, found `()`2122error[E0308]: mismatched types23 --> tests/ui/default-attribute/incorrect_type_tuple.rs:5:1924 |255 | #[serde(default = "main")]26 | ^^^^^^ expected `Tuple`, found `()`276 | struct Tuple(28 | ----- expected due to this2930error[E0308]: mismatched types31 --> tests/ui/default-attribute/incorrect_type_tuple.rs:8:2332 |334 | #[derive(Deserialize)]34 | ----------- expected due to the type of this binding35...368 | #[serde(default = "main")] i8,37 | ^^^^^^ expected `i8`, found `()`
added:test_suite/tests/ui/default-attribute/union_path.rs+9 added
1use serde_derive::Deserialize;23#[derive(Deserialize)]4#[serde(default = "default_u")]5union Union {6 f: u8,7}89fn main() {}
added:test_suite/tests/ui/default-attribute/union_path.stderr+14 added
1error: #[serde(default = "...")] can only be used on structs2 --> tests/ui/default-attribute/union_path.rs:4:93 |44 | #[serde(default = "default_u")]5 | ^^^^^^^^^^^^^^^^^^^^^67error: Serde does not support derive for unions8 --> tests/ui/default-attribute/union_path.rs:4:19 |104 | / #[serde(default = "default_u")]115 | | union Union {126 | | f: u8,137 | | }14 | |_^
added:test_suite/tests/ui/default-attribute/union.rs+9 added
1use serde_derive::Deserialize;23#[derive(Deserialize)]4#[serde(default)]5union Union {6 f: u8,7}89fn main() {}
added:test_suite/tests/ui/default-attribute/union.stderr+14 added
1error: #[serde(default)] can only be used on structs2 --> tests/ui/default-attribute/union.rs:4:93 |44 | #[serde(default)]5 | ^^^^^^^67error: Serde does not support derive for unions8 --> tests/ui/default-attribute/union.rs:4:19 |104 | / #[serde(default)]115 | | union Union {126 | | f: u8,137 | | }14 | |_^
added:test_suite/tests/ui/default-attribute/unit_path.rs+7 added
1use serde_derive::Deserialize;23#[derive(Deserialize)]4#[serde(default = "default_u")]5struct Unit;67fn main() {}
added:test_suite/tests/ui/default-attribute/unit_path.stderr+5 added
1error: #[serde(default = "...")] can only be used on structs that have fields2 --> tests/ui/default-attribute/unit_path.rs:4:93 |44 | #[serde(default = "default_u")]5 | ^^^^^^^^^^^^^^^^^^^^^
added:test_suite/tests/ui/default-attribute/unit.rs+7 added
1use serde_derive::Deserialize;23#[derive(Deserialize)]4#[serde(default)]5struct Unit;67fn main() {}
added:test_suite/tests/ui/default-attribute/unit.stderr+7 added
1error: #[serde(default)] can only be used on structs that have fields2 --> tests/ui/default-attribute/unit.rs:3:103 |43 | #[derive(Deserialize)]5 | ^^^^^^^^^^^6 |7 = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)
added:test_suite/tests/ui/with/incorrect_type.rs+23 added
1use serde_derive::{Deserialize, Serialize};23mod w {4 use serde::{Deserializer, Serializer};56 pub fn deserialize<'de, D: Deserializer<'de>>(_: D) -> Result<(), D::Error> {7 unimplemented!()8 }9 pub fn serialize<T, S: Serializer>(_: S) -> Result<S::Ok, S::Error> {10 unimplemented!()11 }12}1314#[derive(Serialize, Deserialize)]15struct W(#[serde(with = "w")] u8, u8);1617#[derive(Serialize, Deserialize)]18struct S(#[serde(serialize_with = "w::serialize")] u8, u8);1920#[derive(Serialize, Deserialize)]21struct D(#[serde(deserialize_with = "w::deserialize")] u8, u8);2223fn main() {}
added:test_suite/tests/ui/with/incorrect_type.stderr+97 added
1error[E0277]: the trait bound `&u8: Serializer` is not satisfied2 --> tests/ui/with/incorrect_type.rs:14:103 |414 | #[derive(Serialize, Deserialize)]5 | ^^^^^^^^^ the trait `Serializer` is not implemented for `&u8`615 | struct W(#[serde(with = "w")] u8, u8);7 | --- required by a bound introduced by this call8 |9 = help: the following other types implement trait `Serializer`:10 &'a mut Formatter<'b>11 FlatMapSerializer<'a, M>12 _::_serde::__private::ser::content::ContentSerializer<E>13note: required by a bound in `w::serialize`14 --> tests/ui/with/incorrect_type.rs:9:2815 |169 | pub fn serialize<T, S: Serializer>(_: S) -> Result<S::Ok, S::Error> {17 | ^^^^^^^^^^ required by this bound in `serialize`1819error[E0061]: this function takes 1 argument but 2 arguments were supplied20 --> tests/ui/with/incorrect_type.rs:15:2521 |2215 | struct W(#[serde(with = "w")] u8, u8);23 | ^^^ unexpected argument #2 of type `__S`24 |25note: function defined here26 --> tests/ui/with/incorrect_type.rs:9:1227 |289 | pub fn serialize<T, S: Serializer>(_: S) -> Result<S::Ok, S::Error> {29 | ^^^^^^^^^ ----3031error[E0277]: the trait bound `&u8: Serializer` is not satisfied32 --> tests/ui/with/incorrect_type.rs:15:2533 |3415 | struct W(#[serde(with = "w")] u8, u8);35 | ^^^ the trait `Serializer` is not implemented for `&u8`36 |37 = help: the following other types implement trait `Serializer`:38 &'a mut Formatter<'b>39 FlatMapSerializer<'a, M>40 _::_serde::__private::ser::content::ContentSerializer<E>4142error[E0308]: `?` operator has incompatible types43 --> tests/ui/with/incorrect_type.rs:15:2544 |4515 | struct W(#[serde(with = "w")] u8, u8);46 | ^^^ expected `u8`, found `()`47 |48 = note: `?` operator cannot convert from `()` to `u8`4950error[E0277]: the trait bound `&u8: Serializer` is not satisfied51 --> tests/ui/with/incorrect_type.rs:17:1052 |5317 | #[derive(Serialize, Deserialize)]54 | ^^^^^^^^^ the trait `Serializer` is not implemented for `&u8`5518 | struct S(#[serde(serialize_with = "w::serialize")] u8, u8);56 | -------------- required by a bound introduced by this call57 |58 = help: the following other types implement trait `Serializer`:59 &'a mut Formatter<'b>60 FlatMapSerializer<'a, M>61 _::_serde::__private::ser::content::ContentSerializer<E>62note: required by a bound in `w::serialize`63 --> tests/ui/with/incorrect_type.rs:9:2864 |659 | pub fn serialize<T, S: Serializer>(_: S) -> Result<S::Ok, S::Error> {66 | ^^^^^^^^^^ required by this bound in `serialize`6768error[E0061]: this function takes 1 argument but 2 arguments were supplied69 --> tests/ui/with/incorrect_type.rs:18:3570 |7118 | struct S(#[serde(serialize_with = "w::serialize")] u8, u8);72 | ^^^^^^^^^^^^^^ unexpected argument #2 of type `__S`73 |74note: function defined here75 --> tests/ui/with/incorrect_type.rs:9:1276 |779 | pub fn serialize<T, S: Serializer>(_: S) -> Result<S::Ok, S::Error> {78 | ^^^^^^^^^ ----7980error[E0277]: the trait bound `&u8: Serializer` is not satisfied81 --> tests/ui/with/incorrect_type.rs:18:3582 |8318 | struct S(#[serde(serialize_with = "w::serialize")] u8, u8);84 | ^^^^^^^^^^^^^^ the trait `Serializer` is not implemented for `&u8`85 |86 = help: the following other types implement trait `Serializer`:87 &'a mut Formatter<'b>88 FlatMapSerializer<'a, M>89 _::_serde::__private::ser::content::ContentSerializer<E>9091error[E0308]: `?` operator has incompatible types92 --> tests/ui/with/incorrect_type.rs:21:3793 |9421 | struct D(#[serde(deserialize_with = "w::deserialize")] u8, u8);95 | ^^^^^^^^^^^^^^^^ expected `u8`, found `()`96 |97 = note: `?` operator cannot convert from `()` to `u8`