From 25a5dd1579500c69beab56d5ca3ced163ee52324 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 21 Jul 2016 23:22:38 -0700 Subject: [PATCH] Impl Deserialize for PhantomData for all T --- serde/src/de/impls.rs | 4 ++-- testing/tests/test_gen.rs | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/serde/src/de/impls.rs b/serde/src/de/impls.rs index 1920b3ebe..e2319d17d 100644 --- a/serde/src/de/impls.rs +++ b/serde/src/de/impls.rs @@ -356,7 +356,7 @@ pub struct PhantomDataVisitor { marker: PhantomData, } -impl Visitor for PhantomDataVisitor where T: Deserialize { +impl Visitor for PhantomDataVisitor { type Value = PhantomData; #[inline] @@ -367,7 +367,7 @@ impl Visitor for PhantomDataVisitor where T: Deserialize { } } -impl Deserialize for PhantomData where T: Deserialize { +impl Deserialize for PhantomData { fn deserialize(deserializer: &mut D) -> Result, D::Error> where D: Deserializer, { diff --git a/testing/tests/test_gen.rs b/testing/tests/test_gen.rs index fcc4b7e42..80b85f566 100644 --- a/testing/tests/test_gen.rs +++ b/testing/tests/test_gen.rs @@ -6,6 +6,8 @@ extern crate serde; use self::serde::ser::{Serialize, Serializer}; use self::serde::de::{Deserialize, Deserializer}; +use std::marker::PhantomData; + ////////////////////////////////////////////////////////////////////////// #[derive(Serialize, Deserialize)] @@ -23,6 +25,11 @@ struct WithRef<'a, T: 'a> { x: X, } +#[derive(Serialize, Deserialize)] +struct PhantomX { + x: PhantomData, +} + #[derive(Serialize, Deserialize)] struct Bounds { t: T,