Commit Graph

577 Commits

Author SHA1 Message Date
David Tolnay
3022064f84
Suppress option_if_let_else clippy pedantic lint 2020-07-14 18:57:24 -07:00
David Tolnay
9c6f0c3a0e
Release 1.0.114 2020-06-21 17:31:02 -07:00
David Tolnay
a9f8ea0a1e
Simplify search for packed repr attr 2020-06-21 17:22:07 -07:00
Tanner Rogalsky
1cd10a7d09 Improved packed repr matching. 2020-06-21 16:46:27 -07:00
David Tolnay
7350b58f5c
Release 1.0.113 2020-06-19 13:31:38 -07:00
David Tolnay
7351e0e55a
Link to feature announcements where available 2020-06-19 13:30:14 -07:00
Taiki Endo
a50e1c20e9 Use underscore consts on Rust 1.37+ 2020-06-19 15:55:43 +09:00
David Tolnay
f3520e526b
Release 1.0.112 2020-06-14 11:16:04 -07:00
David Tolnay
95b1a5d3d9
Ignore unnested_or_patterns suggesting unstable code
Clippy bug: https://github.com/rust-lang/rust-clippy/issues/5704
2020-06-10 19:41:16 -07:00
David Tolnay
0856a2c101
No need to specify Cargo.toml in package.include
Cargo.toml is always included in the published crate.
2020-06-10 01:21:19 -07:00
David Tolnay
9f331cc257
Release 1.0.111 2020-05-29 18:53:07 -07:00
David Tolnay
c45a809d5c
Look inside of None-delimited groups when examining types 2020-05-29 17:58:34 -07:00
David Tolnay
078b171c1b
Release 1.0.110 2020-05-09 23:06:56 -07:00
David Tolnay
da8d6f678e
Simplify finding of repr(packed) attributes 2020-05-09 23:02:49 -07:00
David Tolnay
548eb8f667
Format PR 1791 with rustfmt 2020-05-09 22:54:42 -07:00
David Tolnay
1fe39043ee
Simplify access of packed struct fields in derived Serialize impls 2020-05-09 22:53:38 -07:00
alvardes
9f47c47cad Add support for packed structs. 2020-05-09 22:45:44 -07:00
David Tolnay
dda070f45c
Fix borrow error on pre-NLL compilers
error[E0506]: cannot assign to `missing_content` because it is borrowed
        --> serde_derive/src/de.rs:1414:9
         |
    1388 |           .filter_map(|(i, variant)| {
         |                       -------------- borrow of `missing_content` occurs here
    ...
    1414 | /         missing_content = quote! {
    1415 | |             match __field {
    1416 | |                 #(#missing_content_arms)*
    1417 | |                 #missing_content_fallthrough
    1418 | |             }
    1419 | |         };
         | |_________^ assignment to borrowed `missing_content` occurs here

    error[E0502]: cannot borrow `missing_content_fallthrough` as immutable because it is also borrowed as mutable
        --> serde_derive/src/de.rs:1414:27
         |
    1388 |           .filter_map(|(i, variant)| {
         |                       -------------- mutable borrow occurs here
    ...
    1404 |                       missing_content_fallthrough = quote!(_ => #missing_content);
         |                       --------------------------- previous borrow occurs due to use of `missing_content_fallthrough` in closure
    ...
    1414 |           missing_content = quote! {
         |  ___________________________^
    1415 | |             match __field {
    1416 | |                 #(#missing_content_arms)*
    1417 | |                 #missing_content_fallthrough
    1418 | |             }
    1419 | |         };
         | |_________^ immutable borrow occurs here
    ...
    1622 |   }
         |   - mutable borrow ends here
         |
         = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
2020-05-09 22:37:31 -07:00
David Tolnay
b97a183e82
Release 1.0.109 2020-05-09 21:00:51 -07:00
David Tolnay
9433004307
Omit missing content match if not needed 2020-05-09 20:59:01 -07:00
David Tolnay
9476838264
Omit missing content fallthrough arm if not needed 2020-05-09 20:59:00 -07:00
asdsad
172edc4cf4
Allow optional content field for adjacently tagged newtype variants
* Deserialize adjacently tagged newtype variants with optional content as None instead of erroring when content field is missing

* refactor to remove duplicate code and remove panic
2020-05-09 20:58:28 -07:00
David Tolnay
ea2789df0f
Release 1.0.108 2020-05-09 17:53:23 -07:00
David Tolnay
f63acb52dc
Release 1.0.107 2020-05-08 15:45:36 -07:00
David Tolnay
63809e69c7
Fix indexing bug when skip and other are combined 2020-05-08 15:39:07 -07:00
David Tolnay
60522937af
Remove CI badge from Cargo.toml
Support for badges has been deprecated by crates.io.
2020-05-01 21:11:02 -07:00
David Tolnay
b6def5300a
Resolve redundant_field_names lint in serde_derive 2020-04-05 21:07:52 -07:00
David Tolnay
1b35c9e27e
Update serde_derive to tool attrs 2020-04-05 21:00:58 -07:00
David Tolnay
d1564525ad
Release 1.0.106 2020-04-03 14:26:42 -07:00
robo9k
a135199ab1 Hide generated dummy const in rustdoc 2020-04-03 22:21:38 +02:00
David Tolnay
69653a762d
Release 1.0.105 2020-03-18 11:42:51 -07:00
David Tolnay
078e88b223
Select a single docs.rs build target 2020-03-17 13:31:35 -07:00
David Tolnay
1894cb703f
Resolve clippy question_mark lint 2020-03-05 19:48:07 -08:00
David Tolnay
27c283ab53
Suppress wildcard import pedantic lints 2020-02-26 21:00:12 -08:00
David Tolnay
142955b109
Ignore struct_excessive_bools pedantic lint 2020-02-12 19:34:14 -08:00
David Tolnay
cb1632e957
Fix unused_parens lint
These are left over from a series of unfortunate rustfmt interactions.
ee75e6c0e9 (diff-c052b162f01a664f8184ef1855d1f1cfL767-R735)
cc2558b0dc (diff-c052b162f01a664f8184ef1855d1f1cfL733-R738)
9f38ca032e (diff-c052b162f01a664f8184ef1855d1f1cfL779-R782)
2020-01-25 00:05:15 -08:00
David Tolnay
dfa321a1dd
Ignore wildcard_in_or_patterns lint 2020-01-14 20:31:03 -08:00
David Tolnay
234fbfd7e3
Release 1.0.104 2019-12-15 20:01:04 -08:00
David Tolnay
d540e72fc7
Format with rustfmt 2019-10-07 2019-11-26 00:02:11 -08:00
David Tolnay
43a9f59c18
Release 1.0.103 2019-11-24 16:15:13 -08:00
David Tolnay
2ceabad360
Release 1.0.102 2019-10-27 13:39:27 -07:00
David Tolnay
5db72b8ad9
Ignore must_use_candidate pedantic lint 2019-10-17 11:05:28 -04:00
David Tolnay
d4d737de8d
Resolve redundant_clone lint 2019-10-08 21:16:45 -07:00
David Tolnay
4aba6fae78
Release 1.0.101 2019-09-16 00:32:28 -07:00
David Tolnay
fe06bc2f88
More concise explanation of allow(unused_variables) 2019-09-16 00:31:23 -07:00
David Tolnay
8dfb4cd02f
Merge pull request #1617 from arilotter/master
Fix unused variable warning when field of adjacently tagged enum is skipped
2019-09-15 23:51:39 -07:00
David Tolnay
d1ade37827
Ignore new too_many_lines lint 2019-09-10 23:15:59 -07:00
Ari Lotter
9de49241fb Bug fix for #1610
Allow unused variables in tuple in AdjacentlyTagged serializer
2019-09-09 10:43:05 -04:00
David Tolnay
b24d50160a
Remove use of ref keyword from serde_derive 2019-09-07 23:16:02 -07:00
David Tolnay
a3157c9572
Produce errors on attr that fails to parse as Meta 2019-09-07 22:46:50 -07:00
David Tolnay
0d4722680a
Use flatten() to iterate serde meta items 2019-09-07 22:44:25 -07:00
David Tolnay
7ab12597bb
Un-wrap error message strings for better grepping 2019-09-07 22:40:24 -07:00
David Tolnay
b86a46c83c
Factor skipping in newtype variants into effective_style 2019-09-07 22:16:56 -07:00
David Tolnay
187a0a3ec0
Format with rustfmt 2019-08-19 2019-09-07 22:16:49 -07:00
David Tolnay
111c18dec3
Merge pull request #1622 from Xaeroxe/fix-new-types
Fix (de)serialization of new types where the internal type is skipped
2019-09-07 22:16:40 -07:00
David Tolnay
7a2b137912
Reuse span in default deserialize_with path for Cows 2019-09-07 20:24:59 -07:00
David Tolnay
b6a77c4413
Release 1.0.100 2019-09-07 18:55:50 -07:00
Jake Kiesel
fcbb3d3783 Add support for other enum representations 2019-09-07 11:43:53 -06:00
Jake Kiesel
acc8640c1e Fix (de)serialization of new types where the internal type is skipped 2019-09-07 03:20:43 -06:00
David Tolnay
192f5cd647
Release 1.0.99 2019-08-16 11:50:19 -07:00
David Tolnay
3ea85a28cf
Update to syn/quote 1.0 2019-08-16 11:31:15 -07:00
David Tolnay
de40eb7306
Update serde_derive to use question mark 2019-08-16 11:28:25 -07:00
David Tolnay
668651ee01 Format with rustfmt 2019-07-30 2019-07-31 21:19:46 -07:00
David Tolnay
fb1cacc10e Update Attr structs to hold symbols 2019-07-31 21:06:36 -07:00
David Tolnay
735e56c26f Use symbols when parsing values out of attribute 2019-07-31 21:06:36 -07:00
David Tolnay
97de3dccbb Factor out attr symbols into constants 2019-07-31 21:06:36 -07:00
David Tolnay
690467cbe2
Release 1.0.98 2019-07-28 10:33:34 -07:00
David Tolnay
3ae2bee272
Release 1.0.97 2019-07-17 14:56:51 -07:00
David Tolnay
cf70c3fb05
Format with rustfmt 2019-06-09 2019-07-17 12:27:26 -07:00
David Tolnay
92e0b62c6b
Merge pull request 1526 from fanzeyi/try_from 2019-07-17 12:16:31 -07:00
David Tolnay
cf32a5b204
Release 1.0.96 2019-07-17 12:04:19 -07:00
David Tolnay
da05163d51
Release 1.0.95 2019-07-16 10:08:53 -07:00
David Tolnay
1c1eecabc0
Release 1.0.94 2019-06-27 10:55:12 -07:00
David Tolnay
4cb13b33e0
Release 1.0.93 2019-06-23 12:50:17 -07:00
David Tolnay
89c6a79b6e
Suppress a new pedantic lint 2019-05-31 21:25:36 -07:00
David Tolnay
cd0412bddc
Release 1.0.92 2019-05-31 13:44:01 -07:00
Jonas Platte
e4e110e28f Fix a compile error in derive(Deserialize) with no_std + alloc 2019-05-31 22:16:40 +02:00
David Tolnay
0726623389
Ignore bare_trait_objects lint to support old compilers 2019-05-31 11:34:18 -07:00
Zeyi Fan
4c29eea790 add attribute try_from 2019-05-11 23:31:24 -07:00
David Tolnay
6dd2b4607f
Switch to SPDX 2.1 license expression 2019-05-09 15:21:20 -07:00
David Tolnay
5cc3902ab9
Release 1.0.91 2019-05-06 16:27:04 -07:00
David Tolnay
79a20e9e33
Resolve option_map_unwrap_or_else lint 2019-04-10 22:57:47 -07:00
David Tolnay
0be7f36d51
Release 1.0.90 2019-04-03 09:41:38 -07:00
David Tolnay
4c6cb6e359
Match on serde_path to handle Some(path) and None
I find this a bit easier to follow than map + unwrap_or_else.
2019-04-03 09:40:25 -07:00
David Tolnay
82bde8d166
Format with rustfmt 2019-03-27 2019-04-03 09:40:12 -07:00
David Tolnay
f3c6b9f05a
Simplify signature of Container::serde_path 2019-04-03 09:18:45 -07:00
David Tolnay
2f1945eaf2
Refer directly to serde_path in Deserialize impl
This makes it not a breaking change if we later want to eliminate
the `use #serde_path as _serde;` line.
2019-04-03 09:16:21 -07:00
Sean Griffin
b4d8a55b2a Change serde_path to crate
Also changed the generated code to have at least one thing refer to the
path directly, rather than via `use` -- This shows that the impl *can*
work without `use`, but doesn't actually do all the work to remove the
`use` lines unless we decide we need this feature to work on the 2015
edition
2019-03-28 11:42:50 -06:00
Sean Griffin
0e6ce8fa50 Fix for Rust 1.15 2019-03-20 14:31:49 -06:00
Sean Griffin
a295c38ba3 Allow #[serde(serde_path = "...")] to override extern crate serde
This is intended to be used by other crates which provide their own proc
macros and use serde internally. Today there's no consistent way to put
`#[derive(Deserialize)]` on a struct that consistently works, since
crates may be using either `features = ["derive"]` or relying on
`serde_derive` separately.

Even if we assume that everyone is using `features = ["derive"]`,
without this commit, any crate which generates
`#[derive(serde::Deserialize)]` forces its consumers to put `serde` in
their `Cargo.toml`, even if they aren't otherwise using serde for
anything.

Examples of crates which suffer from this in the real world are
tower-web and swirl.

With this feature, it's expected that these crates would have `pub
extern crate serde;` in some accessible path, and add
`#[serde(serde_path = "that_crate::wherever::serde")]` anywhere they
place serde's derives. Those crates would also have to derive
`that_crate::whatever::serde::Deserialize`, or `use` the macros
explicitly beforehand.

The test for this is a little funky, as it's testing this in a way that
is not the intended use case, or even one we want to support. It has its
own module which re-exports all of serde, but defines its own
`Serialize` and `Deserialize` traits. We then test that we generated
impls for those traits, instead of serde's. The only other way to test
this would be to create a new test crate which does not depend on serde,
but instead depends on `serde_derive` and a third crate which publicly
re-exports serde. This feels like way too much overhead for a single
test case, hence the funky test given.

I didn't see anywhere in this repo to document this attribute, so I
assume the docs will have to be done as a separate PR to a separate
repo.

Fixes #1487
2019-03-18 15:20:19 -06:00
David Tolnay
295730ba1e
Clippy cyclomatic complexity lint has been renamed 2019-03-09 16:36:51 -08:00
David Tolnay
b811588fa0
Release 1.0.89 2019-02-28 17:09:10 -08:00
David Tolnay
58bbaa9e80
Refer to Option through serde::export in generated code 2019-02-28 16:36:17 -08:00
Thomas Eizinger
2ea43c8986 Don't generate code with redundant closures
Fixes #1491.
2019-02-28 17:30:21 +11:00
David Tolnay
64c483cf80
Release 1.0.88 2019-02-15 19:55:50 -08:00
David Tolnay
ef9028d798
Remove conflict between flatten and skip 2019-02-15 18:39:15 -08:00
David Tolnay
1668cd19d3
Eliminate try!(..).value to improve rustfmt'd code
Rustfmt bails out on the original code, leaving it all on one line.
2019-02-13 09:13:50 -08:00
David Tolnay
134f268cee
Release 1.0.87 2019-02-04 07:08:41 +01:00
David Tolnay
c473633676
Format with rustfmt 2018-12-10 2019-02-04 00:39:32 +01:00
David Tolnay
6a3a82007c
Merge pull request #1474 from jwillbold/master
Fixed #1468, flattened struct fields made structs ignore their tag
2019-02-03 15:37:44 -08:00