Skip to content

Commit

Permalink
Merge pull request #26 from dtolnay/core
Browse files Browse the repository at this point in the history
Use rooted path to refer to ::core in generated code
  • Loading branch information
dtolnay authored Oct 30, 2023
2 parents f92f946 + 8d87617 commit c958dcd
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub fn derive_serialize(input: TokenStream) -> TokenStream {
TokenStream::from(quote! {
impl serde::Serialize for #ident {
#[allow(clippy::use_self)]
fn serialize<S>(&self, serializer: S) -> core::result::Result<S::Ok, S::Error>
fn serialize<S>(&self, serializer: S) -> ::core::result::Result<S::Ok, S::Error>
where
S: serde::Serializer
{
Expand Down Expand Up @@ -93,7 +93,7 @@ pub fn derive_deserialize(input: TokenStream) -> TokenStream {
let match_discriminants = input.variants.iter().map(|variant| {
let variant = &variant.ident;
quote! {
discriminant::#variant => core::result::Result::Ok(#ident::#variant),
discriminant::#variant => ::core::result::Result::Ok(#ident::#variant),
}
});

Expand All @@ -107,11 +107,11 @@ pub fn derive_deserialize(input: TokenStream) -> TokenStream {
Some(variant) => {
let variant = &variant.ident;
quote! {
core::result::Result::Ok(#ident::#variant)
::core::result::Result::Ok(#ident::#variant)
}
}
None => quote! {
core::result::Result::Err(serde::de::Error::custom(
::core::result::Result::Err(serde::de::Error::custom(
format_args!(#error_format, other #(, discriminant::#variants)*)
))
},
Expand All @@ -120,7 +120,7 @@ pub fn derive_deserialize(input: TokenStream) -> TokenStream {
TokenStream::from(quote! {
impl<'de> serde::Deserialize<'de> for #ident {
#[allow(clippy::use_self)]
fn deserialize<D>(deserializer: D) -> core::result::Result<Self, D::Error>
fn deserialize<D>(deserializer: D) -> ::core::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
Expand Down

0 comments on commit c958dcd

Please sign in to comment.