From 2212bfbf2ca2850a120f6eb5242d34aad261fc01 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 7 Sep 2016 16:25:22 -0700 Subject: [PATCH] Result needs to be fully qualified Without this: ``` error[E0244]: wrong number of type arguments --> src/api/accounts.rs:19:10 | 19 | #[derive(Serialize, Deserialize, Debug)] | ^^^^^^^^^^ expected 1 type arguments, found 2 ``` --- serde_codegen/src/ser.rs | 2 +- testing/tests/test_gen.rs | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/serde_codegen/src/ser.rs b/serde_codegen/src/ser.rs index 8fdc35764..d4883e8ec 100644 --- a/serde_codegen/src/ser.rs +++ b/serde_codegen/src/ser.rs @@ -636,7 +636,7 @@ fn wrap_serialize_with( } impl $wrapper_generics _serde::ser::Serialize for $wrapper_ty $where_clause { - fn serialize<__S>(&self, __s: &mut __S) -> Result<(), __S::Error> + fn serialize<__S>(&self, __s: &mut __S) -> ::std::result::Result<(), __S::Error> where __S: _serde::ser::Serializer { $path(self.value, __s) diff --git a/testing/tests/test_gen.rs b/testing/tests/test_gen.rs index 3e2fe3823..c52ebcad2 100644 --- a/testing/tests/test_gen.rs +++ b/testing/tests/test_gen.rs @@ -9,6 +9,11 @@ use self::serde::de::{Deserialize, Deserializer}; use std::borrow::Cow; use std::marker::PhantomData; +// Try to trip up the generated code if it fails to use fully qualified paths. +#[allow(dead_code)] +struct Result; +use std::result::Result as StdResult; + ////////////////////////////////////////////////////////////////////////// #[test] @@ -205,32 +210,32 @@ fn assert() {} fn assert_ser() {} trait SerializeWith { - fn serialize_with(_: &Self, _: &mut S) -> Result<(), S::Error>; + fn serialize_with(_: &Self, _: &mut S) -> StdResult<(), S::Error>; } trait DeserializeWith: Sized { - fn deserialize_with(_: &mut D) -> Result; + fn deserialize_with(_: &mut D) -> StdResult; } // Implements neither Serialize nor Deserialize struct X; -fn ser_x(_: &X, _: &mut S) -> Result<(), S::Error> { +fn ser_x(_: &X, _: &mut S) -> StdResult<(), S::Error> { unimplemented!() } -fn de_x(_: &mut D) -> Result { +fn de_x(_: &mut D) -> StdResult { unimplemented!() } impl SerializeWith for X { - fn serialize_with(_: &Self, _: &mut S) -> Result<(), S::Error> { + fn serialize_with(_: &Self, _: &mut S) -> StdResult<(), S::Error> { unimplemented!() } } impl DeserializeWith for X { - fn deserialize_with(_: &mut D) -> Result { + fn deserialize_with(_: &mut D) -> StdResult { unimplemented!() } }