Skip to content

Commit bb5a1fa

Browse files
authored
Change generated functions signatures to remove type parameters (#1045)
* Change generated functions signatures to remove type parameters; fixes #1042 * Add test to confirm no type shadowing * Change generated functions signatures to remove type parameters (rest of ::prost::Message trait) * Change functions signatures to avoid generic type parameters
1 parent 85c698a commit bb5a1fa

File tree

9 files changed

+142
-283
lines changed

9 files changed

+142
-283
lines changed

prost-derive/src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,19 +174,19 @@ fn try_message(input: TokenStream) -> Result<TokenStream, Error> {
174174
let expanded = quote! {
175175
impl #impl_generics ::prost::Message for #ident #ty_generics #where_clause {
176176
#[allow(unused_variables)]
177-
fn encode_raw<B>(&self, buf: &mut B) where B: ::prost::bytes::BufMut {
177+
fn encode_raw(&self, buf: &mut impl ::prost::bytes::BufMut) {
178178
#(#encode)*
179179
}
180180

181181
#[allow(unused_variables)]
182-
fn merge_field<B>(
182+
fn merge_field(
183183
&mut self,
184184
tag: u32,
185185
wire_type: ::prost::encoding::WireType,
186-
buf: &mut B,
186+
buf: &mut impl ::prost::bytes::Buf,
187187
ctx: ::prost::encoding::DecodeContext,
188188
) -> ::core::result::Result<(), ::prost::DecodeError>
189-
where B: ::prost::bytes::Buf {
189+
{
190190
#struct_name
191191
match tag {
192192
#(#merge)*
@@ -463,21 +463,21 @@ fn try_oneof(input: TokenStream) -> Result<TokenStream, Error> {
463463
let expanded = quote! {
464464
impl #impl_generics #ident #ty_generics #where_clause {
465465
/// Encodes the message to a buffer.
466-
pub fn encode<B>(&self, buf: &mut B) where B: ::prost::bytes::BufMut {
466+
pub fn encode(&self, buf: &mut impl ::prost::bytes::BufMut) {
467467
match *self {
468468
#(#encode,)*
469469
}
470470
}
471471

472472
/// Decodes an instance of the message from a buffer, and merges it into self.
473-
pub fn merge<B>(
473+
pub fn merge(
474474
field: &mut ::core::option::Option<#ident #ty_generics>,
475475
tag: u32,
476476
wire_type: ::prost::encoding::WireType,
477-
buf: &mut B,
477+
buf: &mut impl ::prost::bytes::Buf,
478478
ctx: ::prost::encoding::DecodeContext,
479479
) -> ::core::result::Result<(), ::prost::DecodeError>
480-
where B: ::prost::bytes::Buf {
480+
{
481481
match tag {
482482
#(#merge,)*
483483
_ => unreachable!(concat!("invalid ", stringify!(#ident), " tag: {}"), tag),

0 commit comments

Comments
 (0)