Auto merge of #509 - serde-rs:cow, r=oli-obk
Fix codegen with lifetimes but no type parameters Fixes #507.
This commit is contained in:
commit
7aba920dec
@ -192,7 +192,7 @@ fn deserialize_visitor(
|
||||
builder: &aster::AstBuilder,
|
||||
generics: &ast::Generics,
|
||||
) -> (P<ast::Item>, P<ast::Ty>, P<ast::Expr>) {
|
||||
if generics.ty_params.is_empty() {
|
||||
if generics.lifetimes.is_empty() && generics.ty_params.is_empty() {
|
||||
(
|
||||
builder.item().unit_struct("__Visitor"),
|
||||
builder.ty().id("__Visitor"),
|
||||
|
@ -6,6 +6,7 @@ extern crate serde;
|
||||
use self::serde::ser::{Serialize, Serializer};
|
||||
use self::serde::de::{Deserialize, Deserializer};
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -177,6 +178,15 @@ fn test_gen() {
|
||||
e: E,
|
||||
}
|
||||
assert::<WithTraits2<X, X>>();
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct CowStr<'a>(Cow<'a, str>);
|
||||
assert::<CowStr>();
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[serde(bound(deserialize = "T::Owned: Deserialize"))]
|
||||
struct CowT<'a, T: ?Sized + 'a + ToOwned>(Cow<'a, T>);
|
||||
assert::<CowT<str>>();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
Reference in New Issue
Block a user