diff --git a/test_suite/tests/expand/de_enum.expanded.rs b/test_suite/tests/expand/de_enum.expanded.rs index d47c1406..f9ba2297 100644 --- a/test_suite/tests/expand/de_enum.expanded.rs +++ b/test_suite/tests/expand/de_enum.expanded.rs @@ -1,4 +1,4 @@ -use serde::Deserialize; +use serde::{Deserialize, Serialize}; enum DeEnum { Unit, Seq(i8, B, C, D), @@ -8,6 +8,258 @@ enum DeEnum { _Map2 { a: i8, b: B, c: C, d: D }, } #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)] +const _IMPL_SERIALIZE_FOR_DeEnum: () = { + #[allow(unknown_lints)] + #[allow(rust_2018_idioms)] + extern crate serde as _serde; + #[automatically_derived] + impl _serde::Serialize for DeEnum + where + B: _serde::Serialize, + C: _serde::Serialize, + D: _serde::Serialize, + { + fn serialize<__S>(&self, __serializer: __S) -> _serde::export::Result<__S::Ok, __S::Error> + where + __S: _serde::Serializer, + { + match *self { + DeEnum::Unit => { + _serde::Serializer::serialize_unit_variant(__serializer, "DeEnum", 0u32, "Unit") + } + DeEnum::Seq(ref __field0, ref __field1, ref __field2, ref __field3) => { + let mut __serde_state = match _serde::Serializer::serialize_tuple_variant( + __serializer, + "DeEnum", + 1u32, + "Seq", + 0 + 1 + 1 + 1 + 1, + ) { + _serde::export::Ok(__val) => __val, + _serde::export::Err(__err) => { + return _serde::export::Err(__err); + } + }; + match _serde::ser::SerializeTupleVariant::serialize_field( + &mut __serde_state, + __field0, + ) { + _serde::export::Ok(__val) => __val, + _serde::export::Err(__err) => { + return _serde::export::Err(__err); + } + }; + match _serde::ser::SerializeTupleVariant::serialize_field( + &mut __serde_state, + __field1, + ) { + _serde::export::Ok(__val) => __val, + _serde::export::Err(__err) => { + return _serde::export::Err(__err); + } + }; + match _serde::ser::SerializeTupleVariant::serialize_field( + &mut __serde_state, + __field2, + ) { + _serde::export::Ok(__val) => __val, + _serde::export::Err(__err) => { + return _serde::export::Err(__err); + } + }; + match _serde::ser::SerializeTupleVariant::serialize_field( + &mut __serde_state, + __field3, + ) { + _serde::export::Ok(__val) => __val, + _serde::export::Err(__err) => { + return _serde::export::Err(__err); + } + }; + _serde::ser::SerializeTupleVariant::end(__serde_state) + } + DeEnum::Map { + ref a, + ref b, + ref c, + ref d, + } => { + let mut __serde_state = match _serde::Serializer::serialize_struct_variant( + __serializer, + "DeEnum", + 2u32, + "Map", + 0 + 1 + 1 + 1 + 1, + ) { + _serde::export::Ok(__val) => __val, + _serde::export::Err(__err) => { + return _serde::export::Err(__err); + } + }; + match _serde::ser::SerializeStructVariant::serialize_field( + &mut __serde_state, + "a", + a, + ) { + _serde::export::Ok(__val) => __val, + _serde::export::Err(__err) => { + return _serde::export::Err(__err); + } + }; + match _serde::ser::SerializeStructVariant::serialize_field( + &mut __serde_state, + "b", + b, + ) { + _serde::export::Ok(__val) => __val, + _serde::export::Err(__err) => { + return _serde::export::Err(__err); + } + }; + match _serde::ser::SerializeStructVariant::serialize_field( + &mut __serde_state, + "c", + c, + ) { + _serde::export::Ok(__val) => __val, + _serde::export::Err(__err) => { + return _serde::export::Err(__err); + } + }; + match _serde::ser::SerializeStructVariant::serialize_field( + &mut __serde_state, + "d", + d, + ) { + _serde::export::Ok(__val) => __val, + _serde::export::Err(__err) => { + return _serde::export::Err(__err); + } + }; + _serde::ser::SerializeStructVariant::end(__serde_state) + } + DeEnum::_Unit2 => _serde::Serializer::serialize_unit_variant( + __serializer, + "DeEnum", + 3u32, + "_Unit2", + ), + DeEnum::_Seq2(ref __field0, ref __field1, ref __field2, ref __field3) => { + let mut __serde_state = match _serde::Serializer::serialize_tuple_variant( + __serializer, + "DeEnum", + 4u32, + "_Seq2", + 0 + 1 + 1 + 1 + 1, + ) { + _serde::export::Ok(__val) => __val, + _serde::export::Err(__err) => { + return _serde::export::Err(__err); + } + }; + match _serde::ser::SerializeTupleVariant::serialize_field( + &mut __serde_state, + __field0, + ) { + _serde::export::Ok(__val) => __val, + _serde::export::Err(__err) => { + return _serde::export::Err(__err); + } + }; + match _serde::ser::SerializeTupleVariant::serialize_field( + &mut __serde_state, + __field1, + ) { + _serde::export::Ok(__val) => __val, + _serde::export::Err(__err) => { + return _serde::export::Err(__err); + } + }; + match _serde::ser::SerializeTupleVariant::serialize_field( + &mut __serde_state, + __field2, + ) { + _serde::export::Ok(__val) => __val, + _serde::export::Err(__err) => { + return _serde::export::Err(__err); + } + }; + match _serde::ser::SerializeTupleVariant::serialize_field( + &mut __serde_state, + __field3, + ) { + _serde::export::Ok(__val) => __val, + _serde::export::Err(__err) => { + return _serde::export::Err(__err); + } + }; + _serde::ser::SerializeTupleVariant::end(__serde_state) + } + DeEnum::_Map2 { + ref a, + ref b, + ref c, + ref d, + } => { + let mut __serde_state = match _serde::Serializer::serialize_struct_variant( + __serializer, + "DeEnum", + 5u32, + "_Map2", + 0 + 1 + 1 + 1 + 1, + ) { + _serde::export::Ok(__val) => __val, + _serde::export::Err(__err) => { + return _serde::export::Err(__err); + } + }; + match _serde::ser::SerializeStructVariant::serialize_field( + &mut __serde_state, + "a", + a, + ) { + _serde::export::Ok(__val) => __val, + _serde::export::Err(__err) => { + return _serde::export::Err(__err); + } + }; + match _serde::ser::SerializeStructVariant::serialize_field( + &mut __serde_state, + "b", + b, + ) { + _serde::export::Ok(__val) => __val, + _serde::export::Err(__err) => { + return _serde::export::Err(__err); + } + }; + match _serde::ser::SerializeStructVariant::serialize_field( + &mut __serde_state, + "c", + c, + ) { + _serde::export::Ok(__val) => __val, + _serde::export::Err(__err) => { + return _serde::export::Err(__err); + } + }; + match _serde::ser::SerializeStructVariant::serialize_field( + &mut __serde_state, + "d", + d, + ) { + _serde::export::Ok(__val) => __val, + _serde::export::Err(__err) => { + return _serde::export::Err(__err); + } + }; + _serde::ser::SerializeStructVariant::end(__serde_state) + } + } + } + } +}; +#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)] const _IMPL_DESERIALIZE_FOR_DeEnum: () = { #[allow(unknown_lints)] #[allow(rust_2018_idioms)] diff --git a/test_suite/tests/expand/de_enum.rs b/test_suite/tests/expand/de_enum.rs index 642ea328..ac0c49b5 100644 --- a/test_suite/tests/expand/de_enum.rs +++ b/test_suite/tests/expand/de_enum.rs @@ -1,4 +1,4 @@ -use serde::Deserialize; +use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize)] enum DeEnum {