Skip to content

Commit

Permalink
explicitly use core::default::Default to avoid collisions (#534)
Browse files Browse the repository at this point in the history
Co-authored-by: Lucio Franco <luciofranco14@gmail.com>
  • Loading branch information
cab and LucioFranco authored Sep 16, 2021
1 parent d45a37c commit 859f243
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion prost-derive/src/field/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl Field {
::prost::encoding::group::merge(
tag,
wire_type,
#ident.get_or_insert_with(Default::default),
#ident.get_or_insert_with(::core::default::Default::default),
buf,
ctx,
)
Expand Down
2 changes: 1 addition & 1 deletion prost-derive/src/field/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl Field {
match self.label {
Label::Optional => quote! {
::prost::encoding::message::merge(wire_type,
#ident.get_or_insert_with(Default::default),
#ident.get_or_insert_with(::core::default::Default::default),
buf,
ctx)
},
Expand Down
6 changes: 4 additions & 2 deletions prost-derive/src/field/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ impl Field {
},
Kind::Optional(..) => quote! {
#merge_fn(wire_type,
#ident.get_or_insert_with(Default::default),
#ident.get_or_insert_with(::core::default::Default::default),
buf,
ctx)
},
Expand Down Expand Up @@ -769,7 +769,9 @@ impl DefaultValue {
quote!(::prost::alloc::string::String::new())
}
DefaultValue::String(ref value) => quote!(#value.into()),
DefaultValue::Bytes(ref value) if value.is_empty() => quote!(Default::default()),
DefaultValue::Bytes(ref value) if value.is_empty() => {
quote!(::core::default::Default::default())
}
DefaultValue::Bytes(ref value) => {
let lit = LitByteStr::new(value, Span::call_site());
quote!(#lit.as_ref().into())
Expand Down
2 changes: 1 addition & 1 deletion prost-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ fn try_message(input: TokenStream) -> Result<TokenStream, Error> {
}
}

impl #impl_generics Default for #ident #ty_generics #where_clause {
impl #impl_generics ::core::default::Default for #ident #ty_generics #where_clause {
fn default() -> Self {
#ident {
#(#default)*
Expand Down

0 comments on commit 859f243

Please sign in to comment.