diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 476a0a933..1c1ae1d11 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,10 @@ jobs: - uses: actions/checkout@v3 - uses: dtolnay/rust-toolchain@nightly - run: cd test_suite && cargo test --features unstable + - uses: dtolnay/install@cargo-expand + if: github.event_name != 'pull_request' + - run: cd test_suite && cargo test --features expandtest --test expandtest -- --include-ignored + if: github.event_name != 'pull_request' windows: name: Test suite (windows) diff --git a/test_suite/Cargo.toml b/test_suite/Cargo.toml index ac746280d..adf0e0fbb 100644 --- a/test_suite/Cargo.toml +++ b/test_suite/Cargo.toml @@ -18,7 +18,8 @@ toolchain_find = "0.2" [dev-dependencies] fnv = "1.0" -macrotest = "=1.0.0" +macrotest = "=1.0.9" +prettyplease = "=0.1.14" rustversion = "1.0" serde = { path = "../serde", features = ["rc", "derive"] } serde_derive = { path = "../serde_derive", features = ["deserialize_in_place"] } diff --git a/test_suite/build.rs b/test_suite/build.rs index 4ead539fc..957af7629 100644 --- a/test_suite/build.rs +++ b/test_suite/build.rs @@ -18,12 +18,8 @@ fn has_cargo_expand() -> bool { .unwrap_or(false) } -fn has_rustfmt() -> bool { - toolchain_find::find_installed_component("rustfmt").is_some() -} - fn main() { - if cfg!(feature = "expandtest") && has_cargo_expand() && has_rustfmt() { + if cfg!(feature = "expandtest") && has_cargo_expand() { println!("cargo:rustc-cfg=expandtest"); } } diff --git a/test_suite/tests/expand/de_enum.expanded.rs b/test_suite/tests/expand/de_enum.expanded.rs index 4ea3b8383..f9cdf02b1 100644 --- a/test_suite/tests/expand/de_enum.expanded.rs +++ b/test_suite/tests/expand/de_enum.expanded.rs @@ -28,7 +28,12 @@ const _: () = { { match *self { DeEnum::Unit => { - _serde::Serializer::serialize_unit_variant(__serializer, "DeEnum", 0u32, "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( @@ -81,12 +86,7 @@ const _: () = { }; _serde::ser::SerializeTupleVariant::end(__serde_state) } - DeEnum::Map { - ref a, - ref b, - ref c, - ref d, - } => { + DeEnum::Map { ref a, ref b, ref c, ref d } => { let mut __serde_state = match _serde::Serializer::serialize_struct_variant( __serializer, "DeEnum", @@ -141,13 +141,20 @@ const _: () = { }; _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) => { + 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", @@ -198,12 +205,7 @@ const _: () = { }; _serde::ser::SerializeTupleVariant::end(__serde_state) } - DeEnum::_Map2 { - ref a, - ref b, - ref c, - ref d, - } => { + DeEnum::_Map2 { ref a, ref b, ref c, ref d } => { let mut __serde_state = match _serde::Serializer::serialize_struct_variant( __serializer, "DeEnum", @@ -274,7 +276,9 @@ const _: () = { C: _serde::Deserialize<'de>, D: _serde::Deserialize<'de>, { - fn deserialize<__D>(__deserializer: __D) -> _serde::__private::Result + fn deserialize<__D>( + __deserializer: __D, + ) -> _serde::__private::Result where __D: _serde::Deserializer<'de>, { @@ -294,9 +298,15 @@ const _: () = { &self, __formatter: &mut _serde::__private::Formatter, ) -> _serde::__private::fmt::Result { - _serde::__private::Formatter::write_str(__formatter, "variant identifier") + _serde::__private::Formatter::write_str( + __formatter, + "variant identifier", + ) } - fn visit_u64<__E>(self, __value: u64) -> _serde::__private::Result + fn visit_u64<__E>( + self, + __value: u64, + ) -> _serde::__private::Result where __E: _serde::de::Error, { @@ -307,10 +317,14 @@ const _: () = { 3u64 => _serde::__private::Ok(__Field::__field3), 4u64 => _serde::__private::Ok(__Field::__field4), 5u64 => _serde::__private::Ok(__Field::__field5), - _ => _serde::__private::Err(_serde::de::Error::invalid_value( - _serde::de::Unexpected::Unsigned(__value), - &"variant index 0 <= i < 6", - )), + _ => { + _serde::__private::Err( + _serde::de::Error::invalid_value( + _serde::de::Unexpected::Unsigned(__value), + &"variant index 0 <= i < 6", + ), + ) + } } } fn visit_str<__E>( @@ -327,9 +341,11 @@ const _: () = { "_Unit2" => _serde::__private::Ok(__Field::__field3), "_Seq2" => _serde::__private::Ok(__Field::__field4), "_Map2" => _serde::__private::Ok(__Field::__field5), - _ => _serde::__private::Err(_serde::de::Error::unknown_variant( - __value, VARIANTS, - )), + _ => { + _serde::__private::Err( + _serde::de::Error::unknown_variant(__value, VARIANTS), + ) + } } } fn visit_bytes<__E>( @@ -348,9 +364,9 @@ const _: () = { b"_Map2" => _serde::__private::Ok(__Field::__field5), _ => { let __value = &_serde::__private::from_utf8_lossy(__value); - _serde::__private::Err(_serde::de::Error::unknown_variant( - __value, VARIANTS, - )) + _serde::__private::Err( + _serde::de::Error::unknown_variant(__value, VARIANTS), + ) } } } @@ -363,7 +379,10 @@ const _: () = { where __D: _serde::Deserializer<'de>, { - _serde::Deserializer::deserialize_identifier(__deserializer, __FieldVisitor) + _serde::Deserializer::deserialize_identifier( + __deserializer, + __FieldVisitor, + ) } } struct __Visitor<'de, B, C, D> @@ -420,7 +439,8 @@ const _: () = { marker: _serde::__private::PhantomData>, lifetime: _serde::__private::PhantomData<&'de ()>, } - impl<'de, B, C, D> _serde::de::Visitor<'de> for __Visitor<'de, B, C, D> + impl<'de, B, C, D> _serde::de::Visitor<'de> + for __Visitor<'de, B, C, D> where B: _serde::Deserialize<'de>, C: _serde::Deserialize<'de>, @@ -430,8 +450,7 @@ const _: () = { fn expecting( &self, __formatter: &mut _serde::__private::Formatter, - ) -> _serde::__private::fmt::Result - { + ) -> _serde::__private::fmt::Result { _serde::__private::Formatter::write_str( __formatter, "tuple variant DeEnum::Seq", @@ -447,9 +466,7 @@ const _: () = { { let __field0 = match match _serde::de::SeqAccess::next_element::< i8, - >( - &mut __seq - ) { + >(&mut __seq) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -467,9 +484,7 @@ const _: () = { }; let __field1 = match match _serde::de::SeqAccess::next_element::< B, - >( - &mut __seq - ) { + >(&mut __seq) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -487,9 +502,7 @@ const _: () = { }; let __field2 = match match _serde::de::SeqAccess::next_element::< C, - >( - &mut __seq - ) { + >(&mut __seq) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -507,9 +520,7 @@ const _: () = { }; let __field3 = match match _serde::de::SeqAccess::next_element::< D, - >( - &mut __seq - ) { + >(&mut __seq) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -525,9 +536,9 @@ const _: () = { ); } }; - _serde::__private::Ok(DeEnum::Seq( - __field0, __field1, __field2, __field3, - )) + _serde::__private::Ok( + DeEnum::Seq(__field0, __field1, __field2, __field3), + ) } } _serde::de::VariantAccess::tuple_variant( @@ -554,8 +565,7 @@ const _: () = { fn expecting( &self, __formatter: &mut _serde::__private::Formatter, - ) -> _serde::__private::fmt::Result - { + ) -> _serde::__private::fmt::Result { _serde::__private::Formatter::write_str( __formatter, "field identifier", @@ -630,7 +640,8 @@ const _: () = { marker: _serde::__private::PhantomData>, lifetime: _serde::__private::PhantomData<&'de ()>, } - impl<'de, B, C, D> _serde::de::Visitor<'de> for __Visitor<'de, B, C, D> + impl<'de, B, C, D> _serde::de::Visitor<'de> + for __Visitor<'de, B, C, D> where B: _serde::Deserialize<'de>, C: _serde::Deserialize<'de>, @@ -640,8 +651,7 @@ const _: () = { fn expecting( &self, __formatter: &mut _serde::__private::Formatter, - ) -> _serde::__private::fmt::Result - { + ) -> _serde::__private::fmt::Result { _serde::__private::Formatter::write_str( __formatter, "struct variant DeEnum::Map", @@ -657,9 +667,7 @@ const _: () = { { let __field0 = match match _serde::de::SeqAccess::next_element::< i8, - >( - &mut __seq - ) { + >(&mut __seq) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -677,9 +685,7 @@ const _: () = { }; let __field1 = match match _serde::de::SeqAccess::next_element::< B, - >( - &mut __seq - ) { + >(&mut __seq) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -697,9 +703,7 @@ const _: () = { }; let __field2 = match match _serde::de::SeqAccess::next_element::< C, - >( - &mut __seq - ) { + >(&mut __seq) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -717,9 +721,7 @@ const _: () = { }; let __field3 = match match _serde::de::SeqAccess::next_element::< D, - >( - &mut __seq - ) { + >(&mut __seq) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -750,32 +752,28 @@ const _: () = { where __A: _serde::de::MapAccess<'de>, { - let mut __field0: _serde::__private::Option = - _serde::__private::None; - let mut __field1: _serde::__private::Option = - _serde::__private::None; - let mut __field2: _serde::__private::Option = - _serde::__private::None; - let mut __field3: _serde::__private::Option = - _serde::__private::None; - while let _serde::__private::Some(__key) = - match _serde::de::MapAccess::next_key::<__Field>(&mut __map) - { + let mut __field0: _serde::__private::Option = _serde::__private::None; + let mut __field1: _serde::__private::Option = _serde::__private::None; + let mut __field2: _serde::__private::Option = _serde::__private::None; + let mut __field3: _serde::__private::Option = _serde::__private::None; + while let _serde::__private::Some(__key) + = match _serde::de::MapAccess::next_key::< + __Field, + >(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); } - } - { + } { match __key { __Field::__field0 => { if _serde::__private::Option::is_some(&__field0) { - return _serde :: __private :: Err (< __A :: Error as _serde :: de :: Error > :: duplicate_field ("a")) ; + return _serde::__private::Err( + <__A::Error as _serde::de::Error>::duplicate_field("a"), + ); } __field0 = _serde::__private::Some( - match _serde::de::MapAccess::next_value::( - &mut __map, - ) { + match _serde::de::MapAccess::next_value::(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -785,12 +783,12 @@ const _: () = { } __Field::__field1 => { if _serde::__private::Option::is_some(&__field1) { - return _serde :: __private :: Err (< __A :: Error as _serde :: de :: Error > :: duplicate_field ("b")) ; + return _serde::__private::Err( + <__A::Error as _serde::de::Error>::duplicate_field("b"), + ); } __field1 = _serde::__private::Some( - match _serde::de::MapAccess::next_value::( - &mut __map, - ) { + match _serde::de::MapAccess::next_value::(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -800,12 +798,12 @@ const _: () = { } __Field::__field2 => { if _serde::__private::Option::is_some(&__field2) { - return _serde :: __private :: Err (< __A :: Error as _serde :: de :: Error > :: duplicate_field ("c")) ; + return _serde::__private::Err( + <__A::Error as _serde::de::Error>::duplicate_field("c"), + ); } __field2 = _serde::__private::Some( - match _serde::de::MapAccess::next_value::( - &mut __map, - ) { + match _serde::de::MapAccess::next_value::(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -815,12 +813,12 @@ const _: () = { } __Field::__field3 => { if _serde::__private::Option::is_some(&__field3) { - return _serde :: __private :: Err (< __A :: Error as _serde :: de :: Error > :: duplicate_field ("d")) ; + return _serde::__private::Err( + <__A::Error as _serde::de::Error>::duplicate_field("d"), + ); } __field3 = _serde::__private::Some( - match _serde::de::MapAccess::next_value::( - &mut __map, - ) { + match _serde::de::MapAccess::next_value::(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -831,9 +829,7 @@ const _: () = { _ => { let _ = match _serde::de::MapAccess::next_value::< _serde::de::IgnoredAny, - >( - &mut __map - ) { + >(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -894,7 +890,12 @@ const _: () = { }) } } - const FIELDS: &'static [&'static str] = &["a", "b", "c", "d"]; + const FIELDS: &'static [&'static str] = &[ + "a", + "b", + "c", + "d", + ]; _serde::de::VariantAccess::struct_variant( __variant, FIELDS, @@ -923,7 +924,8 @@ const _: () = { marker: _serde::__private::PhantomData>, lifetime: _serde::__private::PhantomData<&'de ()>, } - impl<'de, B, C, D> _serde::de::Visitor<'de> for __Visitor<'de, B, C, D> + impl<'de, B, C, D> _serde::de::Visitor<'de> + for __Visitor<'de, B, C, D> where B: _serde::Deserialize<'de>, C: _serde::Deserialize<'de>, @@ -933,8 +935,7 @@ const _: () = { fn expecting( &self, __formatter: &mut _serde::__private::Formatter, - ) -> _serde::__private::fmt::Result - { + ) -> _serde::__private::fmt::Result { _serde::__private::Formatter::write_str( __formatter, "tuple variant DeEnum::_Seq2", @@ -950,9 +951,7 @@ const _: () = { { let __field0 = match match _serde::de::SeqAccess::next_element::< i8, - >( - &mut __seq - ) { + >(&mut __seq) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -970,9 +969,7 @@ const _: () = { }; let __field1 = match match _serde::de::SeqAccess::next_element::< B, - >( - &mut __seq - ) { + >(&mut __seq) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -990,9 +987,7 @@ const _: () = { }; let __field2 = match match _serde::de::SeqAccess::next_element::< C, - >( - &mut __seq - ) { + >(&mut __seq) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -1010,9 +1005,7 @@ const _: () = { }; let __field3 = match match _serde::de::SeqAccess::next_element::< D, - >( - &mut __seq - ) { + >(&mut __seq) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -1028,9 +1021,9 @@ const _: () = { ); } }; - _serde::__private::Ok(DeEnum::_Seq2( - __field0, __field1, __field2, __field3, - )) + _serde::__private::Ok( + DeEnum::_Seq2(__field0, __field1, __field2, __field3), + ) } } _serde::de::VariantAccess::tuple_variant( @@ -1057,8 +1050,7 @@ const _: () = { fn expecting( &self, __formatter: &mut _serde::__private::Formatter, - ) -> _serde::__private::fmt::Result - { + ) -> _serde::__private::fmt::Result { _serde::__private::Formatter::write_str( __formatter, "field identifier", @@ -1133,7 +1125,8 @@ const _: () = { marker: _serde::__private::PhantomData>, lifetime: _serde::__private::PhantomData<&'de ()>, } - impl<'de, B, C, D> _serde::de::Visitor<'de> for __Visitor<'de, B, C, D> + impl<'de, B, C, D> _serde::de::Visitor<'de> + for __Visitor<'de, B, C, D> where B: _serde::Deserialize<'de>, C: _serde::Deserialize<'de>, @@ -1143,8 +1136,7 @@ const _: () = { fn expecting( &self, __formatter: &mut _serde::__private::Formatter, - ) -> _serde::__private::fmt::Result - { + ) -> _serde::__private::fmt::Result { _serde::__private::Formatter::write_str( __formatter, "struct variant DeEnum::_Map2", @@ -1160,9 +1152,7 @@ const _: () = { { let __field0 = match match _serde::de::SeqAccess::next_element::< i8, - >( - &mut __seq - ) { + >(&mut __seq) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -1180,9 +1170,7 @@ const _: () = { }; let __field1 = match match _serde::de::SeqAccess::next_element::< B, - >( - &mut __seq - ) { + >(&mut __seq) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -1200,9 +1188,7 @@ const _: () = { }; let __field2 = match match _serde::de::SeqAccess::next_element::< C, - >( - &mut __seq - ) { + >(&mut __seq) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -1220,9 +1206,7 @@ const _: () = { }; let __field3 = match match _serde::de::SeqAccess::next_element::< D, - >( - &mut __seq - ) { + >(&mut __seq) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -1253,32 +1237,28 @@ const _: () = { where __A: _serde::de::MapAccess<'de>, { - let mut __field0: _serde::__private::Option = - _serde::__private::None; - let mut __field1: _serde::__private::Option = - _serde::__private::None; - let mut __field2: _serde::__private::Option = - _serde::__private::None; - let mut __field3: _serde::__private::Option = - _serde::__private::None; - while let _serde::__private::Some(__key) = - match _serde::de::MapAccess::next_key::<__Field>(&mut __map) - { + let mut __field0: _serde::__private::Option = _serde::__private::None; + let mut __field1: _serde::__private::Option = _serde::__private::None; + let mut __field2: _serde::__private::Option = _serde::__private::None; + let mut __field3: _serde::__private::Option = _serde::__private::None; + while let _serde::__private::Some(__key) + = match _serde::de::MapAccess::next_key::< + __Field, + >(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); } - } - { + } { match __key { __Field::__field0 => { if _serde::__private::Option::is_some(&__field0) { - return _serde :: __private :: Err (< __A :: Error as _serde :: de :: Error > :: duplicate_field ("a")) ; + return _serde::__private::Err( + <__A::Error as _serde::de::Error>::duplicate_field("a"), + ); } __field0 = _serde::__private::Some( - match _serde::de::MapAccess::next_value::( - &mut __map, - ) { + match _serde::de::MapAccess::next_value::(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -1288,12 +1268,12 @@ const _: () = { } __Field::__field1 => { if _serde::__private::Option::is_some(&__field1) { - return _serde :: __private :: Err (< __A :: Error as _serde :: de :: Error > :: duplicate_field ("b")) ; + return _serde::__private::Err( + <__A::Error as _serde::de::Error>::duplicate_field("b"), + ); } __field1 = _serde::__private::Some( - match _serde::de::MapAccess::next_value::( - &mut __map, - ) { + match _serde::de::MapAccess::next_value::(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -1303,12 +1283,12 @@ const _: () = { } __Field::__field2 => { if _serde::__private::Option::is_some(&__field2) { - return _serde :: __private :: Err (< __A :: Error as _serde :: de :: Error > :: duplicate_field ("c")) ; + return _serde::__private::Err( + <__A::Error as _serde::de::Error>::duplicate_field("c"), + ); } __field2 = _serde::__private::Some( - match _serde::de::MapAccess::next_value::( - &mut __map, - ) { + match _serde::de::MapAccess::next_value::(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -1318,12 +1298,12 @@ const _: () = { } __Field::__field3 => { if _serde::__private::Option::is_some(&__field3) { - return _serde :: __private :: Err (< __A :: Error as _serde :: de :: Error > :: duplicate_field ("d")) ; + return _serde::__private::Err( + <__A::Error as _serde::de::Error>::duplicate_field("d"), + ); } __field3 = _serde::__private::Some( - match _serde::de::MapAccess::next_value::( - &mut __map, - ) { + match _serde::de::MapAccess::next_value::(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -1334,9 +1314,7 @@ const _: () = { _ => { let _ = match _serde::de::MapAccess::next_value::< _serde::de::IgnoredAny, - >( - &mut __map - ) { + >(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -1397,7 +1375,12 @@ const _: () = { }) } } - const FIELDS: &'static [&'static str] = &["a", "b", "c", "d"]; + const FIELDS: &'static [&'static str] = &[ + "a", + "b", + "c", + "d", + ]; _serde::de::VariantAccess::struct_variant( __variant, FIELDS, @@ -1410,8 +1393,14 @@ const _: () = { } } } - const VARIANTS: &'static [&'static str] = - &["Unit", "Seq", "Map", "_Unit2", "_Seq2", "_Map2"]; + const VARIANTS: &'static [&'static str] = &[ + "Unit", + "Seq", + "Map", + "_Unit2", + "_Seq2", + "_Map2", + ]; _serde::Deserializer::deserialize_enum( __deserializer, "DeEnum", diff --git a/test_suite/tests/expand/default_ty_param.expanded.rs b/test_suite/tests/expand/default_ty_param.expanded.rs index 829e65e8e..4c2163f37 100644 --- a/test_suite/tests/expand/default_ty_param.expanded.rs +++ b/test_suite/tests/expand/default_ty_param.expanded.rs @@ -52,8 +52,11 @@ const _: () = { #[allow(unused_extern_crates, clippy::useless_attribute)] extern crate serde as _serde; #[automatically_derived] - impl<'de, T: AssociatedType> _serde::Deserialize<'de> for DefaultTyParam { - fn deserialize<__D>(__deserializer: __D) -> _serde::__private::Result + impl<'de, T: AssociatedType> _serde::Deserialize<'de> + for DefaultTyParam { + fn deserialize<__D>( + __deserializer: __D, + ) -> _serde::__private::Result where __D: _serde::Deserializer<'de>, { @@ -69,9 +72,15 @@ const _: () = { &self, __formatter: &mut _serde::__private::Formatter, ) -> _serde::__private::fmt::Result { - _serde::__private::Formatter::write_str(__formatter, "field identifier") + _serde::__private::Formatter::write_str( + __formatter, + "field identifier", + ) } - fn visit_u64<__E>(self, __value: u64) -> _serde::__private::Result + fn visit_u64<__E>( + self, + __value: u64, + ) -> _serde::__private::Result where __E: _serde::de::Error, { @@ -113,20 +122,27 @@ const _: () = { where __D: _serde::Deserializer<'de>, { - _serde::Deserializer::deserialize_identifier(__deserializer, __FieldVisitor) + _serde::Deserializer::deserialize_identifier( + __deserializer, + __FieldVisitor, + ) } } struct __Visitor<'de, T: AssociatedType> { marker: _serde::__private::PhantomData>, lifetime: _serde::__private::PhantomData<&'de ()>, } - impl<'de, T: AssociatedType> _serde::de::Visitor<'de> for __Visitor<'de, T> { + impl<'de, T: AssociatedType> _serde::de::Visitor<'de> + for __Visitor<'de, T> { type Value = DefaultTyParam; fn expecting( &self, __formatter: &mut _serde::__private::Formatter, ) -> _serde::__private::fmt::Result { - _serde::__private::Formatter::write_str(__formatter, "struct DefaultTyParam") + _serde::__private::Formatter::write_str( + __formatter, + "struct DefaultTyParam", + ) } #[inline] fn visit_seq<__A>( @@ -136,9 +152,9 @@ const _: () = { where __A: _serde::de::SeqAccess<'de>, { - let __field0 = match match _serde::de::SeqAccess::next_element::>( - &mut __seq, - ) { + let __field0 = match match _serde::de::SeqAccess::next_element::< + PhantomData, + >(&mut __seq) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -146,13 +162,17 @@ const _: () = { } { _serde::__private::Some(__value) => __value, _serde::__private::None => { - return _serde::__private::Err(_serde::de::Error::invalid_length( - 0usize, - &"struct DefaultTyParam with 1 element", - )); + return _serde::__private::Err( + _serde::de::Error::invalid_length( + 0usize, + &"struct DefaultTyParam with 1 element", + ), + ); } }; - _serde::__private::Ok(DefaultTyParam { phantom: __field0 }) + _serde::__private::Ok(DefaultTyParam { + phantom: __field0, + }) } #[inline] fn visit_map<__A>( @@ -162,16 +182,14 @@ const _: () = { where __A: _serde::de::MapAccess<'de>, { - let mut __field0: _serde::__private::Option> = - _serde::__private::None; - while let _serde::__private::Some(__key) = - match _serde::de::MapAccess::next_key::<__Field>(&mut __map) { + let mut __field0: _serde::__private::Option> = _serde::__private::None; + while let _serde::__private::Some(__key) + = match _serde::de::MapAccess::next_key::<__Field>(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); } - } - { + } { match __key { __Field::__field0 => { if _serde::__private::Option::is_some(&__field0) { @@ -182,9 +200,9 @@ const _: () = { ); } __field0 = _serde::__private::Some( - match _serde::de::MapAccess::next_value::>( - &mut __map, - ) { + match _serde::de::MapAccess::next_value::< + PhantomData, + >(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -195,8 +213,7 @@ const _: () = { _ => { let _ = match _serde::de::MapAccess::next_value::< _serde::de::IgnoredAny, - >(&mut __map) - { + >(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -216,7 +233,9 @@ const _: () = { } } }; - _serde::__private::Ok(DefaultTyParam { phantom: __field0 }) + _serde::__private::Ok(DefaultTyParam { + phantom: __field0, + }) } } const FIELDS: &'static [&'static str] = &["phantom"]; @@ -249,9 +268,15 @@ const _: () = { &self, __formatter: &mut _serde::__private::Formatter, ) -> _serde::__private::fmt::Result { - _serde::__private::Formatter::write_str(__formatter, "field identifier") + _serde::__private::Formatter::write_str( + __formatter, + "field identifier", + ) } - fn visit_u64<__E>(self, __value: u64) -> _serde::__private::Result + fn visit_u64<__E>( + self, + __value: u64, + ) -> _serde::__private::Result where __E: _serde::de::Error, { @@ -293,22 +318,30 @@ const _: () = { where __D: _serde::Deserializer<'de>, { - _serde::Deserializer::deserialize_identifier(__deserializer, __FieldVisitor) + _serde::Deserializer::deserialize_identifier( + __deserializer, + __FieldVisitor, + ) } } struct __Visitor<'de, 'place, T: AssociatedType + 'place> { place: &'place mut DefaultTyParam, lifetime: _serde::__private::PhantomData<&'de ()>, } - impl<'de, 'place, T: AssociatedType + 'place> _serde::de::Visitor<'de> - for __Visitor<'de, 'place, T> - { + impl< + 'de, + 'place, + T: AssociatedType + 'place, + > _serde::de::Visitor<'de> for __Visitor<'de, 'place, T> { type Value = (); fn expecting( &self, __formatter: &mut _serde::__private::Formatter, ) -> _serde::__private::fmt::Result { - _serde::__private::Formatter::write_str(__formatter, "struct DefaultTyParam") + _serde::__private::Formatter::write_str( + __formatter, + "struct DefaultTyParam", + ) } #[inline] fn visit_seq<__A>( @@ -318,19 +351,22 @@ const _: () = { where __A: _serde::de::SeqAccess<'de>, { - if let _serde::__private::None = match _serde::de::SeqAccess::next_element_seed( - &mut __seq, - _serde::__private::de::InPlaceSeed(&mut self.place.phantom), - ) { - _serde::__private::Ok(__val) => __val, - _serde::__private::Err(__err) => { - return _serde::__private::Err(__err); - } - } { - return _serde::__private::Err(_serde::de::Error::invalid_length( - 0usize, - &"struct DefaultTyParam with 1 element", - )); + if let _serde::__private::None + = match _serde::de::SeqAccess::next_element_seed( + &mut __seq, + _serde::__private::de::InPlaceSeed(&mut self.place.phantom), + ) { + _serde::__private::Ok(__val) => __val, + _serde::__private::Err(__err) => { + return _serde::__private::Err(__err); + } + } { + return _serde::__private::Err( + _serde::de::Error::invalid_length( + 0usize, + &"struct DefaultTyParam with 1 element", + ), + ); } _serde::__private::Ok(()) } @@ -343,14 +379,13 @@ const _: () = { __A: _serde::de::MapAccess<'de>, { let mut __field0: bool = false; - while let _serde::__private::Some(__key) = - match _serde::de::MapAccess::next_key::<__Field>(&mut __map) { + while let _serde::__private::Some(__key) + = match _serde::de::MapAccess::next_key::<__Field>(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); } - } - { + } { match __key { __Field::__field0 => { if __field0 { @@ -374,8 +409,7 @@ const _: () = { _ => { let _ = match _serde::de::MapAccess::next_value::< _serde::de::IgnoredAny, - >(&mut __map) - { + >(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -385,13 +419,17 @@ const _: () = { } } if !__field0 { - self.place.phantom = match _serde::__private::de::missing_field("phantom") { + self + .place + .phantom = match _serde::__private::de::missing_field( + "phantom", + ) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); } }; - }; + } _serde::__private::Ok(()) } } diff --git a/test_suite/tests/expand/generic_enum.expanded.rs b/test_suite/tests/expand/generic_enum.expanded.rs index a4ad31094..abf57be0f 100644 --- a/test_suite/tests/expand/generic_enum.expanded.rs +++ b/test_suite/tests/expand/generic_enum.expanded.rs @@ -24,12 +24,14 @@ const _: () = { __S: _serde::Serializer, { match *self { - GenericEnum::Unit => _serde::Serializer::serialize_unit_variant( - __serializer, - "GenericEnum", - 0u32, - "Unit", - ), + GenericEnum::Unit => { + _serde::Serializer::serialize_unit_variant( + __serializer, + "GenericEnum", + 0u32, + "Unit", + ) + } GenericEnum::NewType(ref __field0) => { _serde::Serializer::serialize_newtype_variant( __serializer, @@ -122,7 +124,9 @@ const _: () = { T: _serde::Deserialize<'de>, U: _serde::Deserialize<'de>, { - fn deserialize<__D>(__deserializer: __D) -> _serde::__private::Result + fn deserialize<__D>( + __deserializer: __D, + ) -> _serde::__private::Result where __D: _serde::Deserializer<'de>, { @@ -140,9 +144,15 @@ const _: () = { &self, __formatter: &mut _serde::__private::Formatter, ) -> _serde::__private::fmt::Result { - _serde::__private::Formatter::write_str(__formatter, "variant identifier") + _serde::__private::Formatter::write_str( + __formatter, + "variant identifier", + ) } - fn visit_u64<__E>(self, __value: u64) -> _serde::__private::Result + fn visit_u64<__E>( + self, + __value: u64, + ) -> _serde::__private::Result where __E: _serde::de::Error, { @@ -151,10 +161,14 @@ const _: () = { 1u64 => _serde::__private::Ok(__Field::__field1), 2u64 => _serde::__private::Ok(__Field::__field2), 3u64 => _serde::__private::Ok(__Field::__field3), - _ => _serde::__private::Err(_serde::de::Error::invalid_value( - _serde::de::Unexpected::Unsigned(__value), - &"variant index 0 <= i < 4", - )), + _ => { + _serde::__private::Err( + _serde::de::Error::invalid_value( + _serde::de::Unexpected::Unsigned(__value), + &"variant index 0 <= i < 4", + ), + ) + } } } fn visit_str<__E>( @@ -169,9 +183,11 @@ const _: () = { "NewType" => _serde::__private::Ok(__Field::__field1), "Seq" => _serde::__private::Ok(__Field::__field2), "Map" => _serde::__private::Ok(__Field::__field3), - _ => _serde::__private::Err(_serde::de::Error::unknown_variant( - __value, VARIANTS, - )), + _ => { + _serde::__private::Err( + _serde::de::Error::unknown_variant(__value, VARIANTS), + ) + } } } fn visit_bytes<__E>( @@ -188,9 +204,9 @@ const _: () = { b"Map" => _serde::__private::Ok(__Field::__field3), _ => { let __value = &_serde::__private::from_utf8_lossy(__value); - _serde::__private::Err(_serde::de::Error::unknown_variant( - __value, VARIANTS, - )) + _serde::__private::Err( + _serde::de::Error::unknown_variant(__value, VARIANTS), + ) } } } @@ -203,7 +219,10 @@ const _: () = { where __D: _serde::Deserializer<'de>, { - _serde::Deserializer::deserialize_identifier(__deserializer, __FieldVisitor) + _serde::Deserializer::deserialize_identifier( + __deserializer, + __FieldVisitor, + ) } } struct __Visitor<'de, T, U> @@ -224,7 +243,10 @@ const _: () = { &self, __formatter: &mut _serde::__private::Formatter, ) -> _serde::__private::fmt::Result { - _serde::__private::Formatter::write_str(__formatter, "enum GenericEnum") + _serde::__private::Formatter::write_str( + __formatter, + "enum GenericEnum", + ) } fn visit_enum<__A>( self, @@ -248,10 +270,12 @@ const _: () = { }; _serde::__private::Ok(GenericEnum::Unit) } - (__Field::__field1, __variant) => _serde::__private::Result::map( - _serde::de::VariantAccess::newtype_variant::(__variant), - GenericEnum::NewType, - ), + (__Field::__field1, __variant) => { + _serde::__private::Result::map( + _serde::de::VariantAccess::newtype_variant::(__variant), + GenericEnum::NewType, + ) + } (__Field::__field2, __variant) => { struct __Visitor<'de, T, U> where @@ -261,7 +285,8 @@ const _: () = { marker: _serde::__private::PhantomData>, lifetime: _serde::__private::PhantomData<&'de ()>, } - impl<'de, T, U> _serde::de::Visitor<'de> for __Visitor<'de, T, U> + impl<'de, T, U> _serde::de::Visitor<'de> + for __Visitor<'de, T, U> where T: _serde::Deserialize<'de>, U: _serde::Deserialize<'de>, @@ -270,8 +295,7 @@ const _: () = { fn expecting( &self, __formatter: &mut _serde::__private::Formatter, - ) -> _serde::__private::fmt::Result - { + ) -> _serde::__private::fmt::Result { _serde::__private::Formatter::write_str( __formatter, "tuple variant GenericEnum::Seq", @@ -287,9 +311,7 @@ const _: () = { { let __field0 = match match _serde::de::SeqAccess::next_element::< T, - >( - &mut __seq - ) { + >(&mut __seq) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -297,14 +319,17 @@ const _: () = { } { _serde::__private::Some(__value) => __value, _serde::__private::None => { - return _serde :: __private :: Err (_serde :: de :: Error :: invalid_length (0usize , & "tuple variant GenericEnum::Seq with 2 elements")) ; + return _serde::__private::Err( + _serde::de::Error::invalid_length( + 0usize, + &"tuple variant GenericEnum::Seq with 2 elements", + ), + ); } }; let __field1 = match match _serde::de::SeqAccess::next_element::< U, - >( - &mut __seq - ) { + >(&mut __seq) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -312,7 +337,12 @@ const _: () = { } { _serde::__private::Some(__value) => __value, _serde::__private::None => { - return _serde :: __private :: Err (_serde :: de :: Error :: invalid_length (1usize , & "tuple variant GenericEnum::Seq with 2 elements")) ; + return _serde::__private::Err( + _serde::de::Error::invalid_length( + 1usize, + &"tuple variant GenericEnum::Seq with 2 elements", + ), + ); } }; _serde::__private::Ok(GenericEnum::Seq(__field0, __field1)) @@ -340,8 +370,7 @@ const _: () = { fn expecting( &self, __formatter: &mut _serde::__private::Formatter, - ) -> _serde::__private::fmt::Result - { + ) -> _serde::__private::fmt::Result { _serde::__private::Formatter::write_str( __formatter, "field identifier", @@ -409,7 +438,8 @@ const _: () = { marker: _serde::__private::PhantomData>, lifetime: _serde::__private::PhantomData<&'de ()>, } - impl<'de, T, U> _serde::de::Visitor<'de> for __Visitor<'de, T, U> + impl<'de, T, U> _serde::de::Visitor<'de> + for __Visitor<'de, T, U> where T: _serde::Deserialize<'de>, U: _serde::Deserialize<'de>, @@ -418,8 +448,7 @@ const _: () = { fn expecting( &self, __formatter: &mut _serde::__private::Formatter, - ) -> _serde::__private::fmt::Result - { + ) -> _serde::__private::fmt::Result { _serde::__private::Formatter::write_str( __formatter, "struct variant GenericEnum::Map", @@ -435,9 +464,7 @@ const _: () = { { let __field0 = match match _serde::de::SeqAccess::next_element::< T, - >( - &mut __seq - ) { + >(&mut __seq) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -445,14 +472,17 @@ const _: () = { } { _serde::__private::Some(__value) => __value, _serde::__private::None => { - return _serde :: __private :: Err (_serde :: de :: Error :: invalid_length (0usize , & "struct variant GenericEnum::Map with 2 elements")) ; + return _serde::__private::Err( + _serde::de::Error::invalid_length( + 0usize, + &"struct variant GenericEnum::Map with 2 elements", + ), + ); } }; let __field1 = match match _serde::de::SeqAccess::next_element::< U, - >( - &mut __seq - ) { + >(&mut __seq) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -460,7 +490,12 @@ const _: () = { } { _serde::__private::Some(__value) => __value, _serde::__private::None => { - return _serde :: __private :: Err (_serde :: de :: Error :: invalid_length (1usize , & "struct variant GenericEnum::Map with 2 elements")) ; + return _serde::__private::Err( + _serde::de::Error::invalid_length( + 1usize, + &"struct variant GenericEnum::Map with 2 elements", + ), + ); } }; _serde::__private::Ok(GenericEnum::Map { @@ -476,28 +511,26 @@ const _: () = { where __A: _serde::de::MapAccess<'de>, { - let mut __field0: _serde::__private::Option = - _serde::__private::None; - let mut __field1: _serde::__private::Option = - _serde::__private::None; - while let _serde::__private::Some(__key) = - match _serde::de::MapAccess::next_key::<__Field>(&mut __map) - { + let mut __field0: _serde::__private::Option = _serde::__private::None; + let mut __field1: _serde::__private::Option = _serde::__private::None; + while let _serde::__private::Some(__key) + = match _serde::de::MapAccess::next_key::< + __Field, + >(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); } - } - { + } { match __key { __Field::__field0 => { if _serde::__private::Option::is_some(&__field0) { - return _serde :: __private :: Err (< __A :: Error as _serde :: de :: Error > :: duplicate_field ("x")) ; + return _serde::__private::Err( + <__A::Error as _serde::de::Error>::duplicate_field("x"), + ); } __field0 = _serde::__private::Some( - match _serde::de::MapAccess::next_value::( - &mut __map, - ) { + match _serde::de::MapAccess::next_value::(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -507,12 +540,12 @@ const _: () = { } __Field::__field1 => { if _serde::__private::Option::is_some(&__field1) { - return _serde :: __private :: Err (< __A :: Error as _serde :: de :: Error > :: duplicate_field ("y")) ; + return _serde::__private::Err( + <__A::Error as _serde::de::Error>::duplicate_field("y"), + ); } __field1 = _serde::__private::Some( - match _serde::de::MapAccess::next_value::( - &mut __map, - ) { + match _serde::de::MapAccess::next_value::(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -523,9 +556,7 @@ const _: () = { _ => { let _ = match _serde::de::MapAccess::next_value::< _serde::de::IgnoredAny, - >( - &mut __map - ) { + >(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); diff --git a/test_suite/tests/expand/generic_struct.expanded.rs b/test_suite/tests/expand/generic_struct.expanded.rs index bb16dc3b2..87be58d0a 100644 --- a/test_suite/tests/expand/generic_struct.expanded.rs +++ b/test_suite/tests/expand/generic_struct.expanded.rs @@ -29,7 +29,11 @@ const _: () = { return _serde::__private::Err(__err); } }; - match _serde::ser::SerializeStruct::serialize_field(&mut __serde_state, "x", &self.x) { + match _serde::ser::SerializeStruct::serialize_field( + &mut __serde_state, + "x", + &self.x, + ) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -49,7 +53,9 @@ const _: () = { where T: _serde::Deserialize<'de>, { - fn deserialize<__D>(__deserializer: __D) -> _serde::__private::Result + fn deserialize<__D>( + __deserializer: __D, + ) -> _serde::__private::Result where __D: _serde::Deserializer<'de>, { @@ -65,9 +71,15 @@ const _: () = { &self, __formatter: &mut _serde::__private::Formatter, ) -> _serde::__private::fmt::Result { - _serde::__private::Formatter::write_str(__formatter, "field identifier") + _serde::__private::Formatter::write_str( + __formatter, + "field identifier", + ) } - fn visit_u64<__E>(self, __value: u64) -> _serde::__private::Result + fn visit_u64<__E>( + self, + __value: u64, + ) -> _serde::__private::Result where __E: _serde::de::Error, { @@ -109,7 +121,10 @@ const _: () = { where __D: _serde::Deserializer<'de>, { - _serde::Deserializer::deserialize_identifier(__deserializer, __FieldVisitor) + _serde::Deserializer::deserialize_identifier( + __deserializer, + __FieldVisitor, + ) } } struct __Visitor<'de, T> @@ -128,7 +143,10 @@ const _: () = { &self, __formatter: &mut _serde::__private::Formatter, ) -> _serde::__private::fmt::Result { - _serde::__private::Formatter::write_str(__formatter, "struct GenericStruct") + _serde::__private::Formatter::write_str( + __formatter, + "struct GenericStruct", + ) } #[inline] fn visit_seq<__A>( @@ -138,8 +156,9 @@ const _: () = { where __A: _serde::de::SeqAccess<'de>, { - let __field0 = match match _serde::de::SeqAccess::next_element::(&mut __seq) - { + let __field0 = match match _serde::de::SeqAccess::next_element::< + T, + >(&mut __seq) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -147,10 +166,12 @@ const _: () = { } { _serde::__private::Some(__value) => __value, _serde::__private::None => { - return _serde::__private::Err(_serde::de::Error::invalid_length( - 0usize, - &"struct GenericStruct with 1 element", - )); + return _serde::__private::Err( + _serde::de::Error::invalid_length( + 0usize, + &"struct GenericStruct with 1 element", + ), + ); } }; _serde::__private::Ok(GenericStruct { x: __field0 }) @@ -164,14 +185,13 @@ const _: () = { __A: _serde::de::MapAccess<'de>, { let mut __field0: _serde::__private::Option = _serde::__private::None; - while let _serde::__private::Some(__key) = - match _serde::de::MapAccess::next_key::<__Field>(&mut __map) { + while let _serde::__private::Some(__key) + = match _serde::de::MapAccess::next_key::<__Field>(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); } - } - { + } { match __key { __Field::__field0 => { if _serde::__private::Option::is_some(&__field0) { @@ -191,8 +211,7 @@ const _: () = { _ => { let _ = match _serde::de::MapAccess::next_value::< _serde::de::IgnoredAny, - >(&mut __map) - { + >(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -245,9 +264,15 @@ const _: () = { &self, __formatter: &mut _serde::__private::Formatter, ) -> _serde::__private::fmt::Result { - _serde::__private::Formatter::write_str(__formatter, "field identifier") + _serde::__private::Formatter::write_str( + __formatter, + "field identifier", + ) } - fn visit_u64<__E>(self, __value: u64) -> _serde::__private::Result + fn visit_u64<__E>( + self, + __value: u64, + ) -> _serde::__private::Result where __E: _serde::de::Error, { @@ -289,7 +314,10 @@ const _: () = { where __D: _serde::Deserializer<'de>, { - _serde::Deserializer::deserialize_identifier(__deserializer, __FieldVisitor) + _serde::Deserializer::deserialize_identifier( + __deserializer, + __FieldVisitor, + ) } } struct __Visitor<'de, 'place, T: 'place> @@ -299,7 +327,8 @@ const _: () = { place: &'place mut GenericStruct, lifetime: _serde::__private::PhantomData<&'de ()>, } - impl<'de, 'place, T: 'place> _serde::de::Visitor<'de> for __Visitor<'de, 'place, T> + impl<'de, 'place, T: 'place> _serde::de::Visitor<'de> + for __Visitor<'de, 'place, T> where T: _serde::Deserialize<'de>, { @@ -308,7 +337,10 @@ const _: () = { &self, __formatter: &mut _serde::__private::Formatter, ) -> _serde::__private::fmt::Result { - _serde::__private::Formatter::write_str(__formatter, "struct GenericStruct") + _serde::__private::Formatter::write_str( + __formatter, + "struct GenericStruct", + ) } #[inline] fn visit_seq<__A>( @@ -318,19 +350,22 @@ const _: () = { where __A: _serde::de::SeqAccess<'de>, { - if let _serde::__private::None = match _serde::de::SeqAccess::next_element_seed( - &mut __seq, - _serde::__private::de::InPlaceSeed(&mut self.place.x), - ) { - _serde::__private::Ok(__val) => __val, - _serde::__private::Err(__err) => { - return _serde::__private::Err(__err); - } - } { - return _serde::__private::Err(_serde::de::Error::invalid_length( - 0usize, - &"struct GenericStruct with 1 element", - )); + if let _serde::__private::None + = match _serde::de::SeqAccess::next_element_seed( + &mut __seq, + _serde::__private::de::InPlaceSeed(&mut self.place.x), + ) { + _serde::__private::Ok(__val) => __val, + _serde::__private::Err(__err) => { + return _serde::__private::Err(__err); + } + } { + return _serde::__private::Err( + _serde::de::Error::invalid_length( + 0usize, + &"struct GenericStruct with 1 element", + ), + ); } _serde::__private::Ok(()) } @@ -343,14 +378,13 @@ const _: () = { __A: _serde::de::MapAccess<'de>, { let mut __field0: bool = false; - while let _serde::__private::Some(__key) = - match _serde::de::MapAccess::next_key::<__Field>(&mut __map) { + while let _serde::__private::Some(__key) + = match _serde::de::MapAccess::next_key::<__Field>(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); } - } - { + } { match __key { __Field::__field0 => { if __field0 { @@ -372,8 +406,7 @@ const _: () = { _ => { let _ = match _serde::de::MapAccess::next_value::< _serde::de::IgnoredAny, - >(&mut __map) - { + >(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -383,13 +416,15 @@ const _: () = { } } if !__field0 { - self.place.x = match _serde::__private::de::missing_field("x") { + self + .place + .x = match _serde::__private::de::missing_field("x") { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); } }; - }; + } _serde::__private::Ok(()) } } @@ -442,7 +477,9 @@ const _: () = { where T: _serde::Deserialize<'de>, { - fn deserialize<__D>(__deserializer: __D) -> _serde::__private::Result + fn deserialize<__D>( + __deserializer: __D, + ) -> _serde::__private::Result where __D: _serde::Deserializer<'de>, { @@ -475,7 +512,9 @@ const _: () = { where __E: _serde::Deserializer<'de>, { - let __field0: T = match ::deserialize(__e) { + let __field0: T = match ::deserialize( + __e, + ) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -491,8 +530,9 @@ const _: () = { where __A: _serde::de::SeqAccess<'de>, { - let __field0 = match match _serde::de::SeqAccess::next_element::(&mut __seq) - { + let __field0 = match match _serde::de::SeqAccess::next_element::< + T, + >(&mut __seq) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -500,10 +540,12 @@ const _: () = { } { _serde::__private::Some(__value) => __value, _serde::__private::None => { - return _serde::__private::Err(_serde::de::Error::invalid_length( - 0usize, - &"tuple struct GenericNewTypeStruct with 1 element", - )); + return _serde::__private::Err( + _serde::de::Error::invalid_length( + 0usize, + &"tuple struct GenericNewTypeStruct with 1 element", + ), + ); } }; _serde::__private::Ok(GenericNewTypeStruct(__field0)) @@ -532,7 +574,8 @@ const _: () = { place: &'place mut GenericNewTypeStruct, lifetime: _serde::__private::PhantomData<&'de ()>, } - impl<'de, 'place, T: 'place> _serde::de::Visitor<'de> for __Visitor<'de, 'place, T> + impl<'de, 'place, T: 'place> _serde::de::Visitor<'de> + for __Visitor<'de, 'place, T> where T: _serde::Deserialize<'de>, { @@ -564,19 +607,22 @@ const _: () = { where __A: _serde::de::SeqAccess<'de>, { - if let _serde::__private::None = match _serde::de::SeqAccess::next_element_seed( - &mut __seq, - _serde::__private::de::InPlaceSeed(&mut self.place.0), - ) { - _serde::__private::Ok(__val) => __val, - _serde::__private::Err(__err) => { - return _serde::__private::Err(__err); - } - } { - return _serde::__private::Err(_serde::de::Error::invalid_length( - 0usize, - &"tuple struct GenericNewTypeStruct with 1 element", - )); + if let _serde::__private::None + = match _serde::de::SeqAccess::next_element_seed( + &mut __seq, + _serde::__private::de::InPlaceSeed(&mut self.place.0), + ) { + _serde::__private::Ok(__val) => __val, + _serde::__private::Err(__err) => { + return _serde::__private::Err(__err); + } + } { + return _serde::__private::Err( + _serde::de::Error::invalid_length( + 0usize, + &"tuple struct GenericNewTypeStruct with 1 element", + ), + ); } _serde::__private::Ok(()) } diff --git a/test_suite/tests/expand/generic_tuple_struct.expanded.rs b/test_suite/tests/expand/generic_tuple_struct.expanded.rs index 7012f9f40..c8d11c54c 100644 --- a/test_suite/tests/expand/generic_tuple_struct.expanded.rs +++ b/test_suite/tests/expand/generic_tuple_struct.expanded.rs @@ -11,7 +11,9 @@ const _: () = { T: _serde::Deserialize<'de>, U: _serde::Deserialize<'de>, { - fn deserialize<__D>(__deserializer: __D) -> _serde::__private::Result + fn deserialize<__D>( + __deserializer: __D, + ) -> _serde::__private::Result where __D: _serde::Deserializer<'de>, { @@ -46,8 +48,9 @@ const _: () = { where __A: _serde::de::SeqAccess<'de>, { - let __field0 = match match _serde::de::SeqAccess::next_element::(&mut __seq) - { + let __field0 = match match _serde::de::SeqAccess::next_element::< + T, + >(&mut __seq) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -55,14 +58,17 @@ const _: () = { } { _serde::__private::Some(__value) => __value, _serde::__private::None => { - return _serde::__private::Err(_serde::de::Error::invalid_length( - 0usize, - &"tuple struct GenericTupleStruct with 2 elements", - )); + return _serde::__private::Err( + _serde::de::Error::invalid_length( + 0usize, + &"tuple struct GenericTupleStruct with 2 elements", + ), + ); } }; - let __field1 = match match _serde::de::SeqAccess::next_element::(&mut __seq) - { + let __field1 = match match _serde::de::SeqAccess::next_element::< + U, + >(&mut __seq) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -70,10 +76,12 @@ const _: () = { } { _serde::__private::Some(__value) => __value, _serde::__private::None => { - return _serde::__private::Err(_serde::de::Error::invalid_length( - 1usize, - &"tuple struct GenericTupleStruct with 2 elements", - )); + return _serde::__private::Err( + _serde::de::Error::invalid_length( + 1usize, + &"tuple struct GenericTupleStruct with 2 elements", + ), + ); } }; _serde::__private::Ok(GenericTupleStruct(__field0, __field1)) @@ -104,7 +112,8 @@ const _: () = { place: &'place mut GenericTupleStruct, lifetime: _serde::__private::PhantomData<&'de ()>, } - impl<'de, 'place, T: 'place, U: 'place> _serde::de::Visitor<'de> for __Visitor<'de, 'place, T, U> + impl<'de, 'place, T: 'place, U: 'place> _serde::de::Visitor<'de> + for __Visitor<'de, 'place, T, U> where T: _serde::Deserialize<'de>, U: _serde::Deserialize<'de>, @@ -127,33 +136,39 @@ const _: () = { where __A: _serde::de::SeqAccess<'de>, { - if let _serde::__private::None = match _serde::de::SeqAccess::next_element_seed( - &mut __seq, - _serde::__private::de::InPlaceSeed(&mut self.place.0), - ) { - _serde::__private::Ok(__val) => __val, - _serde::__private::Err(__err) => { - return _serde::__private::Err(__err); - } - } { - return _serde::__private::Err(_serde::de::Error::invalid_length( - 0usize, - &"tuple struct GenericTupleStruct with 2 elements", - )); + if let _serde::__private::None + = match _serde::de::SeqAccess::next_element_seed( + &mut __seq, + _serde::__private::de::InPlaceSeed(&mut self.place.0), + ) { + _serde::__private::Ok(__val) => __val, + _serde::__private::Err(__err) => { + return _serde::__private::Err(__err); + } + } { + return _serde::__private::Err( + _serde::de::Error::invalid_length( + 0usize, + &"tuple struct GenericTupleStruct with 2 elements", + ), + ); } - if let _serde::__private::None = match _serde::de::SeqAccess::next_element_seed( - &mut __seq, - _serde::__private::de::InPlaceSeed(&mut self.place.1), - ) { - _serde::__private::Ok(__val) => __val, - _serde::__private::Err(__err) => { - return _serde::__private::Err(__err); - } - } { - return _serde::__private::Err(_serde::de::Error::invalid_length( - 1usize, - &"tuple struct GenericTupleStruct with 2 elements", - )); + if let _serde::__private::None + = match _serde::de::SeqAccess::next_element_seed( + &mut __seq, + _serde::__private::de::InPlaceSeed(&mut self.place.1), + ) { + _serde::__private::Ok(__val) => __val, + _serde::__private::Err(__err) => { + return _serde::__private::Err(__err); + } + } { + return _serde::__private::Err( + _serde::de::Error::invalid_length( + 1usize, + &"tuple struct GenericTupleStruct with 2 elements", + ), + ); } _serde::__private::Ok(()) } diff --git a/test_suite/tests/expand/lifetimes.expanded.rs b/test_suite/tests/expand/lifetimes.expanded.rs index cf2f00811..0dca7865c 100644 --- a/test_suite/tests/expand/lifetimes.expanded.rs +++ b/test_suite/tests/expand/lifetimes.expanded.rs @@ -99,7 +99,9 @@ const _: () = { extern crate serde as _serde; #[automatically_derived] impl<'de, 'a> _serde::Deserialize<'de> for Lifetimes<'a> { - fn deserialize<__D>(__deserializer: __D) -> _serde::__private::Result + fn deserialize<__D>( + __deserializer: __D, + ) -> _serde::__private::Result where __D: _serde::Deserializer<'de>, { @@ -117,9 +119,15 @@ const _: () = { &self, __formatter: &mut _serde::__private::Formatter, ) -> _serde::__private::fmt::Result { - _serde::__private::Formatter::write_str(__formatter, "variant identifier") + _serde::__private::Formatter::write_str( + __formatter, + "variant identifier", + ) } - fn visit_u64<__E>(self, __value: u64) -> _serde::__private::Result + fn visit_u64<__E>( + self, + __value: u64, + ) -> _serde::__private::Result where __E: _serde::de::Error, { @@ -128,10 +136,14 @@ const _: () = { 1u64 => _serde::__private::Ok(__Field::__field1), 2u64 => _serde::__private::Ok(__Field::__field2), 3u64 => _serde::__private::Ok(__Field::__field3), - _ => _serde::__private::Err(_serde::de::Error::invalid_value( - _serde::de::Unexpected::Unsigned(__value), - &"variant index 0 <= i < 4", - )), + _ => { + _serde::__private::Err( + _serde::de::Error::invalid_value( + _serde::de::Unexpected::Unsigned(__value), + &"variant index 0 <= i < 4", + ), + ) + } } } fn visit_str<__E>( @@ -146,9 +158,11 @@ const _: () = { "NoLifetimeSeq" => _serde::__private::Ok(__Field::__field1), "LifetimeMap" => _serde::__private::Ok(__Field::__field2), "NoLifetimeMap" => _serde::__private::Ok(__Field::__field3), - _ => _serde::__private::Err(_serde::de::Error::unknown_variant( - __value, VARIANTS, - )), + _ => { + _serde::__private::Err( + _serde::de::Error::unknown_variant(__value, VARIANTS), + ) + } } } fn visit_bytes<__E>( @@ -165,9 +179,9 @@ const _: () = { b"NoLifetimeMap" => _serde::__private::Ok(__Field::__field3), _ => { let __value = &_serde::__private::from_utf8_lossy(__value); - _serde::__private::Err(_serde::de::Error::unknown_variant( - __value, VARIANTS, - )) + _serde::__private::Err( + _serde::de::Error::unknown_variant(__value, VARIANTS), + ) } } } @@ -180,7 +194,10 @@ const _: () = { where __D: _serde::Deserializer<'de>, { - _serde::Deserializer::deserialize_identifier(__deserializer, __FieldVisitor) + _serde::Deserializer::deserialize_identifier( + __deserializer, + __FieldVisitor, + ) } } struct __Visitor<'de, 'a> { @@ -193,7 +210,10 @@ const _: () = { &self, __formatter: &mut _serde::__private::Formatter, ) -> _serde::__private::fmt::Result { - _serde::__private::Formatter::write_str(__formatter, "enum Lifetimes") + _serde::__private::Formatter::write_str( + __formatter, + "enum Lifetimes", + ) } fn visit_enum<__A>( self, @@ -208,14 +228,22 @@ const _: () = { return _serde::__private::Err(__err); } } { - (__Field::__field0, __variant) => _serde::__private::Result::map( - _serde::de::VariantAccess::newtype_variant::<&'a i32>(__variant), - Lifetimes::LifetimeSeq, - ), - (__Field::__field1, __variant) => _serde::__private::Result::map( - _serde::de::VariantAccess::newtype_variant::(__variant), - Lifetimes::NoLifetimeSeq, - ), + (__Field::__field0, __variant) => { + _serde::__private::Result::map( + _serde::de::VariantAccess::newtype_variant::< + &'a i32, + >(__variant), + Lifetimes::LifetimeSeq, + ) + } + (__Field::__field1, __variant) => { + _serde::__private::Result::map( + _serde::de::VariantAccess::newtype_variant::< + i32, + >(__variant), + Lifetimes::NoLifetimeSeq, + ) + } (__Field::__field2, __variant) => { #[allow(non_camel_case_types)] enum __Field { @@ -228,8 +256,7 @@ const _: () = { fn expecting( &self, __formatter: &mut _serde::__private::Formatter, - ) -> _serde::__private::fmt::Result - { + ) -> _serde::__private::fmt::Result { _serde::__private::Formatter::write_str( __formatter, "field identifier", @@ -290,13 +317,13 @@ const _: () = { marker: _serde::__private::PhantomData>, lifetime: _serde::__private::PhantomData<&'de ()>, } - impl<'de, 'a> _serde::de::Visitor<'de> for __Visitor<'de, 'a> { + impl<'de, 'a> _serde::de::Visitor<'de> + for __Visitor<'de, 'a> { type Value = Lifetimes<'a>; fn expecting( &self, __formatter: &mut _serde::__private::Formatter, - ) -> _serde::__private::fmt::Result - { + ) -> _serde::__private::fmt::Result { _serde::__private::Formatter::write_str( __formatter, "struct variant Lifetimes::LifetimeMap", @@ -312,9 +339,7 @@ const _: () = { { let __field0 = match match _serde::de::SeqAccess::next_element::< &'a i32, - >( - &mut __seq - ) { + >(&mut __seq) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -322,10 +347,17 @@ const _: () = { } { _serde::__private::Some(__value) => __value, _serde::__private::None => { - return _serde :: __private :: Err (_serde :: de :: Error :: invalid_length (0usize , & "struct variant Lifetimes::LifetimeMap with 1 element")) ; + return _serde::__private::Err( + _serde::de::Error::invalid_length( + 0usize, + &"struct variant Lifetimes::LifetimeMap with 1 element", + ), + ); } }; - _serde::__private::Ok(Lifetimes::LifetimeMap { a: __field0 }) + _serde::__private::Ok(Lifetimes::LifetimeMap { + a: __field0, + }) } #[inline] fn visit_map<__A>( @@ -335,26 +367,27 @@ const _: () = { where __A: _serde::de::MapAccess<'de>, { - let mut __field0: _serde::__private::Option<&'a i32> = - _serde::__private::None; - while let _serde::__private::Some(__key) = - match _serde::de::MapAccess::next_key::<__Field>(&mut __map) - { + let mut __field0: _serde::__private::Option<&'a i32> = _serde::__private::None; + while let _serde::__private::Some(__key) + = match _serde::de::MapAccess::next_key::< + __Field, + >(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); } - } - { + } { match __key { __Field::__field0 => { if _serde::__private::Option::is_some(&__field0) { - return _serde :: __private :: Err (< __A :: Error as _serde :: de :: Error > :: duplicate_field ("a")) ; + return _serde::__private::Err( + <__A::Error as _serde::de::Error>::duplicate_field("a"), + ); } __field0 = _serde::__private::Some( - match _serde::de::MapAccess::next_value::<&'a i32>( - &mut __map, - ) { + match _serde::de::MapAccess::next_value::< + &'a i32, + >(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -365,9 +398,7 @@ const _: () = { _ => { let _ = match _serde::de::MapAccess::next_value::< _serde::de::IgnoredAny, - >( - &mut __map - ) { + >(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -387,7 +418,9 @@ const _: () = { } } }; - _serde::__private::Ok(Lifetimes::LifetimeMap { a: __field0 }) + _serde::__private::Ok(Lifetimes::LifetimeMap { + a: __field0, + }) } } const FIELDS: &'static [&'static str] = &["a"]; @@ -412,8 +445,7 @@ const _: () = { fn expecting( &self, __formatter: &mut _serde::__private::Formatter, - ) -> _serde::__private::fmt::Result - { + ) -> _serde::__private::fmt::Result { _serde::__private::Formatter::write_str( __formatter, "field identifier", @@ -474,13 +506,13 @@ const _: () = { marker: _serde::__private::PhantomData>, lifetime: _serde::__private::PhantomData<&'de ()>, } - impl<'de, 'a> _serde::de::Visitor<'de> for __Visitor<'de, 'a> { + impl<'de, 'a> _serde::de::Visitor<'de> + for __Visitor<'de, 'a> { type Value = Lifetimes<'a>; fn expecting( &self, __formatter: &mut _serde::__private::Formatter, - ) -> _serde::__private::fmt::Result - { + ) -> _serde::__private::fmt::Result { _serde::__private::Formatter::write_str( __formatter, "struct variant Lifetimes::NoLifetimeMap", @@ -496,9 +528,7 @@ const _: () = { { let __field0 = match match _serde::de::SeqAccess::next_element::< i32, - >( - &mut __seq - ) { + >(&mut __seq) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -506,10 +536,17 @@ const _: () = { } { _serde::__private::Some(__value) => __value, _serde::__private::None => { - return _serde :: __private :: Err (_serde :: de :: Error :: invalid_length (0usize , & "struct variant Lifetimes::NoLifetimeMap with 1 element")) ; + return _serde::__private::Err( + _serde::de::Error::invalid_length( + 0usize, + &"struct variant Lifetimes::NoLifetimeMap with 1 element", + ), + ); } }; - _serde::__private::Ok(Lifetimes::NoLifetimeMap { a: __field0 }) + _serde::__private::Ok(Lifetimes::NoLifetimeMap { + a: __field0, + }) } #[inline] fn visit_map<__A>( @@ -519,26 +556,25 @@ const _: () = { where __A: _serde::de::MapAccess<'de>, { - let mut __field0: _serde::__private::Option = - _serde::__private::None; - while let _serde::__private::Some(__key) = - match _serde::de::MapAccess::next_key::<__Field>(&mut __map) - { + let mut __field0: _serde::__private::Option = _serde::__private::None; + while let _serde::__private::Some(__key) + = match _serde::de::MapAccess::next_key::< + __Field, + >(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); } - } - { + } { match __key { __Field::__field0 => { if _serde::__private::Option::is_some(&__field0) { - return _serde :: __private :: Err (< __A :: Error as _serde :: de :: Error > :: duplicate_field ("a")) ; + return _serde::__private::Err( + <__A::Error as _serde::de::Error>::duplicate_field("a"), + ); } __field0 = _serde::__private::Some( - match _serde::de::MapAccess::next_value::( - &mut __map, - ) { + match _serde::de::MapAccess::next_value::(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -549,9 +585,7 @@ const _: () = { _ => { let _ = match _serde::de::MapAccess::next_value::< _serde::de::IgnoredAny, - >( - &mut __map - ) { + >(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -571,7 +605,9 @@ const _: () = { } } }; - _serde::__private::Ok(Lifetimes::NoLifetimeMap { a: __field0 }) + _serde::__private::Ok(Lifetimes::NoLifetimeMap { + a: __field0, + }) } } const FIELDS: &'static [&'static str] = &["a"]; diff --git a/test_suite/tests/expand/named_map.expanded.rs b/test_suite/tests/expand/named_map.expanded.rs index e30ac34e4..c20e50484 100644 --- a/test_suite/tests/expand/named_map.expanded.rs +++ b/test_suite/tests/expand/named_map.expanded.rs @@ -33,19 +33,31 @@ const _: () = { return _serde::__private::Err(__err); } }; - match _serde::ser::SerializeStruct::serialize_field(&mut __serde_state, "a", &self.a) { + match _serde::ser::SerializeStruct::serialize_field( + &mut __serde_state, + "a", + &self.a, + ) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); } }; - match _serde::ser::SerializeStruct::serialize_field(&mut __serde_state, "b", &self.b) { + match _serde::ser::SerializeStruct::serialize_field( + &mut __serde_state, + "b", + &self.b, + ) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); } }; - match _serde::ser::SerializeStruct::serialize_field(&mut __serde_state, "c", &self.c) { + match _serde::ser::SerializeStruct::serialize_field( + &mut __serde_state, + "c", + &self.c, + ) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -72,7 +84,9 @@ const _: () = { B: _serde::Deserialize<'de>, C: _serde::Deserialize<'de>, { - fn deserialize<__D>(__deserializer: __D) -> _serde::__private::Result + fn deserialize<__D>( + __deserializer: __D, + ) -> _serde::__private::Result where __D: _serde::Deserializer<'de>, { @@ -90,9 +104,15 @@ const _: () = { &self, __formatter: &mut _serde::__private::Formatter, ) -> _serde::__private::fmt::Result { - _serde::__private::Formatter::write_str(__formatter, "field identifier") + _serde::__private::Formatter::write_str( + __formatter, + "field identifier", + ) } - fn visit_u64<__E>(self, __value: u64) -> _serde::__private::Result + fn visit_u64<__E>( + self, + __value: u64, + ) -> _serde::__private::Result where __E: _serde::de::Error, { @@ -140,7 +160,10 @@ const _: () = { where __D: _serde::Deserializer<'de>, { - _serde::Deserializer::deserialize_identifier(__deserializer, __FieldVisitor) + _serde::Deserializer::deserialize_identifier( + __deserializer, + __FieldVisitor, + ) } } struct __Visitor<'de, A, B, C> @@ -163,7 +186,10 @@ const _: () = { &self, __formatter: &mut _serde::__private::Formatter, ) -> _serde::__private::fmt::Result { - _serde::__private::Formatter::write_str(__formatter, "struct DeNamedMap") + _serde::__private::Formatter::write_str( + __formatter, + "struct DeNamedMap", + ) } #[inline] fn visit_seq<__A>( @@ -173,8 +199,9 @@ const _: () = { where __A: _serde::de::SeqAccess<'de>, { - let __field0 = match match _serde::de::SeqAccess::next_element::(&mut __seq) - { + let __field0 = match match _serde::de::SeqAccess::next_element::< + A, + >(&mut __seq) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -182,14 +209,17 @@ const _: () = { } { _serde::__private::Some(__value) => __value, _serde::__private::None => { - return _serde::__private::Err(_serde::de::Error::invalid_length( - 0usize, - &"struct DeNamedMap with 3 elements", - )); + return _serde::__private::Err( + _serde::de::Error::invalid_length( + 0usize, + &"struct DeNamedMap with 3 elements", + ), + ); } }; - let __field1 = match match _serde::de::SeqAccess::next_element::(&mut __seq) - { + let __field1 = match match _serde::de::SeqAccess::next_element::< + B, + >(&mut __seq) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -197,14 +227,17 @@ const _: () = { } { _serde::__private::Some(__value) => __value, _serde::__private::None => { - return _serde::__private::Err(_serde::de::Error::invalid_length( - 1usize, - &"struct DeNamedMap with 3 elements", - )); + return _serde::__private::Err( + _serde::de::Error::invalid_length( + 1usize, + &"struct DeNamedMap with 3 elements", + ), + ); } }; - let __field2 = match match _serde::de::SeqAccess::next_element::(&mut __seq) - { + let __field2 = match match _serde::de::SeqAccess::next_element::< + C, + >(&mut __seq) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -212,10 +245,12 @@ const _: () = { } { _serde::__private::Some(__value) => __value, _serde::__private::None => { - return _serde::__private::Err(_serde::de::Error::invalid_length( - 2usize, - &"struct DeNamedMap with 3 elements", - )); + return _serde::__private::Err( + _serde::de::Error::invalid_length( + 2usize, + &"struct DeNamedMap with 3 elements", + ), + ); } }; _serde::__private::Ok(DeNamedMap { @@ -235,14 +270,13 @@ const _: () = { let mut __field0: _serde::__private::Option = _serde::__private::None; let mut __field1: _serde::__private::Option = _serde::__private::None; let mut __field2: _serde::__private::Option = _serde::__private::None; - while let _serde::__private::Some(__key) = - match _serde::de::MapAccess::next_key::<__Field>(&mut __map) { + while let _serde::__private::Some(__key) + = match _serde::de::MapAccess::next_key::<__Field>(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); } - } - { + } { match __key { __Field::__field0 => { if _serde::__private::Option::is_some(&__field0) { @@ -292,8 +326,7 @@ const _: () = { _ => { let _ = match _serde::de::MapAccess::next_value::< _serde::de::IgnoredAny, - >(&mut __map) - { + >(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -374,9 +407,15 @@ const _: () = { &self, __formatter: &mut _serde::__private::Formatter, ) -> _serde::__private::fmt::Result { - _serde::__private::Formatter::write_str(__formatter, "field identifier") + _serde::__private::Formatter::write_str( + __formatter, + "field identifier", + ) } - fn visit_u64<__E>(self, __value: u64) -> _serde::__private::Result + fn visit_u64<__E>( + self, + __value: u64, + ) -> _serde::__private::Result where __E: _serde::de::Error, { @@ -424,7 +463,10 @@ const _: () = { where __D: _serde::Deserializer<'de>, { - _serde::Deserializer::deserialize_identifier(__deserializer, __FieldVisitor) + _serde::Deserializer::deserialize_identifier( + __deserializer, + __FieldVisitor, + ) } } struct __Visitor<'de, 'place, A: 'place, B: 'place, C: 'place> @@ -437,7 +479,7 @@ const _: () = { lifetime: _serde::__private::PhantomData<&'de ()>, } impl<'de, 'place, A: 'place, B: 'place, C: 'place> _serde::de::Visitor<'de> - for __Visitor<'de, 'place, A, B, C> + for __Visitor<'de, 'place, A, B, C> where A: _serde::Deserialize<'de>, B: _serde::Deserialize<'de>, @@ -448,7 +490,10 @@ const _: () = { &self, __formatter: &mut _serde::__private::Formatter, ) -> _serde::__private::fmt::Result { - _serde::__private::Formatter::write_str(__formatter, "struct DeNamedMap") + _serde::__private::Formatter::write_str( + __formatter, + "struct DeNamedMap", + ) } #[inline] fn visit_seq<__A>( @@ -458,47 +503,56 @@ const _: () = { where __A: _serde::de::SeqAccess<'de>, { - if let _serde::__private::None = match _serde::de::SeqAccess::next_element_seed( - &mut __seq, - _serde::__private::de::InPlaceSeed(&mut self.place.a), - ) { - _serde::__private::Ok(__val) => __val, - _serde::__private::Err(__err) => { - return _serde::__private::Err(__err); - } - } { - return _serde::__private::Err(_serde::de::Error::invalid_length( - 0usize, - &"struct DeNamedMap with 3 elements", - )); + if let _serde::__private::None + = match _serde::de::SeqAccess::next_element_seed( + &mut __seq, + _serde::__private::de::InPlaceSeed(&mut self.place.a), + ) { + _serde::__private::Ok(__val) => __val, + _serde::__private::Err(__err) => { + return _serde::__private::Err(__err); + } + } { + return _serde::__private::Err( + _serde::de::Error::invalid_length( + 0usize, + &"struct DeNamedMap with 3 elements", + ), + ); } - if let _serde::__private::None = match _serde::de::SeqAccess::next_element_seed( - &mut __seq, - _serde::__private::de::InPlaceSeed(&mut self.place.b), - ) { - _serde::__private::Ok(__val) => __val, - _serde::__private::Err(__err) => { - return _serde::__private::Err(__err); - } - } { - return _serde::__private::Err(_serde::de::Error::invalid_length( - 1usize, - &"struct DeNamedMap with 3 elements", - )); + if let _serde::__private::None + = match _serde::de::SeqAccess::next_element_seed( + &mut __seq, + _serde::__private::de::InPlaceSeed(&mut self.place.b), + ) { + _serde::__private::Ok(__val) => __val, + _serde::__private::Err(__err) => { + return _serde::__private::Err(__err); + } + } { + return _serde::__private::Err( + _serde::de::Error::invalid_length( + 1usize, + &"struct DeNamedMap with 3 elements", + ), + ); } - if let _serde::__private::None = match _serde::de::SeqAccess::next_element_seed( - &mut __seq, - _serde::__private::de::InPlaceSeed(&mut self.place.c), - ) { - _serde::__private::Ok(__val) => __val, - _serde::__private::Err(__err) => { - return _serde::__private::Err(__err); - } - } { - return _serde::__private::Err(_serde::de::Error::invalid_length( - 2usize, - &"struct DeNamedMap with 3 elements", - )); + if let _serde::__private::None + = match _serde::de::SeqAccess::next_element_seed( + &mut __seq, + _serde::__private::de::InPlaceSeed(&mut self.place.c), + ) { + _serde::__private::Ok(__val) => __val, + _serde::__private::Err(__err) => { + return _serde::__private::Err(__err); + } + } { + return _serde::__private::Err( + _serde::de::Error::invalid_length( + 2usize, + &"struct DeNamedMap with 3 elements", + ), + ); } _serde::__private::Ok(()) } @@ -513,14 +567,13 @@ const _: () = { let mut __field0: bool = false; let mut __field1: bool = false; let mut __field2: bool = false; - while let _serde::__private::Some(__key) = - match _serde::de::MapAccess::next_key::<__Field>(&mut __map) { + while let _serde::__private::Some(__key) + = match _serde::de::MapAccess::next_key::<__Field>(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); } - } - { + } { match __key { __Field::__field0 => { if __field0 { @@ -576,8 +629,7 @@ const _: () = { _ => { let _ = match _serde::de::MapAccess::next_value::< _serde::de::IgnoredAny, - >(&mut __map) - { + >(&mut __map) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -587,29 +639,35 @@ const _: () = { } } if !__field0 { - self.place.a = match _serde::__private::de::missing_field("a") { + self + .place + .a = match _serde::__private::de::missing_field("a") { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); } }; - }; + } if !__field1 { - self.place.b = match _serde::__private::de::missing_field("b") { + self + .place + .b = match _serde::__private::de::missing_field("b") { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); } }; - }; + } if !__field2 { - self.place.c = match _serde::__private::de::missing_field("c") { + self + .place + .c = match _serde::__private::de::missing_field("c") { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); } }; - }; + } _serde::__private::Ok(()) } } diff --git a/test_suite/tests/expand/named_tuple.expanded.rs b/test_suite/tests/expand/named_tuple.expanded.rs index be083f633..dc0194794 100644 --- a/test_suite/tests/expand/named_tuple.expanded.rs +++ b/test_suite/tests/expand/named_tuple.expanded.rs @@ -29,19 +29,28 @@ const _: () = { return _serde::__private::Err(__err); } }; - match _serde::ser::SerializeTupleStruct::serialize_field(&mut __serde_state, &self.0) { + match _serde::ser::SerializeTupleStruct::serialize_field( + &mut __serde_state, + &self.0, + ) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); } }; - match _serde::ser::SerializeTupleStruct::serialize_field(&mut __serde_state, &self.1) { + match _serde::ser::SerializeTupleStruct::serialize_field( + &mut __serde_state, + &self.1, + ) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); } }; - match _serde::ser::SerializeTupleStruct::serialize_field(&mut __serde_state, &self.2) { + match _serde::ser::SerializeTupleStruct::serialize_field( + &mut __serde_state, + &self.2, + ) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -64,7 +73,9 @@ const _: () = { B: _serde::Deserialize<'de>, C: _serde::Deserialize<'de>, { - fn deserialize<__D>(__deserializer: __D) -> _serde::__private::Result + fn deserialize<__D>( + __deserializer: __D, + ) -> _serde::__private::Result where __D: _serde::Deserializer<'de>, { @@ -101,8 +112,9 @@ const _: () = { where __A: _serde::de::SeqAccess<'de>, { - let __field0 = match match _serde::de::SeqAccess::next_element::(&mut __seq) - { + let __field0 = match match _serde::de::SeqAccess::next_element::< + A, + >(&mut __seq) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -110,14 +122,17 @@ const _: () = { } { _serde::__private::Some(__value) => __value, _serde::__private::None => { - return _serde::__private::Err(_serde::de::Error::invalid_length( - 0usize, - &"tuple struct DeNamedTuple with 3 elements", - )); + return _serde::__private::Err( + _serde::de::Error::invalid_length( + 0usize, + &"tuple struct DeNamedTuple with 3 elements", + ), + ); } }; - let __field1 = match match _serde::de::SeqAccess::next_element::(&mut __seq) - { + let __field1 = match match _serde::de::SeqAccess::next_element::< + B, + >(&mut __seq) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -125,14 +140,17 @@ const _: () = { } { _serde::__private::Some(__value) => __value, _serde::__private::None => { - return _serde::__private::Err(_serde::de::Error::invalid_length( - 1usize, - &"tuple struct DeNamedTuple with 3 elements", - )); + return _serde::__private::Err( + _serde::de::Error::invalid_length( + 1usize, + &"tuple struct DeNamedTuple with 3 elements", + ), + ); } }; - let __field2 = match match _serde::de::SeqAccess::next_element::(&mut __seq) - { + let __field2 = match match _serde::de::SeqAccess::next_element::< + C, + >(&mut __seq) { _serde::__private::Ok(__val) => __val, _serde::__private::Err(__err) => { return _serde::__private::Err(__err); @@ -140,10 +158,12 @@ const _: () = { } { _serde::__private::Some(__value) => __value, _serde::__private::None => { - return _serde::__private::Err(_serde::de::Error::invalid_length( - 2usize, - &"tuple struct DeNamedTuple with 3 elements", - )); + return _serde::__private::Err( + _serde::de::Error::invalid_length( + 2usize, + &"tuple struct DeNamedTuple with 3 elements", + ), + ); } }; _serde::__private::Ok(DeNamedTuple(__field0, __field1, __field2)) @@ -176,7 +196,7 @@ const _: () = { lifetime: _serde::__private::PhantomData<&'de ()>, } impl<'de, 'place, A: 'place, B: 'place, C: 'place> _serde::de::Visitor<'de> - for __Visitor<'de, 'place, A, B, C> + for __Visitor<'de, 'place, A, B, C> where A: _serde::Deserialize<'de>, B: _serde::Deserialize<'de>, @@ -200,47 +220,56 @@ const _: () = { where __A: _serde::de::SeqAccess<'de>, { - if let _serde::__private::None = match _serde::de::SeqAccess::next_element_seed( - &mut __seq, - _serde::__private::de::InPlaceSeed(&mut self.place.0), - ) { - _serde::__private::Ok(__val) => __val, - _serde::__private::Err(__err) => { - return _serde::__private::Err(__err); - } - } { - return _serde::__private::Err(_serde::de::Error::invalid_length( - 0usize, - &"tuple struct DeNamedTuple with 3 elements", - )); + if let _serde::__private::None + = match _serde::de::SeqAccess::next_element_seed( + &mut __seq, + _serde::__private::de::InPlaceSeed(&mut self.place.0), + ) { + _serde::__private::Ok(__val) => __val, + _serde::__private::Err(__err) => { + return _serde::__private::Err(__err); + } + } { + return _serde::__private::Err( + _serde::de::Error::invalid_length( + 0usize, + &"tuple struct DeNamedTuple with 3 elements", + ), + ); } - if let _serde::__private::None = match _serde::de::SeqAccess::next_element_seed( - &mut __seq, - _serde::__private::de::InPlaceSeed(&mut self.place.1), - ) { - _serde::__private::Ok(__val) => __val, - _serde::__private::Err(__err) => { - return _serde::__private::Err(__err); - } - } { - return _serde::__private::Err(_serde::de::Error::invalid_length( - 1usize, - &"tuple struct DeNamedTuple with 3 elements", - )); + if let _serde::__private::None + = match _serde::de::SeqAccess::next_element_seed( + &mut __seq, + _serde::__private::de::InPlaceSeed(&mut self.place.1), + ) { + _serde::__private::Ok(__val) => __val, + _serde::__private::Err(__err) => { + return _serde::__private::Err(__err); + } + } { + return _serde::__private::Err( + _serde::de::Error::invalid_length( + 1usize, + &"tuple struct DeNamedTuple with 3 elements", + ), + ); } - if let _serde::__private::None = match _serde::de::SeqAccess::next_element_seed( - &mut __seq, - _serde::__private::de::InPlaceSeed(&mut self.place.2), - ) { - _serde::__private::Ok(__val) => __val, - _serde::__private::Err(__err) => { - return _serde::__private::Err(__err); - } - } { - return _serde::__private::Err(_serde::de::Error::invalid_length( - 2usize, - &"tuple struct DeNamedTuple with 3 elements", - )); + if let _serde::__private::None + = match _serde::de::SeqAccess::next_element_seed( + &mut __seq, + _serde::__private::de::InPlaceSeed(&mut self.place.2), + ) { + _serde::__private::Ok(__val) => __val, + _serde::__private::Err(__err) => { + return _serde::__private::Err(__err); + } + } { + return _serde::__private::Err( + _serde::de::Error::invalid_length( + 2usize, + &"tuple struct DeNamedTuple with 3 elements", + ), + ); } _serde::__private::Ok(()) } diff --git a/test_suite/tests/expand/named_unit.expanded.rs b/test_suite/tests/expand/named_unit.expanded.rs index 87876b771..77900a7a6 100644 --- a/test_suite/tests/expand/named_unit.expanded.rs +++ b/test_suite/tests/expand/named_unit.expanded.rs @@ -25,7 +25,9 @@ const _: () = { extern crate serde as _serde; #[automatically_derived] impl<'de> _serde::Deserialize<'de> for NamedUnit { - fn deserialize<__D>(__deserializer: __D) -> _serde::__private::Result + fn deserialize<__D>( + __deserializer: __D, + ) -> _serde::__private::Result where __D: _serde::Deserializer<'de>, { @@ -36,7 +38,10 @@ const _: () = { &self, __formatter: &mut _serde::__private::Formatter, ) -> _serde::__private::fmt::Result { - _serde::__private::Formatter::write_str(__formatter, "unit struct NamedUnit") + _serde::__private::Formatter::write_str( + __formatter, + "unit struct NamedUnit", + ) } #[inline] fn visit_unit<__E>(self) -> _serde::__private::Result @@ -46,7 +51,11 @@ const _: () = { _serde::__private::Ok(NamedUnit) } } - _serde::Deserializer::deserialize_unit_struct(__deserializer, "NamedUnit", __Visitor) + _serde::Deserializer::deserialize_unit_struct( + __deserializer, + "NamedUnit", + __Visitor, + ) } } }; diff --git a/test_suite/tests/expand/ser_enum.expanded.rs b/test_suite/tests/expand/ser_enum.expanded.rs index b0a83ca3f..8b71bab46 100644 --- a/test_suite/tests/expand/ser_enum.expanded.rs +++ b/test_suite/tests/expand/ser_enum.expanded.rs @@ -31,12 +31,14 @@ const _: () = { __S: _serde::Serializer, { match *self { - SerEnum::Unit => _serde::Serializer::serialize_unit_variant( - __serializer, - "SerEnum", - 0u32, - "Unit", - ), + SerEnum::Unit => { + _serde::Serializer::serialize_unit_variant( + __serializer, + "SerEnum", + 0u32, + "Unit", + ) + } SerEnum::Seq(ref __field0, ref __field1, ref __field2, ref __field3) => { let mut __serde_state = match _serde::Serializer::serialize_tuple_variant( __serializer, @@ -88,12 +90,7 @@ const _: () = { }; _serde::ser::SerializeTupleVariant::end(__serde_state) } - SerEnum::Map { - ref a, - ref b, - ref c, - ref d, - } => { + SerEnum::Map { ref a, ref b, ref c, ref d } => { let mut __serde_state = match _serde::Serializer::serialize_struct_variant( __serializer, "SerEnum", @@ -148,13 +145,20 @@ const _: () = { }; _serde::ser::SerializeStructVariant::end(__serde_state) } - SerEnum::_Unit2 => _serde::Serializer::serialize_unit_variant( - __serializer, - "SerEnum", - 3u32, - "_Unit2", - ), - SerEnum::_Seq2(ref __field0, ref __field1, ref __field2, ref __field3) => { + SerEnum::_Unit2 => { + _serde::Serializer::serialize_unit_variant( + __serializer, + "SerEnum", + 3u32, + "_Unit2", + ) + } + SerEnum::_Seq2( + ref __field0, + ref __field1, + ref __field2, + ref __field3, + ) => { let mut __serde_state = match _serde::Serializer::serialize_tuple_variant( __serializer, "SerEnum", @@ -205,12 +209,7 @@ const _: () = { }; _serde::ser::SerializeTupleVariant::end(__serde_state) } - SerEnum::_Map2 { - ref a, - ref b, - ref c, - ref d, - } => { + SerEnum::_Map2 { ref a, ref b, ref c, ref d } => { let mut __serde_state = match _serde::Serializer::serialize_struct_variant( __serializer, "SerEnum", diff --git a/test_suite/tests/expand/void.expanded.rs b/test_suite/tests/expand/void.expanded.rs index 35e6763d7..2e91a6670 100644 --- a/test_suite/tests/expand/void.expanded.rs +++ b/test_suite/tests/expand/void.expanded.rs @@ -25,7 +25,9 @@ const _: () = { extern crate serde as _serde; #[automatically_derived] impl<'de> _serde::Deserialize<'de> for Void { - fn deserialize<__D>(__deserializer: __D) -> _serde::__private::Result + fn deserialize<__D>( + __deserializer: __D, + ) -> _serde::__private::Result where __D: _serde::Deserializer<'de>, { @@ -38,17 +40,27 @@ const _: () = { &self, __formatter: &mut _serde::__private::Formatter, ) -> _serde::__private::fmt::Result { - _serde::__private::Formatter::write_str(__formatter, "variant identifier") + _serde::__private::Formatter::write_str( + __formatter, + "variant identifier", + ) } - fn visit_u64<__E>(self, __value: u64) -> _serde::__private::Result + fn visit_u64<__E>( + self, + __value: u64, + ) -> _serde::__private::Result where __E: _serde::de::Error, { match __value { - _ => _serde::__private::Err(_serde::de::Error::invalid_value( - _serde::de::Unexpected::Unsigned(__value), - &"variant index 0 <= i < 0", - )), + _ => { + _serde::__private::Err( + _serde::de::Error::invalid_value( + _serde::de::Unexpected::Unsigned(__value), + &"variant index 0 <= i < 0", + ), + ) + } } } fn visit_str<__E>( @@ -59,9 +71,11 @@ const _: () = { __E: _serde::de::Error, { match __value { - _ => _serde::__private::Err(_serde::de::Error::unknown_variant( - __value, VARIANTS, - )), + _ => { + _serde::__private::Err( + _serde::de::Error::unknown_variant(__value, VARIANTS), + ) + } } } fn visit_bytes<__E>( @@ -74,9 +88,9 @@ const _: () = { match __value { _ => { let __value = &_serde::__private::from_utf8_lossy(__value); - _serde::__private::Err(_serde::de::Error::unknown_variant( - __value, VARIANTS, - )) + _serde::__private::Err( + _serde::de::Error::unknown_variant(__value, VARIANTS), + ) } } } @@ -89,7 +103,10 @@ const _: () = { where __D: _serde::Deserializer<'de>, { - _serde::Deserializer::deserialize_identifier(__deserializer, __FieldVisitor) + _serde::Deserializer::deserialize_identifier( + __deserializer, + __FieldVisitor, + ) } } struct __Visitor<'de> {