Commit Graph

4067 Commits

Author SHA1 Message Date
David Tolnay
89c4b02bf3
Release 1.0.210 2024-09-06 11:17:20 -07:00
David Tolnay
eeb8e44cda
Merge pull request #2818 from dtolnay/coreerror
Stabilize no-std Error trait
2024-09-06 11:16:43 -07:00
David Tolnay
785c2d9605
Stabilize no-std StdError trait 2024-09-06 11:12:13 -07:00
David Tolnay
d549f048e1
Reformat parse_ip_impl definition and calls 2024-09-06 11:05:54 -07:00
David Tolnay
4c0dd63011
Delete attr support from core::net deserialization macros 2024-09-06 11:05:54 -07:00
David Tolnay
26fb134165
Relocate cfg attrs out of parse_ip_impl and parse_socket_impl 2024-09-06 11:05:53 -07:00
David Tolnay
07e614b52b
Merge pull request #2817 from dtolnay/corenet
Delete doc(cfg) attribute from impls that are supported in no-std
2024-09-06 11:05:48 -07:00
David Tolnay
b1f899fbe8
Delete doc(cfg) attribute from impls that are supported in no-std 2024-09-06 11:00:55 -07:00
David Tolnay
b4f860e627
Merge pull request #2816 from MathiasKoch/chore/core-net
Implement serialize/deserialize for core::net instead of std::net
2024-09-06 10:59:24 -07:00
Mathias
d940fe1b49 Reuse existing Buf wrapper as replacement for std::io::Write 2024-09-05 14:24:44 +02:00
Mathias
f2899a9e06 Implement serialize/deserialize for core::net instead of std::net if running rust version newer than 1.77, where core::net was stabilized 2024-09-05 11:07:09 +02:00
David Tolnay
3aca38d2d3
Upload CI Cargo.lock for reproducing failures 2024-08-25 12:12:25 -07:00
David Tolnay
30752ac4ff
Release 1.0.209 2024-08-23 20:29:05 -07:00
David Tolnay
b84e6ca4f5
Improve wording of PR 2805 comments 2024-08-23 20:28:11 -07:00
David Tolnay
87a2fb0f1a
Wrap comments from PR 2805 to 80 columns 2024-08-23 20:25:16 -07:00
David Tolnay
9eaf7b9824
Merge pull request #2805 from Mingun/untagged-tests
Fix deserialization of empty structs and tuples in untagged enums
2024-08-23 20:25:07 -07:00
Mingun
7bde100237 Replace MapRefDeserializer with value::MapDeserializer
Although they are slightly different, this difference is irrelevant:
- MapDeserializer has a specialization for deserialize_seq and deserialize_tuple, but
  only MapRefDeserializer::deserialize_any is used by the code which is almost the same
- MapDeserializer checks that map was consumed after visit_map, but MapRefDeserializer
  does not. Actually, each derived implementation consumes map and each manual implementation
  also should consume it

Also, MapDeserializer already used when value deserialized from ContentRefDeserializer
directly and MapRefDeserializer was only used to deserialize Struct variants of enums.
There are no reasons why the behavior should be different in those two cases
2024-08-24 04:52:26 +05:00
Mingun
da7fc795ee Fix deserialization of empty struct variant in untagged enums
SeqRefDeserializer::deserialize_any has a special condition for empty sequence, which
emits visit_unit. That condition assumes that type would be able to deserialized from
unit, but:
1) struct variants was never able to deserialize from it (they expect only visit_map or visit_seq)
2) tuple variants even with zero fields expect visit_seq only. The suggestion to accept visit_unit
   instead was rejected in #2520

Fixes (2):
    newtype_enum::tuple0
    newtype_enum::empty_struct_from_seq
2024-08-24 04:52:26 +05:00
Mingun
4c5fec1363 Test special cases that reaches SeqRefDeserializer::deserialize_any len==0 condition
failures (2):
    newtype_enum::empty_struct_from_seq
    newtype_enum::tuple0
2024-08-24 04:52:25 +05:00
Mingun
6588b0ad37 Cover Content::Seq case in VariantRefDeserializer::struct_variant 2024-08-24 04:52:25 +05:00
Mingun
0093f74cfe Split test newtype_enum into four tests for each variant
(review this commit with "ignore whitespace changes" option on)
2024-08-24 04:52:25 +05:00
Mingun
171c6da57a Complete coverage of ContentRefDeserializer::deserialize_newtype_struct 2024-08-24 04:52:25 +05:00
Mingun
2dddc7796d Cover ContentRefDeserializer::deserialize_option 2024-08-24 04:52:25 +05:00
Mingun
8514f4119a Remove unnecessary generics 2024-08-24 04:52:24 +05:00
Mingun
98fb7d94aa Move all untagged enum tests (except flatten) into a dedicated module
Moved and renamed:
From test_annotations
- test_expecting_message_untagged_tagged_enum                  => expecting_message
- flatten::enum_::untagged::straitforward                      => contains_flatten

From test_macros
- test_untagged_newtype_struct                                 => newtype_struct
- test_untagged_enum                                           => complex
- test_untagged_enum_with_flattened_integer_key                => contains_flatten_with_integer_key
- test_enum_in_untagged_enum                                   => newtype_enum
- test_untagged_bytes                                          => string_and_bytes
- test_untagged_newtype_variant_containing_unit_struct_not_map => newtype_unit_and_empty_map
2024-08-24 04:52:22 +05:00
David Tolnay
31ca16d9bc
Merge pull request #2804 from Mingun/adjacently-tagged-tests
Consolidate and add new tests of adjacently tagged enums
2024-08-23 14:12:41 -07:00
Mingun
9f72ce695e Struct: add tests for deserialization from sequence
(review this commit with "ignore whitespace changes" option on)
2024-08-16 22:51:42 +05:00
Mingun
c383e4f953 Tuple: add tests for deserialization from sequence
(review this commit with "ignore whitespace changes" option on)
2024-08-16 22:51:16 +05:00
Mingun
a94d8750fb Newtype: move up the test with tag only 2024-08-16 22:51:13 +05:00
Mingun
b0d651be40 Newtype: add tests for deserialization from sequence
(review this commit with "ignore whitespace changes" option on)
2024-08-16 22:51:13 +05:00
Mingun
d5a9c11b5c No need to test integer and byte array field names, they already tested for Unit case
There is no difference what variant is deserialized so we can test only one kind of variant
2024-08-16 22:51:10 +05:00
Mingun
6bfe1c435a Unit: add tests for deserialization from bytes tag and content fields 2024-08-16 22:43:15 +05:00
Mingun
a02da49b87 Unit: add tests for deserialization from integer tag and content fields 2024-08-16 22:43:15 +05:00
Mingun
29dc6c3367 Unit: add tests for deserialization from sequence
(review this commit with "ignore whitespace changes" option on)
2024-08-16 22:38:02 +05:00
Mingun
a7f0bab078 Document fields in internal structs used to deserialize adjacently tagged enums 2024-08-16 21:39:55 +05:00
Mingun
3dc6829303 Integrate bytes test into struct_ test
`newtype` test also integrates test with `Bytes` tag, so be like

Removed the first assert_tokens because it is the same as the first assert in the merged method
2024-08-16 21:39:53 +05:00
Mingun
42e63ff942 Reuse AdjacentlyTagged enum in bytes test
Change 0i32 to 1u8 so the test can be merged with the previous in the next commit
2024-08-16 21:38:23 +05:00
Mingun
df07751e6f Group newtype and newtype_with_newtype tests 2024-08-16 21:36:56 +05:00
Mingun
5445f1741b Reuse AdjacentlyTagged enum in newtype_with_newtype test 2024-08-16 21:36:56 +05:00
Mingun
9d0f811221 Remove unnecessary generic 2024-08-16 21:36:56 +05:00
Mingun
36b9a859c4 Test deserialization of the serialized unit format for adjacently tagged enum 2024-08-16 21:36:55 +05:00
Mingun
59628d1712 Create only one value for all checks 2024-08-16 21:36:55 +05:00
Mingun
bee7470715 Split test test_adjacently_tagged_enum into four tests for each variant
(review this commit with "ignore whitespace changes" option on)
2024-08-16 21:36:55 +05:00
Mingun
5a359e10f4 Group Newtype variant checks in test_adjacently_tagged_enum together 2024-08-16 21:36:55 +05:00
Mingun
5e37ade519 Move all adjacently tagged enum tests (except flatten) into a dedicated module
Moved and renamed:
From test_annotatons
- test_adjacently_tagged_enum_bytes               => bytes
- flatten::enum_::adjacently_tagged::straitforward=> struct_with_flatten
- test_expecting_message_adjacently_tagged_enum   => expecting_message
- test_partially_untagged_adjacently_tagged_enum  => partially_untagged

From test_macros
- test_adjacently_tagged_newtype_struct           => newtype_with_newtype
- test_adjacently_tagged_enum
- test_adjacently_tagged_enum_deny_unknown_fields => deny_unknown_fields
2024-08-16 21:36:52 +05:00
David Tolnay
1a9ffdbd0c
Merge pull request #2788 from Mingun/internally-tagged-enum-tests
Consolidate and add new tests of internally tagged enums
2024-08-15 14:42:28 -07:00
Mingun
2adb0e99b0 Add additional checks for unit and newtype_unit tests
- check that unit variant can be deserialized from a map
- check that newtype variant with unit can be deserialized from a struct
2024-08-15 23:39:14 +05:00
Mingun
71ed1f2f12 Add tests for special and general cases for internally tagged enums
Special case is the tag field first (so the enum variant are known after reading the first entry from map).
General case is the tag field not the first (so we need to buffer entries until we found an entry with tag)
2024-08-15 23:39:13 +05:00
Mingun
47954502af Add tests with borrowed strings for the tag field name and tag value 2024-08-15 23:39:13 +05:00
Mingun
4987fd15f7 Convert newtype_enum and struct_enum tests into modules
Separate testing each variant kind of enum (unit, newtype, tuple, struct) results
in more specific information if that checks fail

(review this commit with "ignore whitespace changes" option on)
2024-08-15 23:39:12 +05:00