diff --git a/prost-build/src/code_generator/enums.rs b/prost-build/src/code_generator/enums.rs index b86d86da3..0f6128c39 100644 --- a/prost-build/src/code_generator/enums.rs +++ b/prost-build/src/code_generator/enums.rs @@ -42,20 +42,18 @@ impl CodeGenerator<'_> { let enum_variants = resolve_enum_variants(self, &variant_mappings, &fq_proto_enum_name); let enum_name_syn = enum_name.parse_syn::(); let arms_1 = variant_mappings.iter().map(|variant| { - syn::parse_str::(&format!( + format!( "{}::{} => \"{}\"", enum_name_syn, variant.generated_variant_name, variant.proto_name - )) - .expect("unable to parse enum arm") - .to_token_stream() + ) + .parse_syn::() }); let arms_2 = variant_mappings.iter().map(|variant| { - syn::parse_str::(&format!( + format!( "\"{}\" => Some(Self::{})", variant.proto_name, variant.generated_variant_name - )) - .expect("unable to parse enum arm") - .to_token_stream() + ) + .parse_syn::() }); return Some(quote! { diff --git a/prost-build/src/code_generator/mod.rs b/prost-build/src/code_generator/mod.rs index b04a3a9f6..3543f3aca 100644 --- a/prost-build/src/code_generator/mod.rs +++ b/prost-build/src/code_generator/mod.rs @@ -12,7 +12,7 @@ use prost_types::{ DescriptorProto, EnumDescriptorProto, FieldDescriptorProto, FieldOptions, FileDescriptorProto, OneofDescriptorProto, ServiceDescriptorProto, SourceCodeInfo, }; -use quote::{quote, ToTokens}; +use quote::quote; use syn::{Attribute, TypePath}; use crate::ast::{Comments, Method, Service};