Commit Graph

240 Commits

Author SHA1 Message Date
David Tolnay
c6b6e2a5d9
Rename serde_item to serde_internals 2016-06-30 19:42:55 -07:00
Erick Tryzelaar
5941f1d071 Version bump the syntex stack 2016-06-22 20:19:47 -07:00
David Tolnay
5c6a0e12e9
Factor attr parsing into serde_item crate 2016-06-19 20:15:49 -07:00
David Tolnay
882d130e19
Test duplicates within a single attribute 2016-06-16 23:45:34 -07:00
David Tolnay
5f84e601b6
Add explanation of ignored errors in attr.rs 2016-06-16 23:25:46 -07:00
David Tolnay
ac69524258
Gather attrs at the beginning 2016-06-15 02:38:47 -07:00
David Tolnay
28589620f6
Error on duplicate attributes 2016-06-14 20:39:21 -07:00
Homu
b838651ac9 Auto merge of #378 - dtolnay:str, r=oli-obk
Better error when deriving Deserialize for struct containing &str

Fixes #360. The error looks like this:

```rust
#[derive(Serialize, Deserialize)]
struct Test<'a> {
    s: &'a str,
}
```

```
src/main.rs:6:5: 6:15 error: Serde does not support deserializing fields of type &str; consider using String instead
src/main.rs:6     s: &'a str,
                  ^~~~~~~~~~
```
2016-06-14 00:49:26 +09:00
David Tolnay
c5f606f10f
Remove unnecessary Syntexes 2016-06-12 15:50:45 -07:00
David Tolnay
c21bea8b30
Better error when deriving Deserialize for struct containing &str 2016-06-11 21:32:53 -07:00
Erick Tryzelaar
48da62ed07 Updating to rustc 1.11.0-nightly (7d2f75a95 2016-06-09) 2016-06-11 08:19:51 -07:00
David Tolnay
3119cc8857
Simplify implementation of #[serde(default=...)] 2016-06-09 23:21:42 -07:00
David Tolnay
bb059b97c0
Release 0.7.9 2016-06-09 20:16:49 -07:00
David Tolnay
c716c4e261
Use AsRef to accept paths in serde_codegen::expand 2016-06-09 11:23:43 -07:00
David Tolnay
3d2e3beafe
Add serde_codegen::expand to avoid public Syntex dependency 2016-06-09 11:23:43 -07:00
David Tolnay
58fa302007
Release 0.7.8 2016-06-06 10:13:52 -07:00
Homu
bf33daf124 Auto merge of #354 - dtolnay:attr, r=oli-obk
Fix attributes canceling each other

Fixes #353.
2016-06-06 18:08:20 +09:00
David Tolnay
bdffaf3ea1
Re-enable clippy lint "useless_let_if_seq"
This reverts commit 4e6cd2d63f.
2016-06-05 13:01:22 -07:00
David Tolnay
01dfad6705
Fix attributes canceling each other 2016-06-05 11:40:30 -07:00
David Tolnay
2e06786262
Remove unnecessary clones 2016-06-05 11:23:01 -07:00
David Tolnay
578f34ecaf
Use "bound" attribute instead of "where" 2016-06-05 11:17:43 -07:00
David Tolnay
45c51d3198 Fix build on 1.5.0 which does not have Vec::as_slice 2016-06-04 16:53:45 -07:00
David Tolnay
bd40830905 Do not generate bounds from recursive types 2016-06-04 16:12:01 -07:00
David Tolnay
4e6cd2d63f Disable clippy lint "useless_let_if_seq" 2016-06-04 15:48:44 -07:00
David Tolnay
2256a04926 Address clippy lint "ptr_arg" 2016-06-04 15:48:44 -07:00
David Tolnay
660ea7bd7b Attribute for handwritten where clauses 2016-06-04 15:48:42 -07:00
Oliver Schneider
5c2cf5778f
also publish the .in file used by the build script 2016-06-01 13:09:43 +02:00
Oliver Schneider
96cd910c92
undo the breaking change introduced in 0.7.6 2016-06-01 11:08:59 +02:00
Homu
e0bd57d63c Auto merge of #347 - erickt:master, r=erickt
Add "include" to Cargo.toml files

This filters out junk files from the crates.

Closes #331.
2016-05-30 23:23:57 +09:00
Erick Tryzelaar
2c69ccdca4 Add the build script to the Cargo include section 2016-05-30 07:23:09 -07:00
Erick Tryzelaar
66eddd4d9b Add "include" to Cargo.toml files
This filters out junk files from the crates.

Closes #331.
2016-05-30 07:00:13 -07:00
Manish Goregaokar
379c9e7148
Rustup too rustc 1.11.0-nightly (7746a334d 2016-05-28) 2016-05-30 14:01:57 +05:30
David Tolnay
938f42faf6 Support (de)serialize_with in tuples 2016-05-19 10:53:38 -07:00
David Tolnay
f1b4072444 Strip more references 2016-05-18 23:48:56 -07:00
David Tolnay
7d2423e856 Reduce code duplication in Deserialize generator
This combines deserialize_newtype_struct, deserialize_tuple_struct,
and deserialize_tuple_variant into a single method deserialize_tuple,
as well as deserialize_struct and deserialize_struct_variant into a
single method deserialize_struct. No behavior changes.
2016-05-15 13:32:54 -07:00
David Tolnay
004dcaec3b Remove unused imports and needless borrows 2016-05-13 10:47:09 -07:00
Erick Tryzelaar
41142d41ee Merge pull request #319 from dtolnay/release
Release 0.7.5
2016-05-12 09:30:41 -07:00
David Tolnay
3ad276944a Do not depend on multiple syntex versions 2016-05-11 09:52:28 -07:00
David Tolnay
709ac64dfc Release 0.7.5 2016-05-11 09:36:30 -07:00
Homu
a9a4b2d8e2 Auto merge of #293 - dtolnay:duplicate, r=oli-obk
feat(codegen): Detect repeated struct field when deserializing

Addresses #59. Let me know whether you think we need an escape hatch to opt out of this check.
2016-05-11 19:44:34 +09:00
Oliver Schneider
7374ac499d Merge pull request #311 from dtolnay/deserialize_with
Field with deserialize_with should not implement Deserialize
2016-05-11 11:48:19 +02:00
David Tolnay
eeb4efc19c feat(codegen): Detect repeated struct field when deserializing 2016-05-10 09:52:51 -07:00
David Tolnay
76b70455ec Field with deserialize_with should not implement Deserialize 2016-05-10 09:50:32 -07:00
David Tolnay
f43c8a6267 Prefix type parameters and lifetimes with double underscore 2016-05-10 09:12:38 -07:00
David Tolnay
f4414bfc14 Reduce dependence on type inference 2016-05-07 15:25:13 -07:00
Erick Tryzelaar
8378267b9b Merge pull request #303 from antrik/rustup
Update for latest libsyntax changes
2016-05-03 22:07:38 -07:00
Olaf Buddenhagen
0e9d45da60 Bump version to 0.7.4
Dependencies were updated in previous commit. (For supporting current
Nightly Rust.)

I guess this shouldn't affect our client interface -- which is why these
dependency bumps only get patch level version number updates for Serde,
I presume?
2016-05-02 07:26:16 +02:00
Olaf Buddenhagen
6e7a75c859 Adapt for parser::PathParsingMode interface change in libsyntax
This was renamed upstream in
6c44bea644

It's an incompatible change requiring new versions of syntex, aster, and
quasi.
2016-05-02 07:25:29 +02:00
Olaf Buddenhagen
0ff91e4451 Adapt for removal of old interfaces in libsyntax
9108fb7bae
dropped the `map()` method (among other things) -- so we need to adapt
our code.

This change should be backwards-compatible.
2016-05-02 07:08:43 +02:00
David Tolnay
305fab7c16 fix(codegen): Support extern crate serde not in toplevel module 2016-04-25 09:58:01 -07:00
Erick Tryzelaar
a959073a81 Merge pull request #296 from erickt/master
Fix a warning, bump the versions
2016-04-25 07:58:23 -07:00
Erick Tryzelaar
7bd87feb62 Fix a warning, bump the versions 2016-04-19 12:43:57 -05:00
David Tolnay
fd3c15fb68 fix(codegen): Discard type defaults from impl generics 2016-04-19 10:28:43 -07:00
David Tolnay
886670134a feat(codegen): Infer Default and Deserialize bounds correctly 2016-04-13 21:56:12 -07:00
Erick Tryzelaar
65e36647f5 Merge pull request #283 from dtolnay/defaultskip
fix(codegen): Take into account default=... when skip_deserializing
2016-04-13 08:43:10 -07:00
Erick Tryzelaar
a4de662adb Fix doc links 2016-04-13 08:11:02 -07:00
David Tolnay
ff02b0c741 fix(codegen): Take into account default=... when skip_deserializing 2016-04-12 23:42:24 -07:00
Erick Tryzelaar
6b3958d5fc Merge pull request #282 from erickt/doc
Fix generating serde_{codegen,macros} documentation
2016-04-12 17:08:15 -07:00
Erick Tryzelaar
dbba537b66 Merge branch 'skip_deserializing' of https://github.com/dtolnay/serde into dtolnay-skip_deserializing 2016-04-12 08:52:25 -07:00
Erick Tryzelaar
bc2324fba7 Merge branch 'feature/inhibit' of https://github.com/dtolnay/serde into dtolnay-feature/inhibit 2016-04-12 08:41:02 -07:00
Erick Tryzelaar
9082b75e75 Fix generating serde_{codegen,macros} documentation 2016-04-12 08:36:02 -07:00
Erick Tryzelaar
4b9f751d74 Merge pull request #264 from dtolnay/docs/links
Fix broken documentation links in Cargo.toml
2016-04-12 08:32:14 -07:00
Erick Tryzelaar
1c5d83889c Merge remote-tracking branch 'remotes/origin/master' into renamed_missing_field 2016-04-12 08:24:34 -07:00
David Tolnay
87393b61bb feat(codegen) skip_deserializing 2016-04-10 20:29:37 -07:00
Erick Tryzelaar
a84b6aaedd Bump syntex/aster/quasi version 2016-04-10 19:54:54 -07:00
Joe Wilm
4af850431c Fix deserialize_with in module with Result alias
Result<T, E> aliases usually provide one or both of `T` and `E`. This
would cause an error when using deserialize_with:

    error: wrong number of type arguments: expected 1, found 2

which unhelpfully just pointed to `#[derive(Deserialize)]`
2016-04-05 15:53:51 -07:00
Anthony Ramine
c7c5b50f35 Silence unused_variables warning with empty enums
Deriving Serialize or Deserialize on Void-like enums triggered an
unused_variables warning.
2016-04-03 14:31:04 +02:00
Oliver Schneider
d9b6feef19 pass the renamed deserialize field name to missing_field 2016-03-30 17:29:27 +02:00
Erick Tryzelaar
9785646246 feat(cargo): Update syntex 2016-03-16 23:52:21 -07:00
David Tolnay
fb18a5cc56 Fix broken documentation links in Cargo.toml 2016-03-06 19:28:26 -08:00
David Tolnay
eaff73a541 Where clause for generic types only 2016-02-29 21:53:58 -08:00
David Tolnay
19ec8bbdb9 feat(codegen): Inhibit generic bounds if skip_serializing
The generated code for a struct like:

    struct Test<A, B, C> {
        a: X<A>
        #[serde(skip_serializing)]
        b: B
        #[serde(serialize_with="...")]
        c: C
    }

Used to be:

    impl<A, B, C> Serialize for Test<A, B, C>
        where A: Serialize,
              B: Serialize,
              C: Serialize,
    { ... }

Now it is:

    impl<A, B, C> Serialize for Test<A, B, C>
        where X<A>: Serialize,
    { ... }

Both `skip_serializing` and `serialize_with` mean the type does not need to
implement `Serialize`.
2016-02-28 19:11:51 -08:00
Erick Tryzelaar
57433e1eaa feat(codegen): Optimize deserializing fields from byte strings 2016-02-23 20:38:06 -08:00
Erick Tryzelaar
118476b98b feat(de): Rename de::Error trait methods 2016-02-23 20:21:07 -08:00
Erick Tryzelaar
d6a50b8977 feat(cargo): Version bump to 0.7! 2016-02-23 05:26:07 -08:00
Erick Tryzelaar
740865b637 feat(de): Add an Error::unknown_variant error.
Closes #169
2016-02-21 16:26:52 -08:00
Erick Tryzelaar
78cf29d1d1 feat(codegen): Switch attributes to using using paths not expressions 2016-02-21 15:28:25 -08:00
Erick Tryzelaar
0c35ce0a4f feat(codegen): Improve error messages in annotations 2016-02-21 09:54:03 -08:00
Erick Tryzelaar
c268eb2258 feat(codegen): Remove #[serde(skip_serializing_if_{none,empty})]
`#[serde(skip_serializing_if="...")]` can replace this functionality.
2016-02-18 19:31:43 -08:00
Erick Tryzelaar
40f8e6b061 feat(codegen): Add #[serde(deserialize_with="...")]
This allows a field to be deserialized with an expression instead
of the default deserializer. This simplifies deserializing a struct
or enum that contains an external type that doesn't implement
`serde::Deserialize`. This expression is passed a variable
`deserializer` that needs to be used to deserialize the expression.
2016-02-18 19:13:55 -08:00
Erick Tryzelaar
001cb7ab01 feat(codegen): Add #[serde(serialize_with="...")]
This allows a field to be serialized with an expression instead
of the default serializer. This simplifies serializing a struct
or enum that contains an external type that doesn't implement
`serde::Serialize`. This expression is passed a variable
`serializer` that needs to be used to serialize the expression.
2016-02-18 19:13:55 -08:00
Erick Tryzelaar
de89f95f31 feat(codegen): Add support for #![serde(skip_serialize_if="$expr")]
This allows end users to use an arbitrary expression to decide whether
or not to serialize some field. This expression has access to all the
fields in the struct, but none of the internal state of the Serialize
implementation. For structs, serde implements this by creating a
temporary trait and implementing the struct for it. For struct variants,
the fields are copied by reference into a temporary struct first
before implementing the temporary trait.

This also fixes a bug where the serde_codegen wasn't making calls to
Serializer::serialize_{tuple,struct}_variant{,_elt}.
2016-02-18 19:13:55 -08:00
Erick Tryzelaar
9812a4c9c6 feat(codegen): Allow #[serde(default="123")]
This feature adds support for the default to be specified to be
some expression (which unfortunately needs to be parsed from
a string) without needing this value to have an implementation
of `Default`, or for a new-type wrapper in order to provide an
alternative implementation. This expression is run in a function,
and therefore has no access to any of the internal state of
the deserializer.
2016-02-18 19:13:55 -08:00
Erick Tryzelaar
17bf789708 Merge branch 'v0.6.x' 2016-02-18 09:46:46 -08:00
Erick Tryzelaar
f6a66a5537 feat(cargo): Rustup to latest nightly 2016-02-18 09:27:41 -08:00
Erick Tryzelaar
1236889664 Merge branch 'v0.6.x'
# Conflicts:
#	serde_codegen/src/de.rs
2016-02-14 16:45:59 -08:00
Erick Tryzelaar
fd5ab8c5c8 feat(cargo): Version bump 2016-02-13 22:06:08 -08:00
debris
74b230c183 Update serde_codegen for rustc 1.8.0-nightly (ce4b75f25 2016-02-12) 2016-02-14 03:27:20 +01:00
Erick Tryzelaar
561a373d19 Merge branch 'v0.6.x'
# Conflicts:
#	serde/src/de/mod.rs
#	serde_codegen/src/attr.rs
#	serde_codegen/src/de.rs
#	serde_codegen/src/lib.rs
2016-02-12 21:43:23 -08:00
Erick Tryzelaar
064241f03c fix(serde): Rename visit_struct_key to visit_struct_field
This is more consistent with the rest of the serde naming patterns.
2016-02-12 21:22:42 -08:00
Erick Tryzelaar
32163cd53b feat(cargo): Version bump 2016-02-12 21:06:47 -08:00
Erick Tryzelaar
3a5aa00262 fix(codegen): Fix clippy cfg_attr 2016-02-12 20:21:52 -08:00
Joe Wilm
9985d2ebfc plugin(clippy) now relies on feature = "clippy"
Was previously nightly. This resulted in compilation error when the
clippy feature was not enabled because the clippy crate could not be
found.
2016-02-10 11:42:33 -08:00
Erick Tryzelaar
46f88037db Merge branch 'v0.6.x' 2016-02-08 14:17:26 -08:00
Erick Tryzelaar
517c2f79b7 chore(cargo): Only depend on clippy when testing 2016-02-08 13:35:26 -08:00
Erick Tryzelaar
0224e212f9 feat(codegen): Allow containers to be renamed
Closes #218
2016-02-08 11:11:36 -08:00
Erick Tryzelaar
b842164fd8 feat(codegen): Support renames that are different when serializing and deserializing
According to #61, if one uses serde to serialize requests that pass
url-encoded parameters to a server, it might get responses back
with a different capitalization scheme. This patch restores the
behavior implemented in #62.

# Conflicts:
#	serde_codegen/src/attr.rs
#	serde_codegen/src/de.rs
#	serde_tests/tests/test_annotations.rs
2016-02-08 10:43:41 -08:00
Erick Tryzelaar
365e5129af refactor(codegen): Add VariantAttrs 2016-02-08 10:43:32 -08:00
Erick Tryzelaar
d0ee5b0b4b feat(codegen): Remove {Ser,Deser}ializer::format
This feature has never been used, and it's complicating the
implementation of #207. We could restore this functionality if there is
ever interest in it.

Closes #211.
2016-02-08 10:10:00 -08:00
Erick Tryzelaar
5d4f9ce72b refactor(codegen): Add FieldsAttr::from_{field,variant} 2016-02-08 10:09:30 -08:00