mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-23 02:28:00 +00:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 85c95040b3 | |||
| 339c0f5493 | |||
| b4d5c26f4e | |||
| f4e1ffa2cb | |||
| ef5d09e144 | |||
| e547a06639 | |||
| c61b20cceb | |||
| 42987a5b24 | |||
| 3f28a93240 | |||
| 9970084550 | |||
| 3920993370 | |||
| 22690cedc2 | |||
| b27039d34d | |||
| 1b6fd5a362 | |||
| 8b7b886036 |
+1
-1
@@ -24,7 +24,7 @@ script:
|
||||
- (cd serde && travis-cargo --only nightly build -- --no-default-features --features collections)
|
||||
- (cd testing && travis-cargo --skip nightly test)
|
||||
- (cd testing && travis-cargo --only nightly test -- --features unstable-testing)
|
||||
- (cd serde_macros && travis-cargo --only nightly test -- --features unstable-testing)
|
||||
- (cd serde_derive && travis-cargo --only nightly test)
|
||||
- (cd examples/serde-syntex-example && travis-cargo --skip nightly run)
|
||||
- (cd examples/serde-syntex-example && travis-cargo --only nightly run -- --no-default-features --features unstable)
|
||||
- (cd serde && travis-cargo --only stable doc)
|
||||
|
||||
@@ -15,8 +15,10 @@ You may be looking for:
|
||||
## Serde in action
|
||||
|
||||
```rust
|
||||
#![feature(plugin, custom_derive)]
|
||||
#![plugin(serde_macros)]
|
||||
#![feature(proc_macro)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
|
||||
extern crate serde_json;
|
||||
|
||||
|
||||
@@ -6,12 +6,12 @@ build = "build.rs"
|
||||
|
||||
[features]
|
||||
default = ["serde_codegen"]
|
||||
unstable = ["serde_macros"]
|
||||
unstable = ["serde_derive"]
|
||||
|
||||
[build-dependencies]
|
||||
serde_codegen = { version = "^0.8", optional = true, path = "../../serde_codegen" }
|
||||
|
||||
[dependencies]
|
||||
serde = "^0.8"
|
||||
serde_derive = { version = "^0.8", optional = true, path = "../../serde_derive" }
|
||||
serde_json = "^0.8"
|
||||
serde_macros = { version = "^0.8", optional = true, path = "../../serde_macros" }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#[cfg(not(feature = "serde_macros"))]
|
||||
#[cfg(not(feature = "serde_derive"))]
|
||||
mod inner {
|
||||
extern crate serde_codegen;
|
||||
|
||||
@@ -15,7 +15,7 @@ mod inner {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "serde_macros")]
|
||||
#[cfg(feature = "serde_derive")]
|
||||
mod inner {
|
||||
pub fn main() {}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
#![cfg_attr(feature = "serde_macros", feature(custom_derive, plugin))]
|
||||
#![cfg_attr(feature = "serde_macros", plugin(serde_macros))]
|
||||
#![cfg_attr(feature = "serde_derive", feature(proc_macro))]
|
||||
|
||||
#[cfg(feature = "serde_derive")]
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
|
||||
extern crate serde;
|
||||
extern crate serde_json;
|
||||
|
||||
#[cfg(feature = "serde_macros")]
|
||||
#[cfg(feature = "serde_derive")]
|
||||
include!("main.rs.in");
|
||||
|
||||
#[cfg(not(feature = "serde_macros"))]
|
||||
#[cfg(not(feature = "serde_derive"))]
|
||||
include!(concat!(env!("OUT_DIR"), "/main.rs"));
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "serde"
|
||||
version = "0.8.10"
|
||||
version = "0.8.12"
|
||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
|
||||
license = "MIT/Apache-2.0"
|
||||
description = "A generic serialization/deserialization framework"
|
||||
|
||||
@@ -809,7 +809,7 @@ map_impl!(
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#[cfg(all(feature = "unstable", feature = "std"))]
|
||||
#[cfg(feature = "std")]
|
||||
impl Deserialize for net::IpAddr {
|
||||
fn deserialize<D>(deserializer: &mut D) -> Result<Self, D::Error>
|
||||
where D: Deserializer,
|
||||
|
||||
@@ -640,15 +640,12 @@ impl Serialize for Duration {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#[cfg(all(feature = "std", feature = "unstable"))]
|
||||
#[cfg(feature = "std")]
|
||||
impl Serialize for net::IpAddr {
|
||||
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
|
||||
where S: Serializer,
|
||||
{
|
||||
match *self {
|
||||
net::IpAddr::V4(ref addr) => addr.serialize(serializer),
|
||||
net::IpAddr::V6(ref addr) => addr.serialize(serializer),
|
||||
}
|
||||
self.to_string().serialize(serializer)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "serde_codegen"
|
||||
version = "0.8.10"
|
||||
version = "0.8.12"
|
||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
|
||||
license = "MIT/Apache-2.0"
|
||||
description = "Macros to auto-generate implementations for the serde framework"
|
||||
@@ -22,8 +22,8 @@ with-syn = []
|
||||
|
||||
[dependencies]
|
||||
clippy = { version = "^0.*", optional = true }
|
||||
quote = "0.2"
|
||||
serde_codegen_internals = { version = "=0.9.0", default-features = false, path = "../serde_codegen_internals" }
|
||||
syn = { version = "0.8", features = ["aster", "visit"] }
|
||||
quote = "0.3"
|
||||
serde_codegen_internals = { version = "=0.10.0", default-features = false, path = "../serde_codegen_internals" }
|
||||
syn = { version = "0.9", features = ["aster", "visit"] }
|
||||
syntex = { version = "^0.44.0", optional = true }
|
||||
syntex_syntax = { version = "^0.44.0", optional = true }
|
||||
|
||||
+25
-32
@@ -185,17 +185,17 @@ fn deserialize_visitor(generics: &syn::Generics) -> (Tokens, Tokens, Tokens) {
|
||||
let ty_param_idents = if ty_param_idents.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(quote!(::<#(ty_param_idents),*>))
|
||||
Some(quote!(::<#(#ty_param_idents),*>))
|
||||
};
|
||||
|
||||
let phantom_exprs = iter::repeat(quote!(::std::marker::PhantomData)).take(num_phantoms);
|
||||
|
||||
(
|
||||
quote! {
|
||||
struct __Visitor #generics ( #(phantom_types),* ) #where_clause;
|
||||
struct __Visitor #generics ( #(#phantom_types),* ) #where_clause;
|
||||
},
|
||||
quote!(__Visitor <#(all_params),*> ),
|
||||
quote!(__Visitor #ty_param_idents ( #(phantom_exprs),* )),
|
||||
quote!(__Visitor <#(#all_params),*> ),
|
||||
quote!(__Visitor #ty_param_idents ( #(#phantom_exprs),* )),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -358,17 +358,17 @@ fn deserialize_seq(
|
||||
quote!(#ident: #value)
|
||||
});
|
||||
quote! {
|
||||
#type_path { #(args),* }
|
||||
#type_path { #(#args),* }
|
||||
}
|
||||
} else {
|
||||
let args = (0..fields.len()).map(|i| aster::id(format!("__field{}", i)));
|
||||
quote! {
|
||||
#type_path ( #(args),* )
|
||||
#type_path ( #(#args),* )
|
||||
}
|
||||
};
|
||||
|
||||
quote! {
|
||||
#(let_values)*
|
||||
#(#let_values)*
|
||||
|
||||
try!(visitor.end());
|
||||
|
||||
@@ -505,7 +505,7 @@ fn deserialize_item_enum(
|
||||
let variant_names = variants.iter().map(|variant| variant.ident.to_string());
|
||||
|
||||
let variants_stmt = quote! {
|
||||
const VARIANTS: &'static [&'static str] = &[ #(variant_names),* ];
|
||||
const VARIANTS: &'static [&'static str] = &[ #(#variant_names),* ];
|
||||
};
|
||||
|
||||
let ignored_arm = if item_attrs.deny_unknown_fields() {
|
||||
@@ -551,7 +551,7 @@ fn deserialize_item_enum(
|
||||
where __V: _serde::de::VariantVisitor,
|
||||
{
|
||||
match try!(visitor.visit_variant()) {
|
||||
#(variant_arms)*
|
||||
#(#variant_arms)*
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -651,14 +651,6 @@ fn deserialize_field_visitor(
|
||||
Some(quote!(__ignore,))
|
||||
};
|
||||
|
||||
let field_enum = quote! {
|
||||
#[allow(non_camel_case_types)]
|
||||
enum __Field {
|
||||
#(field_idents,)*
|
||||
#ignore_variant
|
||||
}
|
||||
};
|
||||
|
||||
let index_field_arms: Vec<_> = field_idents.iter()
|
||||
.enumerate()
|
||||
.map(|(field_index, field_ident)| {
|
||||
@@ -686,7 +678,7 @@ fn deserialize_field_visitor(
|
||||
|
||||
let index_body = quote! {
|
||||
match value {
|
||||
#(index_field_arms)*
|
||||
#(#index_field_arms)*
|
||||
_ => #fallthrough_index_arm_expr
|
||||
}
|
||||
};
|
||||
@@ -712,7 +704,7 @@ fn deserialize_field_visitor(
|
||||
|
||||
let str_body = quote! {
|
||||
match value {
|
||||
#(str_field_arms)*
|
||||
#(#str_field_arms)*
|
||||
_ => #fallthrough_str_arm_expr
|
||||
}
|
||||
};
|
||||
@@ -740,12 +732,18 @@ fn deserialize_field_visitor(
|
||||
|
||||
let bytes_body = quote! {
|
||||
match value {
|
||||
#(bytes_field_arms)*
|
||||
#(#bytes_field_arms)*
|
||||
_ => #fallthrough_bytes_arm_expr
|
||||
}
|
||||
};
|
||||
|
||||
let impl_item = quote! {
|
||||
quote! {
|
||||
#[allow(non_camel_case_types)]
|
||||
enum __Field {
|
||||
#(#field_idents,)*
|
||||
#ignore_variant
|
||||
}
|
||||
|
||||
impl _serde::de::Deserialize for __Field {
|
||||
#[inline]
|
||||
fn deserialize<__D>(deserializer: &mut __D) -> ::std::result::Result<__Field, __D::Error>
|
||||
@@ -778,11 +776,6 @@ fn deserialize_field_visitor(
|
||||
deserializer.deserialize_struct_field(__FieldVisitor)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
quote! {
|
||||
#field_enum
|
||||
#impl_item
|
||||
}
|
||||
}
|
||||
|
||||
@@ -816,7 +809,7 @@ fn deserialize_struct_visitor(
|
||||
});
|
||||
|
||||
let fields_stmt = quote! {
|
||||
const FIELDS: &'static [&'static str] = &[ #(field_names),* ];
|
||||
const FIELDS: &'static [&'static str] = &[ #(#field_names),* ];
|
||||
};
|
||||
|
||||
(field_visitor, fields_stmt, visit_map)
|
||||
@@ -929,21 +922,21 @@ fn deserialize_map(
|
||||
});
|
||||
|
||||
quote! {
|
||||
#(let_values)*
|
||||
#(#let_values)*
|
||||
|
||||
while let Some(key) = try!(visitor.visit_key::<__Field>()) {
|
||||
match key {
|
||||
#(value_arms)*
|
||||
#(skipped_arms)*
|
||||
#(#value_arms)*
|
||||
#(#skipped_arms)*
|
||||
#ignored_arm
|
||||
}
|
||||
}
|
||||
|
||||
try!(visitor.end());
|
||||
|
||||
#(extract_values)*
|
||||
#(#extract_values)*
|
||||
|
||||
Ok(#struct_path { #(result),* })
|
||||
Ok(#struct_path { #(#result),* })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -201,7 +201,7 @@ pub fn expand_single_item(item: &str) -> Result<String, String> {
|
||||
let mut de = false;
|
||||
let item = syn::MacroInput {
|
||||
attrs: item.attrs.into_iter().flat_map(|attr| {
|
||||
if attr.is_sugared_doc {
|
||||
if attr.is_sugared_doc || attr.style != syn::AttrStyle::Outer {
|
||||
return Some(attr);
|
||||
}
|
||||
let (name, nested) = match attr.value {
|
||||
@@ -210,6 +210,7 @@ pub fn expand_single_item(item: &str) -> Result<String, String> {
|
||||
};
|
||||
if name != "derive" {
|
||||
return Some(syn::Attribute {
|
||||
style: syn::AttrStyle::Outer,
|
||||
value: syn::MetaItem::List(name, nested),
|
||||
is_sugared_doc: false,
|
||||
});
|
||||
@@ -231,6 +232,7 @@ pub fn expand_single_item(item: &str) -> Result<String, String> {
|
||||
None
|
||||
} else {
|
||||
Some(syn::Attribute {
|
||||
style: syn::AttrStyle::Outer,
|
||||
value: syn::MetaItem::List(name, rest),
|
||||
is_sugared_doc: false,
|
||||
})
|
||||
|
||||
@@ -168,7 +168,7 @@ fn serialize_tuple_struct(
|
||||
|
||||
quote! {
|
||||
let #let_mut __serde_state = try!(_serializer.serialize_tuple_struct(#type_name, #len));
|
||||
#(serialize_stmts)*
|
||||
#(#serialize_stmts)*
|
||||
_serializer.serialize_tuple_struct_end(__serde_state)
|
||||
}
|
||||
}
|
||||
@@ -209,7 +209,7 @@ fn serialize_struct(
|
||||
|
||||
quote! {
|
||||
let #let_mut __serde_state = try!(_serializer.serialize_struct(#type_name, #len));
|
||||
#(serialize_fields)*
|
||||
#(#serialize_fields)*
|
||||
_serializer.serialize_struct_end(__serde_state)
|
||||
}
|
||||
}
|
||||
@@ -238,7 +238,7 @@ fn serialize_item_enum(
|
||||
|
||||
quote! {
|
||||
match *self {
|
||||
#(arms)*
|
||||
#(#arms)*
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -290,7 +290,7 @@ fn serialize_variant(
|
||||
})
|
||||
.collect();
|
||||
|
||||
let pat = quote!(#type_ident::#variant_ident(#(field_names),*));
|
||||
let pat = quote!(#type_ident::#variant_ident(#(#field_names),*));
|
||||
|
||||
let block = serialize_tuple_variant(
|
||||
type_name,
|
||||
@@ -313,7 +313,7 @@ fn serialize_variant(
|
||||
};
|
||||
quote!(ref #id)
|
||||
});
|
||||
let pat = quote!(#type_ident::#variant_ident { #(fields),* });
|
||||
let pat = quote!(#type_ident::#variant_ident { #(#fields),* });
|
||||
|
||||
let block = serialize_struct_variant(
|
||||
variant_index,
|
||||
@@ -381,7 +381,7 @@ fn serialize_tuple_variant(
|
||||
#variant_index,
|
||||
#variant_name,
|
||||
#len));
|
||||
#(serialize_stmts)*
|
||||
#(#serialize_stmts)*
|
||||
_serializer.serialize_tuple_variant_end(__serde_state)
|
||||
}
|
||||
}
|
||||
@@ -428,7 +428,7 @@ fn serialize_struct_variant(
|
||||
#variant_name,
|
||||
#len,
|
||||
));
|
||||
#(serialize_fields)*
|
||||
#(#serialize_fields)*
|
||||
_serializer.serialize_struct_variant_end(__serde_state)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "serde_codegen_internals"
|
||||
version = "0.9.0"
|
||||
version = "0.10.0"
|
||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
|
||||
license = "MIT/Apache-2.0"
|
||||
description = "AST representation used by Serde codegen. Unstable."
|
||||
@@ -15,4 +15,4 @@ unstable-testing = ["clippy"]
|
||||
|
||||
[dependencies]
|
||||
clippy = { version = "^0.*", optional = true }
|
||||
syn = "0.8"
|
||||
syn = "0.9"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "serde_derive"
|
||||
version = "0.8.10"
|
||||
version = "0.8.12"
|
||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
|
||||
license = "MIT/Apache-2.0"
|
||||
description = "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]"
|
||||
@@ -12,15 +12,16 @@ include = ["Cargo.toml", "src/**/*.rs"]
|
||||
|
||||
[lib]
|
||||
name = "serde_derive"
|
||||
rustc-macro = true
|
||||
proc-macro = true
|
||||
|
||||
[dependencies.serde_codegen]
|
||||
version = "=0.8.10"
|
||||
version = "=0.8.12"
|
||||
path = "../serde_codegen"
|
||||
default-features = false
|
||||
features = ["with-syn"]
|
||||
|
||||
[dev-dependencies]
|
||||
compiletest_rs = "^0.2.0"
|
||||
fnv = "1.0"
|
||||
serde = { version = "0.8.10", path = "../serde" }
|
||||
serde_test = { version = "0.8.10", path = "../serde_test" }
|
||||
serde = { version = "0.8.12", path = "../serde" }
|
||||
serde_test = { version = "0.8.12", path = "../serde_test" }
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#![feature(rustc_macro, rustc_macro_lib)]
|
||||
#![feature(proc_macro, proc_macro_lib)]
|
||||
#![cfg(not(test))]
|
||||
|
||||
extern crate rustc_macro;
|
||||
extern crate proc_macro;
|
||||
extern crate serde_codegen;
|
||||
|
||||
use rustc_macro::TokenStream;
|
||||
use proc_macro::TokenStream;
|
||||
|
||||
#[rustc_macro_derive(Serialize)]
|
||||
#[proc_macro_derive(Serialize)]
|
||||
pub fn derive_serialize(input: TokenStream) -> TokenStream {
|
||||
let item = format!("#[derive(Serialize)]\n{}", input);
|
||||
match serde_codegen::expand_single_item(&item) {
|
||||
@@ -15,7 +15,7 @@ pub fn derive_serialize(input: TokenStream) -> TokenStream {
|
||||
}
|
||||
}
|
||||
|
||||
#[rustc_macro_derive(Deserialize)]
|
||||
#[proc_macro_derive(Deserialize)]
|
||||
pub fn derive_deserialize(input: TokenStream) -> TokenStream {
|
||||
let item = format!("#[derive(Deserialize)]\n{}", input);
|
||||
match serde_codegen::expand_single_item(&item) {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
#![feature(proc_macro)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
|
||||
#[derive(Serialize)] //~ ERROR: custom derive attribute panicked
|
||||
struct S {
|
||||
#[serde(rename="x", serialize="y")] //~^^ HELP: unknown serde field attribute `serialize`
|
||||
x: (),
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,13 @@
|
||||
#![feature(proc_macro)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
|
||||
#[derive(Serialize)] //~ ERROR: custom derive attribute panicked
|
||||
struct S {
|
||||
#[serde(rename="x")]
|
||||
#[serde(rename(deserialize="y"))] //~^^^ HELP: duplicate serde attribute `rename`
|
||||
x: (),
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,12 @@
|
||||
#![feature(proc_macro)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
|
||||
#[derive(Serialize)] //~ ERROR: custom derive attribute panicked
|
||||
struct S {
|
||||
#[serde(rename(serialize="x"), rename(serialize="y"))] //~^^ HELP: duplicate serde attribute `rename`
|
||||
x: (),
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,13 @@
|
||||
#![feature(proc_macro)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
|
||||
#[derive(Serialize)] //~ ERROR: custom derive attribute panicked
|
||||
struct S {
|
||||
#[serde(rename(serialize="x"))]
|
||||
#[serde(rename="y")] //~^^^ HELP: duplicate serde attribute `rename`
|
||||
x: (),
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,12 @@
|
||||
#![feature(proc_macro)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
|
||||
#[derive(Serialize)] //~ ERROR: custom derive attribute panicked
|
||||
struct S {
|
||||
#[serde(rename(serialize="x", serialize="y"))] //~^^ HELP: duplicate serde attribute `rename`
|
||||
x: (),
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,13 @@
|
||||
#![feature(proc_macro)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
|
||||
#[derive(Serialize)] //~ ERROR: custom derive attribute panicked
|
||||
struct S {
|
||||
#[serde(rename(serialize="x"))]
|
||||
#[serde(rename(serialize="y"))] //~^^^ HELP: duplicate serde attribute `rename`
|
||||
x: (),
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,11 @@
|
||||
#![feature(proc_macro)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
|
||||
#[derive(Serialize, Deserialize)] //~ ERROR: custom derive attribute panicked
|
||||
struct Test<'a> {
|
||||
s: &'a str, //~^^ HELP: Serde does not support deserializing fields of type &str
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,12 @@
|
||||
#![feature(proc_macro)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
|
||||
#[derive(Serialize)] //~ ERROR: custom derive attribute panicked
|
||||
#[serde(abc="xyz")] //~^ HELP: unknown serde container attribute `abc`
|
||||
struct A {
|
||||
x: u32,
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
@@ -0,0 +1,12 @@
|
||||
#![feature(proc_macro)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
|
||||
#[derive(Serialize)] //~ ERROR: custom derive attribute panicked
|
||||
struct C {
|
||||
#[serde(abc="xyz")] //~^^ HELP: unknown serde field attribute `abc`
|
||||
x: u32,
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
@@ -0,0 +1,12 @@
|
||||
#![feature(proc_macro)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
|
||||
#[derive(Serialize)] //~ ERROR: custom derive attribute panicked
|
||||
enum E {
|
||||
#[serde(abc="xyz")] //~^^ HELP: unknown serde variant attribute `abc`
|
||||
V,
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
+4
-3
@@ -1,8 +1,9 @@
|
||||
#![feature(custom_derive, plugin)]
|
||||
#![plugin(serde_macros, clippy)]
|
||||
|
||||
#![feature(proc_macro)]
|
||||
#![deny(identity_op)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
|
||||
// The derived implementation uses 0+1 to add up the number of fields
|
||||
// serialized, which Clippy warns about. If the expansion info is registered
|
||||
// correctly, the Clippy lint is not triggered.
|
||||
@@ -1,4 +1,4 @@
|
||||
#![feature(test, rustc_macro, rustc_attrs)]
|
||||
#![feature(test, proc_macro)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
@@ -6,3 +6,5 @@ extern crate serde_derive;
|
||||
extern crate test;
|
||||
|
||||
include!("../../testing/tests/test.rs.in");
|
||||
|
||||
mod compile_tests;
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# To prevent compiletest from seeing two versions of serde
|
||||
paths = ["../serde"]
|
||||
@@ -1,2 +0,0 @@
|
||||
/target
|
||||
/Cargo.lock
|
||||
@@ -1,41 +0,0 @@
|
||||
[package]
|
||||
name = "serde_macros"
|
||||
version = "0.8.9"
|
||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
|
||||
license = "MIT/Apache-2.0"
|
||||
description = "Macros to auto-generate implementations for the serde framework"
|
||||
homepage = "https://serde.rs"
|
||||
repository = "https://github.com/serde-rs/serde"
|
||||
documentation = "https://serde.rs/codegen.html"
|
||||
keywords = ["serde", "serialization"]
|
||||
include = ["Cargo.toml", "src/**/*.rs"]
|
||||
|
||||
[lib]
|
||||
name = "serde_macros"
|
||||
plugin = true
|
||||
|
||||
[features]
|
||||
unstable-testing = [
|
||||
"clippy",
|
||||
"serde/unstable-testing",
|
||||
"serde_codegen/unstable-testing"
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
clippy = { version = "^0.*", optional = true }
|
||||
serde_codegen = { version = "=0.8.9", default-features = false, features = ["unstable"], path = "../serde_codegen" }
|
||||
|
||||
[dev-dependencies]
|
||||
compiletest_rs = "^0.2.0"
|
||||
fnv = "1.0"
|
||||
rustc-serialize = "^0.3.16"
|
||||
serde = { version = "0.8.9", path = "../serde" }
|
||||
serde_test = { version = "0.8.9", path = "../serde_test" }
|
||||
|
||||
[[test]]
|
||||
name = "test"
|
||||
path = "tests/test.rs"
|
||||
|
||||
[[bench]]
|
||||
name = "bench"
|
||||
path = "benches/bench.rs"
|
||||
@@ -1,9 +0,0 @@
|
||||
#![feature(custom_attribute, custom_derive, plugin, test)]
|
||||
#![cfg_attr(feature = "clippy", plugin(clippy))]
|
||||
#![plugin(serde_macros)]
|
||||
|
||||
extern crate rustc_serialize;
|
||||
extern crate serde;
|
||||
extern crate test;
|
||||
|
||||
include!("../../testing/benches/bench.rs.in");
|
||||
@@ -1,12 +0,0 @@
|
||||
#![feature(plugin_registrar, rustc_private)]
|
||||
#![cfg_attr(feature = "clippy", feature(plugin))]
|
||||
#![cfg_attr(feature = "clippy", plugin(clippy))]
|
||||
|
||||
extern crate serde_codegen;
|
||||
extern crate rustc_plugin;
|
||||
|
||||
#[plugin_registrar]
|
||||
#[doc(hidden)]
|
||||
pub fn plugin_registrar(reg: &mut rustc_plugin::Registry) {
|
||||
serde_codegen::register(reg);
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
#![feature(custom_attribute, custom_derive, plugin)]
|
||||
#![plugin(serde_macros)]
|
||||
|
||||
#[derive(Serialize)] //~ ERROR: 6 errors:
|
||||
struct S {
|
||||
#[serde(rename(serialize="x"))]
|
||||
#[serde(rename(serialize="y"))] // ERROR: duplicate serde attribute `rename`
|
||||
a: (),
|
||||
|
||||
#[serde(rename(serialize="x"))]
|
||||
#[serde(rename="y")] // ERROR: duplicate serde attribute `rename`
|
||||
b: (),
|
||||
|
||||
#[serde(rename(serialize="x"))]
|
||||
#[serde(rename(deserialize="y"))] // ok
|
||||
c: (),
|
||||
|
||||
#[serde(rename="x")]
|
||||
#[serde(rename(deserialize="y"))] // ERROR: duplicate serde attribute `rename`
|
||||
d: (),
|
||||
|
||||
#[serde(rename(serialize="x", serialize="y"))] // ERROR: duplicate serde attribute `rename`
|
||||
e: (),
|
||||
|
||||
#[serde(rename="x", serialize="y")] // ERROR: unknown serde field attribute `serialize`
|
||||
f: (),
|
||||
|
||||
#[serde(rename(serialize="x"), rename(serialize="y"))] // ERROR: duplicate serde attribute `rename`
|
||||
g: (),
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -1,30 +0,0 @@
|
||||
#![feature(custom_attribute, custom_derive, plugin)]
|
||||
#![plugin(serde_macros)]
|
||||
|
||||
extern crate serde;
|
||||
|
||||
#[derive(Serialize)] //~ unknown serde container attribute `abc`
|
||||
#[serde(abc="xyz")]
|
||||
struct A {
|
||||
x: u32,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)] //~ unknown serde container attribute `abc`
|
||||
#[serde(abc="xyz")]
|
||||
struct B {
|
||||
x: u32,
|
||||
}
|
||||
|
||||
#[derive(Serialize)] //~ unknown serde field attribute `abc`
|
||||
struct C {
|
||||
#[serde(abc="xyz")]
|
||||
x: u32,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)] //~ unknown serde field attribute `abc`
|
||||
struct D {
|
||||
#[serde(abc="xyz")]
|
||||
x: u32,
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
@@ -1,9 +0,0 @@
|
||||
#![feature(custom_attribute, custom_derive, plugin)]
|
||||
#![plugin(serde_macros)]
|
||||
|
||||
#[derive(Serialize, Deserialize)] //~ ERROR: Serde does not support deserializing fields of type &str
|
||||
struct Test<'a> {
|
||||
s: &'a str,
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -1,8 +0,0 @@
|
||||
#![feature(test, custom_attribute, custom_derive, plugin)]
|
||||
#![plugin(serde_macros)]
|
||||
|
||||
extern crate test;
|
||||
|
||||
include!("../../testing/tests/test.rs.in");
|
||||
|
||||
mod compile_tests;
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "serde_test"
|
||||
version = "0.8.10"
|
||||
version = "0.8.12"
|
||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
|
||||
license = "MIT/Apache-2.0"
|
||||
description = "Token De/Serializer for testing De/Serialize implementations"
|
||||
@@ -12,4 +12,4 @@ keywords = ["serde", "serialization"]
|
||||
include = ["Cargo.toml", "src/**/*.rs"]
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "0.8.10", path = "../serde" }
|
||||
serde = { version = "0.8.12", path = "../serde" }
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "serde_testing"
|
||||
version = "0.8.10"
|
||||
version = "0.8.12"
|
||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
|
||||
license = "MIT/Apache-2.0"
|
||||
description = "A generic serialization/deserialization framework"
|
||||
|
||||
Reference in New Issue
Block a user