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 6bef5435e..e2aaf08ea 100644 --- a/prost-build/src/code_generator/mod.rs +++ b/prost-build/src/code_generator/mod.rs @@ -200,7 +200,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() } }