diff --git a/protobuf-codegen/src/enums.rs b/protobuf-codegen/src/enums.rs index 705540189..a6e404aeb 100644 --- a/protobuf-codegen/src/enums.rs +++ b/protobuf-codegen/src/enums.rs @@ -208,8 +208,7 @@ impl<'a> EnumGen<'a> { if !self.lite_runtime { w.write_line(""); - let ref type_name = self.type_name; - w.def_fn(&format!("enum_descriptor_static(_: ::std::option::Option<{}>) -> &'static ::protobuf::reflect::EnumDescriptor", type_name), |w| { + w.def_fn(&format!("enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor"), |w| { w.lazy_static_decl_get("descriptor", "::protobuf::reflect::EnumDescriptor", |w| { let ref type_name = self.type_name; w.write_line(&format!("::protobuf::reflect::EnumDescriptor::new(\"{}\", file_descriptor_proto())", type_name)); diff --git a/protobuf/src/descriptor.rs b/protobuf/src/descriptor.rs index ea33e644f..acba5e1e0 100644 --- a/protobuf/src/descriptor.rs +++ b/protobuf/src/descriptor.rs @@ -2574,7 +2574,7 @@ impl ::protobuf::ProtobufEnum for FieldDescriptorProto_Type { values } - fn enum_descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::EnumDescriptor { + fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor { static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy { lock: ::protobuf::lazy::ONCE_INIT, ptr: 0 as *const ::protobuf::reflect::EnumDescriptor, @@ -2626,7 +2626,7 @@ impl ::protobuf::ProtobufEnum for FieldDescriptorProto_Label { values } - fn enum_descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::EnumDescriptor { + fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor { static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy { lock: ::protobuf::lazy::ONCE_INIT, ptr: 0 as *const ::protobuf::reflect::EnumDescriptor, @@ -4924,7 +4924,7 @@ impl ::protobuf::ProtobufEnum for FileOptions_OptimizeMode { values } - fn enum_descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::EnumDescriptor { + fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor { static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy { lock: ::protobuf::lazy::ONCE_INIT, ptr: 0 as *const ::protobuf::reflect::EnumDescriptor, @@ -5698,7 +5698,7 @@ impl ::protobuf::ProtobufEnum for FieldOptions_CType { values } - fn enum_descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::EnumDescriptor { + fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor { static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy { lock: ::protobuf::lazy::ONCE_INIT, ptr: 0 as *const ::protobuf::reflect::EnumDescriptor, @@ -5750,7 +5750,7 @@ impl ::protobuf::ProtobufEnum for FieldOptions_JSType { values } - fn enum_descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::EnumDescriptor { + fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor { static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy { lock: ::protobuf::lazy::ONCE_INIT, ptr: 0 as *const ::protobuf::reflect::EnumDescriptor, diff --git a/protobuf/src/enums.rs b/protobuf/src/enums.rs index 40712d96d..31983a2c9 100644 --- a/protobuf/src/enums.rs +++ b/protobuf/src/enums.rs @@ -23,12 +23,11 @@ pub trait ProtobufEnum: Eq + Sized + Copy + 'static { /// Get enum descriptor. fn enum_descriptor(&self) -> &'static EnumDescriptor { - ProtobufEnum::enum_descriptor_static(None::) + Self::enum_descriptor_static() } /// Get enum descriptor by type. - // http://stackoverflow.com/q/20342436/15018 - fn enum_descriptor_static(_: Option) -> &'static EnumDescriptor { + fn enum_descriptor_static() -> &'static EnumDescriptor { panic!(); } } diff --git a/protobuf/src/reflect/mod.rs b/protobuf/src/reflect/mod.rs index 6cfeccf26..eeccb31ed 100644 --- a/protobuf/src/reflect/mod.rs +++ b/protobuf/src/reflect/mod.rs @@ -257,7 +257,7 @@ impl EnumDescriptor { } pub fn for_type() -> &'static EnumDescriptor { - ProtobufEnum::enum_descriptor_static(None::) + E::enum_descriptor_static() } pub fn new(rust_name: &'static str, file: &'static FileDescriptorProto) -> EnumDescriptor { diff --git a/protobuf/src/well_known_types/struct_pb.rs b/protobuf/src/well_known_types/struct_pb.rs index fc0d6123b..bbb1904cc 100644 --- a/protobuf/src/well_known_types/struct_pb.rs +++ b/protobuf/src/well_known_types/struct_pb.rs @@ -859,7 +859,7 @@ impl ::protobuf::ProtobufEnum for NullValue { values } - fn enum_descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::EnumDescriptor { + fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor { static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy { lock: ::protobuf::lazy::ONCE_INIT, ptr: 0 as *const ::protobuf::reflect::EnumDescriptor, diff --git a/protobuf/src/well_known_types/type_pb.rs b/protobuf/src/well_known_types/type_pb.rs index 0940cd64c..fe2be5f1b 100644 --- a/protobuf/src/well_known_types/type_pb.rs +++ b/protobuf/src/well_known_types/type_pb.rs @@ -994,7 +994,7 @@ impl ::protobuf::ProtobufEnum for Field_Kind { values } - fn enum_descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::EnumDescriptor { + fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor { static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy { lock: ::protobuf::lazy::ONCE_INIT, ptr: 0 as *const ::protobuf::reflect::EnumDescriptor, @@ -1055,7 +1055,7 @@ impl ::protobuf::ProtobufEnum for Field_Cardinality { values } - fn enum_descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::EnumDescriptor { + fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor { static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy { lock: ::protobuf::lazy::ONCE_INIT, ptr: 0 as *const ::protobuf::reflect::EnumDescriptor, @@ -1926,7 +1926,7 @@ impl ::protobuf::ProtobufEnum for Syntax { values } - fn enum_descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::EnumDescriptor { + fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor { static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy { lock: ::protobuf::lazy::ONCE_INIT, ptr: 0 as *const ::protobuf::reflect::EnumDescriptor,