diff --git a/borsh-derive-internal/src/struct_de.rs b/borsh-derive-internal/src/struct_de.rs index 545ac3ae4..d26192d2f 100644 --- a/borsh-derive-internal/src/struct_de.rs +++ b/borsh-derive-internal/src/struct_de.rs @@ -64,7 +64,7 @@ pub fn struct_de(input: &ItemStruct, cratename: Ident) -> syn::Result core::result::Result { + fn deserialize(buf: &mut &[u8]) -> ::core::result::Result { let mut return_value = #return_value; return_value.#method_ident(); Ok(return_value) @@ -74,7 +74,7 @@ pub fn struct_de(input: &ItemStruct, cratename: Ident) -> syn::Result core::result::Result { + fn deserialize(buf: &mut &[u8]) -> ::core::result::Result { Ok(#return_value) } } diff --git a/borsh-derive-internal/src/struct_ser.rs b/borsh-derive-internal/src/struct_ser.rs index 2e118b878..ea3ab955b 100644 --- a/borsh-derive-internal/src/struct_ser.rs +++ b/borsh-derive-internal/src/struct_ser.rs @@ -54,7 +54,7 @@ pub fn struct_ser(input: &ItemStruct, cratename: Ident) -> syn::Result(&self, writer: &mut W) -> core::result::Result<(), #cratename::maybestd::io::Error> { + fn serialize(&self, writer: &mut W) -> ::core::result::Result<(), #cratename::maybestd::io::Error> { #body Ok(()) } @@ -88,7 +88,7 @@ mod tests { u64: borsh::ser::BorshSerialize, String: borsh::ser::BorshSerialize { - fn serialize(&self, writer: &mut W) -> core::result::Result<(), borsh::maybestd::io::Error> { + fn serialize(&self, writer: &mut W) -> ::core::result::Result<(), borsh::maybestd::io::Error> { borsh::BorshSerialize::serialize(&self.x, writer)?; borsh::BorshSerialize::serialize(&self.y, writer)?; Ok(()) @@ -114,7 +114,7 @@ mod tests { HashMap: borsh::ser::BorshSerialize, String: borsh::ser::BorshSerialize { - fn serialize(&self, writer: &mut W) -> core::result::Result<(), borsh::maybestd::io::Error> { + fn serialize(&self, writer: &mut W) -> ::core::result::Result<(), borsh::maybestd::io::Error> { borsh::BorshSerialize::serialize(&self.x, writer)?; borsh::BorshSerialize::serialize(&self.y, writer)?; Ok(()) @@ -141,7 +141,7 @@ mod tests { HashMap: borsh::ser::BorshSerialize, String: borsh::ser::BorshSerialize { - fn serialize(&self, writer: &mut W) -> core::result::Result<(), borsh::maybestd::io::Error> { + fn serialize(&self, writer: &mut W) -> ::core::result::Result<(), borsh::maybestd::io::Error> { borsh::BorshSerialize::serialize(&self.x, writer)?; borsh::BorshSerialize::serialize(&self.y, writer)?; Ok(()) diff --git a/borsh/tests/test_macro_namespace_collisions.rs b/borsh/tests/test_macro_namespace_collisions.rs new file mode 100644 index 000000000..a035350cf --- /dev/null +++ b/borsh/tests/test_macro_namespace_collisions.rs @@ -0,0 +1,7 @@ +// Borsh macros should not collide with the local modules: +// https://github.com/near/borsh-rs/issues/11 +mod std {} +mod core {} + +#[derive(borsh::BorshSerialize, borsh::BorshDeserialize)] +struct A;