Oli Scherer
04bb76bc00
Merge pull request #2558 from Mingun/correct-span
...
Improve error reporting about mismatched signature in `with` and `default` attributes
2024-10-21 21:38:09 +02:00
David Tolnay
f61d452814
Touch up PR 2795
2024-08-12 13:03:10 -07:00
Mingun
8b769fcc20
Remove unused component from tuple
2024-08-12 19:05:57 +05:00
Mingun
9c954264f4
Include variant aliases in error messages
2024-08-12 19:05:04 +05:00
Mingun
fd5b5e9aa5
Correctly calculate has_flatten attribute in all cases for deserialization
...
Consequence: `FlattenSkipDeserializing[DenyUnknown]`
- does not collect data in Field, because do not read them anyway
- gets `deserialize_in_place` method
- gets ability to deserialize from sequence (visit_seq method)
- uses `deserialize_struct` instead of `deserialize_map`
2024-08-11 20:01:33 +05:00
Mingun
0647a7c1fe
Fix creating and filling a collections that was not read
2024-08-11 20:01:00 +05:00
David Tolnay
e52b7b380f
Touch up PR 2567
2024-08-11 00:05:56 -07:00
Mingun
b4ec2595c9
Correctly process flatten fields in enum variants
...
- Fix incorrect deserialization of variants that doesn't contain flatten field when other contains
- Fix a panic when deriving `Deserialize` for an enum with tuple and struct with flatten field
Fixes (2):
regression::issue2565::simple_variant
regression::issue1904 (compilation)
2024-08-09 19:59:23 +05:00
David Tolnay
32958dec3b
Skip collecting unmatched fields in variants that do not use flatten
2024-08-07 18:43:47 -07:00
Mingun
74b538b8ec
Produce error about mismatched types of #[serde(with = "...")] and #[serde(default = "...")] attributes on the attribute itself
2024-08-05 00:29:37 +05:00
David Tolnay
8de84b7ca3
Resolve get_first clippy lint
...
warning: accessing first element with `variant.fields.get(0)`
--> serde_derive/src/de.rs:1843:27
|
1843 | let default = variant.fields.get(0).map(|field| {
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `variant.fields.first()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first
= note: `-W clippy::get-first` implied by `-W clippy::all`
= help: to override `-W clippy::all` add `#[allow(clippy::get_first)]`
warning: accessing first element with `variant.fields.get(0)`
--> serde_derive/src/de.rs:1888:27
|
1888 | let default = variant.fields.get(0).map(|field| {
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `variant.fields.first()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first
2023-10-21 22:01:10 -07:00
David Tolnay
b908487476
Remove double nesting of first_attempt
...
`expr` is of type serde_derive::fragment::Expr, which can be
interpolated directly in any expression position. It does not
need to be nested in another set of braces.
2023-10-12 19:18:42 -07:00
Adam H. Leventhal
8da2058e2a
fix deserialization of untagged variants within internally or adjacently
...
tagged enums
2023-09-07 17:19:27 -07:00
Adam H. Leventhal
09993a904a
Fix for "cannot infer type" from Deserialize derive macro with simple
...
variants and untagged variants
2023-09-06 15:33:28 -07:00
pinkforest
360606b9a6
Following consensus on: #2580 (review)
...
This PR phases out the precompiled per final consensus made in #2580
i#
Fix a cfg
2023-08-21 13:53:48 +10:00
Mingun
070cce0d9c
Get rid of temporary variable
2023-08-06 19:55:48 +05:00
Mingun
b58e8bac12
Replace if let Some(...) = ... to Option::map
2023-08-06 19:53:39 +05:00
Mingun
ada50b077e
ignore_variant variable is always None, let's take this into account
2023-08-06 19:36:48 +05:00
Mingun
5e313a7330
Move generiс code out-of-function, create more specialized and simple code
2023-08-06 19:35:27 +05:00
Mingun
2a36d11238
Introduce a dedicated function for generating Field enum
...
(the enum that represents all fields of a struct)
2023-08-06 19:32:53 +05:00
David Tolnay
fc273c6763
Resolve needless_return clippy lint in PR 2553
...
warning: unneeded `return` statement
--> serde_derive/src/de.rs:2986:13
|
2986 | return quote!(#assign_to __default.#member);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
= note: `-W clippy::needless-return` implied by `-W clippy::all`
help: remove `return`
|
2986 - return quote!(#assign_to __default.#member);
2986 + quote!(#assign_to __default.#member)
|
2023-08-05 22:16:19 -07:00
David Tolnay
73931692b2
Merge pull request #2553 from Mingun/default-on-tuples
...
Allow `#[serde(default)]` on tuple structs
2023-08-05 22:12:10 -07:00
David Tolnay
4d93e9f44c
Keep deserialize aliases as a sorted set
2023-08-05 17:06:11 -07:00
David Tolnay
da55ed7e8d
Remove some clones of names of things
2023-08-05 17:01:34 -07:00
David Tolnay
431636af0d
Merge pull request #2458 from Mingun/identifier
...
Keep aliases always sorted and include aliases in expecting message for field/variant_identifier
2023-08-05 16:39:14 -07:00
Mingun
5c33931422
Allow #[serde(default)] on tuple structs
2023-08-03 22:32:34 +05:00
David Tolnay
4aa54222f4
Delete double reference when setting up adjacently tagged variant seed
2023-08-01 22:54:47 -07:00
David Tolnay
ef4f860384
Improve "expecting" message of adjacently tagged enum variant
2023-08-01 22:49:44 -07:00
David Tolnay
43035f6f37
Merge pull request #2505 from Baptistemontan/rework_adjacently_tagged_enum
...
Revisit of the representation of adjacently tagged enums tag
2023-08-01 22:25:31 -07:00
Mingun
878110a4bc
Simplify code after dead code elimination
2023-08-01 19:03:21 +05:00
Mingun
59ec8b7db2
Remove dead code - variant_ident and deserializer are always None
2023-08-01 19:03:20 +05:00
Mingun
cae1b43829
Inline deserialize_newtype_struct_in_place
2023-08-01 19:03:19 +05:00
Mingun
99fde4ee3e
Implement #2387 also for deserialize_in_place method
2023-08-01 19:03:19 +05:00
Mingun
afe3872810
Simplify check for missing fields
2023-08-01 19:03:18 +05:00
Mingun
3a3e6bf103
Reorder variables to match order in final quote!
2023-08-01 19:03:18 +05:00
Mingun
935f0bd70f
Merge some quote! blocks
2023-08-01 19:03:17 +05:00
Mingun
5c18bfeda6
Inline deserialize_struct_as_struct_in_place_visitor
2023-08-01 19:03:17 +05:00
Baptiste de Montangon
957ef206d1
Revisit of the representation of adjacently tagged enums tag
2023-07-31 20:53:02 +02:00
David Tolnay
6f1f38d046
Replace 'try!' with '?' in serde_derive
2023-07-27 19:16:11 -07:00
David Tolnay
0fb672a1ef
Eliminate #[macro_use] from serde_derive
2023-07-25 23:23:24 -07:00
David Tolnay
dd9913675d
Ungroup imports
2023-07-25 23:06:34 -07:00
David Tolnay
30f79b3b2e
Eliminate 2015-style module system imports from serde_derive
2023-07-25 20:56:19 -07:00
Mingun
f709fc05b0
Do not run the code when results are not used
2023-07-23 15:23:39 +05:00
Mingun
089aae1292
Eliminate even more allocations
2023-07-23 15:23:39 +05:00
Mingun
855acaf112
Eliminate additional allocations for flattening aliases
2023-07-23 15:23:38 +05:00
Mingun
7ca7720262
Slightly reduced number of allocations
2023-07-23 15:23:37 +05:00
Mingun
78fea3aa4a
Show possible aliases in the expected message
...
Fixes tests
2023-07-23 15:23:37 +05:00
David Tolnay
2027088741
Support precompiled deserialize_in_place
2023-07-19 12:27:37 -07:00
David Tolnay
f75426f47e
Inline visitor_expr of unit struct deserialize impl
2023-07-09 18:03:58 -07:00
Baptiste de Montangon
89c8d85de9
allow Deserialize derive to handle generic unit structs
2023-07-10 01:31:40 +02:00