diff --git a/prost-build/src/code_generator/enums.rs b/prost-build/src/code_generator/enums.rs index 0f6128c39..561bc8660 100644 --- a/prost-build/src/code_generator/enums.rs +++ b/prost-build/src/code_generator/enums.rs @@ -105,11 +105,11 @@ impl CodeGenerator<'_> { let field_attributes = code_generator.resolve_field_attributes(fq_proto_enum_name, variant.proto_name); - let variant = syn::parse_str::(&format!( + let variant = format!( "{} = {}", variant.generated_variant_name, variant.proto_number - )) - .expect("unable to parse enum variant"); + ) + .parse_syn::(); variants.push(quote! { #(#documentation)* diff --git a/prost-build/src/code_generator/mod.rs b/prost-build/src/code_generator/mod.rs index 3543f3aca..5903df2e6 100644 --- a/prost-build/src/code_generator/mod.rs +++ b/prost-build/src/code_generator/mod.rs @@ -203,7 +203,6 @@ impl<'a> CodeGenerator<'a> { } fn prost_type_path(&self, item: &str) -> TypePath { - syn::parse_str(&format!("{}::{}", self.resolve_prost_path(), item)) - .expect("unable to parse prost type path") + format!("{}::{}", self.resolve_prost_path(), item).parse_syn() } }