Commit Graph

2912 Commits

Author SHA1 Message Date
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
465392b618
Merge pull request #1499 from sgrif/sg-custom-serde-path
Allow `#[serde(crate = "...")]` to override `extern crate serde`
2019-04-03 09:32:07 -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
ac0d8f61c5
Use non-preview name of Clippy rustup component 2019-03-01 23:11:06 -08:00
David Tolnay
b811588fa0
Release 1.0.89 2019-02-28 17:09:10 -08:00
David Tolnay
5fcdf0ff2b
Sort version-conditional imports at the bottom 2019-02-28 16:53:13 -08:00
David Tolnay
650b723da3
Format with rustfmt 2019-02-14 2019-02-28 16:40:54 -08:00
David Tolnay
97920be33a
Merge pull request #1486 from vorot93/reverse
impl Serialize and Deserialize for core::cmp::Reverse
2019-02-28 16:39:54 -08:00
David Tolnay
58bbaa9e80
Refer to Option through serde::export in generated code 2019-02-28 16:36:17 -08:00
David Tolnay
94f152730c
Merge pull request #1492 from thomaseizinger/1491-clippy-warning
Don't generate code with redundant closures
2019-02-28 16:35:59 -08:00
David Tolnay
535e3d4372
Mention rc feature in list of trait impls in documentation 2019-02-28 01:13:36 -08:00
Thomas Eizinger
2ea43c8986 Don't generate code with redundant closures
Fixes #1491.
2019-02-28 17:30:21 +11:00
Artem Vorotnikov
71fe2a5534
Reverse impls available for Rust >=1.19 2019-02-20 12:56:35 +03:00
Artem Vorotnikov
f3ffcfd61e
impl Serialize and Deserialize for core::cmp::Reverse 2019-02-20 04:32:55 +03:00
David Tolnay
bf27b28554
Simplify running update-references.sh 2019-02-17 10:58:46 -08:00
David Tolnay
344602d27e
Make array ser impls macro better fit rustfmt style 2019-02-16 15:22:53 -08:00
David Tolnay
64c483cf80
Release 1.0.88 2019-02-15 19:55:50 -08:00
David Tolnay
19091aacc7
Fix mistaken double negative in flatten error message 2019-02-15 18:56:31 -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
Johannes Willbold
1d6ef76cfb Fixed #1468, flattened struct fields made structs ignore their tag 2019-02-03 02:09:37 +01:00
David Tolnay
c8e3959435
Release 1.0.86 2019-02-01 21:07:19 -08:00
David Tolnay
796f412a1e
Document that Bound<T> impls exist 2019-02-01 21:07:18 -08:00
David Tolnay
fa854a2108
Format with rustfmt 2018-12-10 2019-02-01 21:04:08 -08:00
David Tolnay
3a097ff2d2
Deserialize Bound::Unbounded as unit variant 2019-02-01 21:04:07 -08:00
David Tolnay
8463bfc1e5
Remove as yet unrequested range impls 2019-02-01 21:04:06 -08:00
David Tolnay
7a72b4c624
Merge pull request #1466 from 0nkery/master
Impl Serialize/Deserialize for std::ops::{Bound, RangeFrom, RangeTo, RangeToInclusive}
2019-02-01 21:03:55 -08:00
David Tolnay
670c179417
Re-enable deny unused_imports 2019-02-01 17:56:52 -08:00
David Tolnay
1b1d868837
Combine the two clippy lists 2019-02-01 17:56:31 -08:00
David Tolnay
d9704d02bb
Remove clippy lints that are no longer triggering 2019-02-01 17:53:14 -08:00
David Tolnay
1349548367
Fix indentation of cfg that isn't formatted by rustfmt 2019-02-01 17:48:14 -08:00
Dmitry Shlagoff
18b1604fc8 Fix compatibility issues with syntax and Bound 2019-01-30 00:41:03 +07:00
Dmitry Shlagoff
0def7da5a8 Impl Ser/De for RangeFrom, RangeTo, RangeToInclusive 2019-01-29 20:29:14 +07:00
Dmitry Shlagoff
4bb45c8252 Impl Serialize for Bound<T> 2019-01-29 15:20:27 +07:00
David Tolnay
bb99b31eb0
Release 1.0.85 2019-01-18 22:36:49 -08:00
David Tolnay
84397183f3
Fix spelling of alises -> aliases 2019-01-18 22:34:23 -08:00
David Tolnay
aeae265777
Simpler way to get single element from vector 2019-01-18 22:33:43 -08:00
David Tolnay
a9c5df5da1
Remove unused Clone on attr::Attr 2019-01-18 22:31:25 -08:00
David Tolnay
96576c4de9
Merge pull request #1458 from Lymia/master
Implements alias annotation and allow multiple deserialization renames.
2019-01-18 22:29:57 -08:00
David Tolnay
9ec68e5829
Re-export is no longer just for optional serde cfg 2019-01-18 00:48:05 -08:00
David Tolnay
face857d5e
Update crates.io readme to 2018 edition 2019-01-18 00:44:17 -08:00