From 07d784306c3ce5b3b428e5b5823a3c5812488d43 Mon Sep 17 00:00:00 2001 From: tottoto Date: Thu, 8 Dec 2022 19:20:12 +0900 Subject: [PATCH 1/2] chore(build): Ignore clippy warning derive_partial_eq_without_eq --- prost-build/src/code_generator.rs | 4 ++++ tests/single-include/src/outdir/outdir.rs | 1 + 2 files changed, 5 insertions(+) diff --git a/prost-build/src/code_generator.rs b/prost-build/src/code_generator.rs index 81a551ee9..f4d8df9a5 100644 --- a/prost-build/src/code_generator.rs +++ b/prost-build/src/code_generator.rs @@ -183,6 +183,8 @@ impl<'a> CodeGenerator<'a> { self.append_doc(&fq_message_name, None); self.append_type_attributes(&fq_message_name); self.push_indent(); + self.buf + .push_str("#[allow(clippy::derive_partial_eq_without_eq)]\n"); self.buf.push_str(&format!( "#[derive(Clone, PartialEq, {}::Message)]\n", self.config.prost_path.as_deref().unwrap_or("::prost") @@ -505,6 +507,8 @@ impl<'a> CodeGenerator<'a> { let oneof_name = format!("{}.{}", fq_message_name, oneof.name()); self.append_type_attributes(&oneof_name); self.push_indent(); + self.buf + .push_str("#[allow(clippy::derive_partial_eq_without_eq)]\n"); self.buf.push_str(&format!( "#[derive(Clone, PartialEq, {}::Oneof)]\n", self.config.prost_path.as_deref().unwrap_or("::prost") diff --git a/tests/single-include/src/outdir/outdir.rs b/tests/single-include/src/outdir/outdir.rs index c7af08f54..eee461c1b 100644 --- a/tests/single-include/src/outdir/outdir.rs +++ b/tests/single-include/src/outdir/outdir.rs @@ -1,3 +1,4 @@ +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct OutdirRequest { #[prost(string, tag = "1")] From 1fb3857c871a66ef6c2880c06c3059e20e61399e Mon Sep 17 00:00:00 2001 From: tottoto Date: Thu, 8 Dec 2022 22:20:08 +0900 Subject: [PATCH 2/2] chore(types): Update generated code to reflect clippy lint annotation --- prost-types/src/compiler.rs | 4 ++++ prost-types/src/protobuf.rs | 44 +++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/prost-types/src/compiler.rs b/prost-types/src/compiler.rs index fb4f864b9..675ebb036 100644 --- a/prost-types/src/compiler.rs +++ b/prost-types/src/compiler.rs @@ -1,4 +1,5 @@ /// The version number of protocol compiler. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Version { #[prost(int32, optional, tag = "1")] @@ -13,6 +14,7 @@ pub struct Version { pub suffix: ::core::option::Option<::prost::alloc::string::String>, } /// An encoded CodeGeneratorRequest is written to the plugin's stdin. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct CodeGeneratorRequest { /// The .proto files that were explicitly listed on the command-line. The @@ -44,6 +46,7 @@ pub struct CodeGeneratorRequest { pub compiler_version: ::core::option::Option, } /// The plugin writes an encoded CodeGeneratorResponse to stdout. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct CodeGeneratorResponse { /// Error message. If non-empty, code generation failed. The plugin process @@ -66,6 +69,7 @@ pub struct CodeGeneratorResponse { /// Nested message and enum types in `CodeGeneratorResponse`. pub mod code_generator_response { /// Represents a single generated file. + #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct File { /// The file name, relative to the output directory. The name must not diff --git a/prost-types/src/protobuf.rs b/prost-types/src/protobuf.rs index 65d0975ad..6bd39520c 100644 --- a/prost-types/src/protobuf.rs +++ b/prost-types/src/protobuf.rs @@ -1,11 +1,13 @@ /// The protocol compiler can output a FileDescriptorSet containing the .proto /// files it parses. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct FileDescriptorSet { #[prost(message, repeated, tag = "1")] pub file: ::prost::alloc::vec::Vec, } /// Describes a complete .proto file. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct FileDescriptorProto { /// file name, relative to root of source tree @@ -47,6 +49,7 @@ pub struct FileDescriptorProto { pub syntax: ::core::option::Option<::prost::alloc::string::String>, } /// Describes a message type. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct DescriptorProto { #[prost(string, optional, tag = "1")] @@ -74,6 +77,7 @@ pub struct DescriptorProto { } /// Nested message and enum types in `DescriptorProto`. pub mod descriptor_proto { + #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ExtensionRange { /// Inclusive. @@ -88,6 +92,7 @@ pub mod descriptor_proto { /// Range of reserved tag numbers. Reserved tag numbers may not be used by /// fields or extension ranges in the same message. Reserved ranges may /// not overlap. + #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ReservedRange { /// Inclusive. @@ -98,6 +103,7 @@ pub mod descriptor_proto { pub end: ::core::option::Option, } } +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ExtensionRangeOptions { /// The parser stores options it doesn't recognize here. See above. @@ -105,6 +111,7 @@ pub struct ExtensionRangeOptions { pub uninterpreted_option: ::prost::alloc::vec::Vec, } /// Describes a field within a message. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct FieldDescriptorProto { #[prost(string, optional, tag = "1")] @@ -280,6 +287,7 @@ pub mod field_descriptor_proto { } } /// Describes a oneof. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct OneofDescriptorProto { #[prost(string, optional, tag = "1")] @@ -288,6 +296,7 @@ pub struct OneofDescriptorProto { pub options: ::core::option::Option, } /// Describes an enum type. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct EnumDescriptorProto { #[prost(string, optional, tag = "1")] @@ -316,6 +325,7 @@ pub mod enum_descriptor_proto { /// Note that this is distinct from DescriptorProto.ReservedRange in that it /// is inclusive such that it can appropriately represent the entire int32 /// domain. + #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct EnumReservedRange { /// Inclusive. @@ -327,6 +337,7 @@ pub mod enum_descriptor_proto { } } /// Describes a value within an enum. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct EnumValueDescriptorProto { #[prost(string, optional, tag = "1")] @@ -337,6 +348,7 @@ pub struct EnumValueDescriptorProto { pub options: ::core::option::Option, } /// Describes a service. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ServiceDescriptorProto { #[prost(string, optional, tag = "1")] @@ -347,6 +359,7 @@ pub struct ServiceDescriptorProto { pub options: ::core::option::Option, } /// Describes a method of a service. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct MethodDescriptorProto { #[prost(string, optional, tag = "1")] @@ -395,6 +408,7 @@ pub struct MethodDescriptorProto { /// /// If this turns out to be popular, a web service will be set up /// to automatically assign option numbers. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct FileOptions { /// Sets the Java package where classes generated from this .proto will be @@ -549,6 +563,7 @@ pub mod file_options { } } } +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct MessageOptions { /// Set true to use the old proto1 MessageSet wire format for extensions. @@ -609,6 +624,7 @@ pub struct MessageOptions { #[prost(message, repeated, tag = "999")] pub uninterpreted_option: ::prost::alloc::vec::Vec, } +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct FieldOptions { /// The ctype option instructs the C++ code generator to use a different @@ -756,12 +772,14 @@ pub mod field_options { } } } +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct OneofOptions { /// The parser stores options it doesn't recognize here. See above. #[prost(message, repeated, tag = "999")] pub uninterpreted_option: ::prost::alloc::vec::Vec, } +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct EnumOptions { /// Set this option to true to allow mapping different tag names to the same @@ -778,6 +796,7 @@ pub struct EnumOptions { #[prost(message, repeated, tag = "999")] pub uninterpreted_option: ::prost::alloc::vec::Vec, } +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct EnumValueOptions { /// Is this enum value deprecated? @@ -790,6 +809,7 @@ pub struct EnumValueOptions { #[prost(message, repeated, tag = "999")] pub uninterpreted_option: ::prost::alloc::vec::Vec, } +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ServiceOptions { /// Is this service deprecated? @@ -802,6 +822,7 @@ pub struct ServiceOptions { #[prost(message, repeated, tag = "999")] pub uninterpreted_option: ::prost::alloc::vec::Vec, } +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct MethodOptions { /// Is this method deprecated? @@ -865,6 +886,7 @@ pub mod method_options { /// options protos in descriptor objects (e.g. returned by Descriptor::options(), /// or produced by Descriptor::CopyTo()) will never have UninterpretedOptions /// in them. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct UninterpretedOption { #[prost(message, repeated, tag = "2")] @@ -891,6 +913,7 @@ pub mod uninterpreted_option { /// extension (denoted with parentheses in options specs in .proto files). /// E.g.,{ \["foo", false\], \["bar.baz", true\], \["qux", false\] } represents /// "foo.(bar.baz).qux". + #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct NamePart { #[prost(string, required, tag = "1")] @@ -901,6 +924,7 @@ pub mod uninterpreted_option { } /// Encapsulates information about the original source file from which a /// FileDescriptorProto was generated. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct SourceCodeInfo { /// A Location identifies a piece of source code in a .proto file which @@ -952,6 +976,7 @@ pub struct SourceCodeInfo { } /// Nested message and enum types in `SourceCodeInfo`. pub mod source_code_info { + #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Location { /// Identifies which part of the FileDescriptorProto was defined at this @@ -1046,6 +1071,7 @@ pub mod source_code_info { /// Describes the relationship between generated code and its original source /// file. A GeneratedCodeInfo message is associated with only one generated /// source file, but may contain references to different source .proto files. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GeneratedCodeInfo { /// An Annotation connects some span of text in generated code to an element @@ -1055,6 +1081,7 @@ pub struct GeneratedCodeInfo { } /// Nested message and enum types in `GeneratedCodeInfo`. pub mod generated_code_info { + #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Annotation { /// Identifies the element in the original source .proto file. This field @@ -1168,6 +1195,7 @@ pub mod generated_code_info { /// "value": "1.212s" /// } /// ``` +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Any { /// A URL/resource name that uniquely identifies the type of the serialized @@ -1205,6 +1233,7 @@ pub struct Any { } /// `SourceContext` represents information about the source of a /// protobuf element, like the file in which it is defined. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct SourceContext { /// The path-qualified name of the .proto file that contained the associated @@ -1213,6 +1242,7 @@ pub struct SourceContext { pub file_name: ::prost::alloc::string::String, } /// A protocol buffer message type. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Type { /// The fully qualified message name. @@ -1235,6 +1265,7 @@ pub struct Type { pub syntax: i32, } /// A single field of a message type. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Field { /// The field type. @@ -1393,6 +1424,7 @@ pub mod field { } } /// Enum type definition. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Enum { /// Enum type name. @@ -1412,6 +1444,7 @@ pub struct Enum { pub syntax: i32, } /// Enum value definition. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct EnumValue { /// Enum value name. @@ -1426,6 +1459,7 @@ pub struct EnumValue { } /// A protocol buffer option, which can be attached to a message, field, /// enumeration, etc. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Option { /// The option's name. For protobuf built-in options (options defined in @@ -1471,6 +1505,7 @@ impl Syntax { /// sometimes simply referred to as "APIs" in other contexts, such as the name of /// this message itself. See for /// detailed terminology. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Api { /// The fully qualified name of this interface, including package name @@ -1516,6 +1551,7 @@ pub struct Api { pub syntax: i32, } /// Method represents a method of an API interface. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Method { /// The simple name of this method. @@ -1628,6 +1664,7 @@ pub struct Method { /// ... /// } /// ``` +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Mixin { /// The fully qualified name of the interface which is included. @@ -1702,6 +1739,7 @@ pub struct Mixin { /// encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should /// be expressed in JSON format as "3.000000001s", and 3 seconds and 1 /// microsecond should be expressed in JSON format as "3.000001s". +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Duration { /// Signed seconds of the span of time. Must be from -315,576,000,000 @@ -1940,6 +1978,7 @@ pub struct Duration { /// The implementation of any API method which has a FieldMask type field in the /// request should verify the included field paths, and return an /// `INVALID_ARGUMENT` error if any path is unmappable. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct FieldMask { /// The set of field mask paths. @@ -1954,6 +1993,7 @@ pub struct FieldMask { /// with the proto support for the language. /// /// The JSON representation for `Struct` is JSON object. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Struct { /// Unordered map of dynamically typed values. @@ -1969,6 +2009,7 @@ pub struct Struct { /// variants. Absence of any variant indicates an error. /// /// The JSON representation for `Value` is JSON value. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Value { /// The kind of value. @@ -1978,6 +2019,7 @@ pub struct Value { /// Nested message and enum types in `Value`. pub mod value { /// The kind of value. + #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Kind { /// Represents a null value. @@ -2003,6 +2045,7 @@ pub mod value { /// `ListValue` is a wrapper around a repeated field of values. /// /// The JSON representation for `ListValue` is JSON array. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ListValue { /// Repeated field of dynamically typed values. @@ -2129,6 +2172,7 @@ impl NullValue { /// \[`strftime`\]() with /// the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use /// the Joda Time's \[`ISODateTimeFormat.dateTime()`\]() to obtain a formatter capable of generating timestamps in this format. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Timestamp { /// Represents seconds of UTC time since Unix epoch