Skip to content

Conversation

@Mingun
Copy link
Contributor

@Mingun Mingun commented Jul 28, 2024

This PR depends on serde-deprecated/test#6 and currently temporary uses my fork with branch that adds necessary support for testing 128-bit integers. It is possible, however, drop the first two commits, but that will mean that 128-bit integers will not be tested. I'd prefer to merge serde-deprecated/test#6 and then update this PR to use new version of serde_test.

Closes #1682, closes #2230, closes #2576, closes #2948

@WiSaGaN
Copy link
Contributor

WiSaGaN commented Aug 11, 2024

This looks like a pretty clean fix. @dtolnay would you take a look please?

@Pzixel
Copy link

Pzixel commented Apr 26, 2025

Ping?

@robertprp
Copy link

robertprp commented May 22, 2025

Up

(tests\ui\unimplemented\required_by_dependency.rs broken because of changed paths to serde_test)
(review this commit with "ignore whitespace changes" option on)
failures (5): newtype::enum_::newtype (deserialize) newtype::enum_::struct_ (serialize) newtype::enum_::tuple (serialize) newtype::struct_ (deserialize) struct_ (deserialize)
…of internally tagged enums Deserialization not checked because there is no sequence of tokens that could represent test values failures (7): newtype::enum_::newtype (deserialize) newtype::enum_::struct (serialize) newtype::enum_::tuple (serialize) newtype::i128 (serialize) newtype::struct_ (deserialize) newtype::u128 (serialize) struct_ (deserialize)
failures (8): newtype::enum_::newtype (deserialize) newtype::enum_::struct_ (serialize) newtype::enum_::tuple (serialize) newtype::i128 (serialize) newtype::newtype_struct (deserialize) newtype::struct_ (deserialize) newtype::u128 (serialize) struct_ (deserialize)
`Content` size doesn't changed, because it is already big enough (64 bytes due to `TupleVariant` and `StructVariant`). Fixes (2): newtype::i128 (serialize) newtype::u128 (serialize) failures (6): newtype::enum_::newtype (deserialize) newtype::enum_:;struct (deserialize) newtype::enum_::tuple (deserialize) newtype::newtype_struct (deserialize) newtype::struct_ (deserialize) struct_ (deserialize)
…y tagged enums Fixed (6): newtype::enum_::newtype newtype::enum_::struct_ newtype::enum_::tuple newtype::newtype_struct newtype::struct_ struct_
@vmx
Copy link

vmx commented Oct 1, 2025

@Mingun thanks for this PR. I tried it out for my case. It partially fixes the problem I have, hence I comment directly on this PR. In my case I want to be able to deserialize a i128 into other signed integer types if they fit. Similarly to mapping an i64 into other integers.

It applies to all signed integer type, but let's make things concrete and use i32 as an example. The problem is that the PrimitiveVisitor for i32 doesn't implement visit_i128(), hence it falls back to the default implementation, which triggers an invalid_type error.

A workaround is adding in the impl_deserialize_num! { i32 … the i128:visit_128 to int_to_int!(i64:visit_i64);.

Does this belong to this PR or would it be a separate PR? Do you think that would be the correct fix for the issue?

I sadly can't provide a simple test case for it. Mine is pretty entangled as it involves even a Deserializer implementation and I wasn't able to create a simpler version.

@Mingun
Copy link
Contributor Author

Mingun commented Oct 2, 2025

@vmx, you're right, I should update my PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

5 participants