Skip to content

Commit f085c6c

Browse files
committed
build: fix clippy::use_self
1 parent 61745de commit f085c6c

File tree

5 files changed

+68
-69
lines changed

5 files changed

+68
-69
lines changed

prost-build/src/code_generator.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -803,8 +803,7 @@ impl<'a> CodeGenerator<'a> {
803803

804804
for variant in variant_mappings.iter() {
805805
self.push_indent();
806-
self.buf.push_str(&enum_name);
807-
self.buf.push_str("::");
806+
self.buf.push_str("Self::");
808807
self.buf.push_str(&variant.generated_variant_name);
809808
self.buf.push_str(" => \"");
810809
self.buf.push_str(variant.proto_name);

prost-build/src/fixtures/helloworld/_expected_helloworld.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ impl ServingStatus {
2828
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
2929
pub fn as_str_name(&self) -> &'static str {
3030
match self {
31-
ServingStatus::Unknown => "UNKNOWN",
32-
ServingStatus::Serving => "SERVING",
33-
ServingStatus::NotServing => "NOT_SERVING",
31+
Self::Unknown => "UNKNOWN",
32+
Self::Serving => "SERVING",
33+
Self::NotServing => "NOT_SERVING",
3434
}
3535
}
3636
/// Creates an enum from field names used in the ProtoBuf definition.

prost-build/src/fixtures/helloworld/_expected_helloworld_formatted.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ impl ServingStatus {
2828
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
2929
pub fn as_str_name(&self) -> &'static str {
3030
match self {
31-
ServingStatus::Unknown => "UNKNOWN",
32-
ServingStatus::Serving => "SERVING",
33-
ServingStatus::NotServing => "NOT_SERVING",
31+
Self::Unknown => "UNKNOWN",
32+
Self::Serving => "SERVING",
33+
Self::NotServing => "NOT_SERVING",
3434
}
3535
}
3636
/// Creates an enum from field names used in the ProtoBuf definition.

prost-types/src/compiler.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ pub mod code_generator_response {
154154
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
155155
pub fn as_str_name(&self) -> &'static str {
156156
match self {
157-
Feature::None => "FEATURE_NONE",
158-
Feature::Proto3Optional => "FEATURE_PROTO3_OPTIONAL",
157+
Self::None => "FEATURE_NONE",
158+
Self::Proto3Optional => "FEATURE_PROTO3_OPTIONAL",
159159
}
160160
}
161161
/// Creates an enum from field names used in the ProtoBuf definition.

prost-types/src/protobuf.rs

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -227,24 +227,24 @@ pub mod field_descriptor_proto {
227227
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
228228
pub fn as_str_name(&self) -> &'static str {
229229
match self {
230-
Type::Double => "TYPE_DOUBLE",
231-
Type::Float => "TYPE_FLOAT",
232-
Type::Int64 => "TYPE_INT64",
233-
Type::Uint64 => "TYPE_UINT64",
234-
Type::Int32 => "TYPE_INT32",
235-
Type::Fixed64 => "TYPE_FIXED64",
236-
Type::Fixed32 => "TYPE_FIXED32",
237-
Type::Bool => "TYPE_BOOL",
238-
Type::String => "TYPE_STRING",
239-
Type::Group => "TYPE_GROUP",
240-
Type::Message => "TYPE_MESSAGE",
241-
Type::Bytes => "TYPE_BYTES",
242-
Type::Uint32 => "TYPE_UINT32",
243-
Type::Enum => "TYPE_ENUM",
244-
Type::Sfixed32 => "TYPE_SFIXED32",
245-
Type::Sfixed64 => "TYPE_SFIXED64",
246-
Type::Sint32 => "TYPE_SINT32",
247-
Type::Sint64 => "TYPE_SINT64",
230+
Self::Double => "TYPE_DOUBLE",
231+
Self::Float => "TYPE_FLOAT",
232+
Self::Int64 => "TYPE_INT64",
233+
Self::Uint64 => "TYPE_UINT64",
234+
Self::Int32 => "TYPE_INT32",
235+
Self::Fixed64 => "TYPE_FIXED64",
236+
Self::Fixed32 => "TYPE_FIXED32",
237+
Self::Bool => "TYPE_BOOL",
238+
Self::String => "TYPE_STRING",
239+
Self::Group => "TYPE_GROUP",
240+
Self::Message => "TYPE_MESSAGE",
241+
Self::Bytes => "TYPE_BYTES",
242+
Self::Uint32 => "TYPE_UINT32",
243+
Self::Enum => "TYPE_ENUM",
244+
Self::Sfixed32 => "TYPE_SFIXED32",
245+
Self::Sfixed64 => "TYPE_SFIXED64",
246+
Self::Sint32 => "TYPE_SINT32",
247+
Self::Sint64 => "TYPE_SINT64",
248248
}
249249
}
250250
/// Creates an enum from field names used in the ProtoBuf definition.
@@ -297,9 +297,9 @@ pub mod field_descriptor_proto {
297297
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
298298
pub fn as_str_name(&self) -> &'static str {
299299
match self {
300-
Label::Optional => "LABEL_OPTIONAL",
301-
Label::Required => "LABEL_REQUIRED",
302-
Label::Repeated => "LABEL_REPEATED",
300+
Self::Optional => "LABEL_OPTIONAL",
301+
Self::Required => "LABEL_REQUIRED",
302+
Self::Repeated => "LABEL_REPEATED",
303303
}
304304
}
305305
/// Creates an enum from field names used in the ProtoBuf definition.
@@ -576,9 +576,9 @@ pub mod file_options {
576576
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
577577
pub fn as_str_name(&self) -> &'static str {
578578
match self {
579-
OptimizeMode::Speed => "SPEED",
580-
OptimizeMode::CodeSize => "CODE_SIZE",
581-
OptimizeMode::LiteRuntime => "LITE_RUNTIME",
579+
Self::Speed => "SPEED",
580+
Self::CodeSize => "CODE_SIZE",
581+
Self::LiteRuntime => "LITE_RUNTIME",
582582
}
583583
}
584584
/// Creates an enum from field names used in the ProtoBuf definition.
@@ -759,9 +759,9 @@ pub mod field_options {
759759
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
760760
pub fn as_str_name(&self) -> &'static str {
761761
match self {
762-
CType::String => "STRING",
763-
CType::Cord => "CORD",
764-
CType::StringPiece => "STRING_PIECE",
762+
Self::String => "STRING",
763+
Self::Cord => "CORD",
764+
Self::StringPiece => "STRING_PIECE",
765765
}
766766
}
767767
/// Creates an enum from field names used in the ProtoBuf definition.
@@ -801,9 +801,9 @@ pub mod field_options {
801801
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
802802
pub fn as_str_name(&self) -> &'static str {
803803
match self {
804-
JsType::JsNormal => "JS_NORMAL",
805-
JsType::JsString => "JS_STRING",
806-
JsType::JsNumber => "JS_NUMBER",
804+
Self::JsNormal => "JS_NORMAL",
805+
Self::JsString => "JS_STRING",
806+
Self::JsNumber => "JS_NUMBER",
807807
}
808808
}
809809
/// Creates an enum from field names used in the ProtoBuf definition.
@@ -913,9 +913,9 @@ pub mod method_options {
913913
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
914914
pub fn as_str_name(&self) -> &'static str {
915915
match self {
916-
IdempotencyLevel::IdempotencyUnknown => "IDEMPOTENCY_UNKNOWN",
917-
IdempotencyLevel::NoSideEffects => "NO_SIDE_EFFECTS",
918-
IdempotencyLevel::Idempotent => "IDEMPOTENT",
916+
Self::IdempotencyUnknown => "IDEMPOTENCY_UNKNOWN",
917+
Self::NoSideEffects => "NO_SIDE_EFFECTS",
918+
Self::Idempotent => "IDEMPOTENT",
919919
}
920920
}
921921
/// Creates an enum from field names used in the ProtoBuf definition.
@@ -1402,25 +1402,25 @@ pub mod field {
14021402
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
14031403
pub fn as_str_name(&self) -> &'static str {
14041404
match self {
1405-
Kind::TypeUnknown => "TYPE_UNKNOWN",
1406-
Kind::TypeDouble => "TYPE_DOUBLE",
1407-
Kind::TypeFloat => "TYPE_FLOAT",
1408-
Kind::TypeInt64 => "TYPE_INT64",
1409-
Kind::TypeUint64 => "TYPE_UINT64",
1410-
Kind::TypeInt32 => "TYPE_INT32",
1411-
Kind::TypeFixed64 => "TYPE_FIXED64",
1412-
Kind::TypeFixed32 => "TYPE_FIXED32",
1413-
Kind::TypeBool => "TYPE_BOOL",
1414-
Kind::TypeString => "TYPE_STRING",
1415-
Kind::TypeGroup => "TYPE_GROUP",
1416-
Kind::TypeMessage => "TYPE_MESSAGE",
1417-
Kind::TypeBytes => "TYPE_BYTES",
1418-
Kind::TypeUint32 => "TYPE_UINT32",
1419-
Kind::TypeEnum => "TYPE_ENUM",
1420-
Kind::TypeSfixed32 => "TYPE_SFIXED32",
1421-
Kind::TypeSfixed64 => "TYPE_SFIXED64",
1422-
Kind::TypeSint32 => "TYPE_SINT32",
1423-
Kind::TypeSint64 => "TYPE_SINT64",
1405+
Self::TypeUnknown => "TYPE_UNKNOWN",
1406+
Self::TypeDouble => "TYPE_DOUBLE",
1407+
Self::TypeFloat => "TYPE_FLOAT",
1408+
Self::TypeInt64 => "TYPE_INT64",
1409+
Self::TypeUint64 => "TYPE_UINT64",
1410+
Self::TypeInt32 => "TYPE_INT32",
1411+
Self::TypeFixed64 => "TYPE_FIXED64",
1412+
Self::TypeFixed32 => "TYPE_FIXED32",
1413+
Self::TypeBool => "TYPE_BOOL",
1414+
Self::TypeString => "TYPE_STRING",
1415+
Self::TypeGroup => "TYPE_GROUP",
1416+
Self::TypeMessage => "TYPE_MESSAGE",
1417+
Self::TypeBytes => "TYPE_BYTES",
1418+
Self::TypeUint32 => "TYPE_UINT32",
1419+
Self::TypeEnum => "TYPE_ENUM",
1420+
Self::TypeSfixed32 => "TYPE_SFIXED32",
1421+
Self::TypeSfixed64 => "TYPE_SFIXED64",
1422+
Self::TypeSint32 => "TYPE_SINT32",
1423+
Self::TypeSint64 => "TYPE_SINT64",
14241424
}
14251425
}
14261426
/// Creates an enum from field names used in the ProtoBuf definition.
@@ -1479,10 +1479,10 @@ pub mod field {
14791479
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
14801480
pub fn as_str_name(&self) -> &'static str {
14811481
match self {
1482-
Cardinality::Unknown => "CARDINALITY_UNKNOWN",
1483-
Cardinality::Optional => "CARDINALITY_OPTIONAL",
1484-
Cardinality::Required => "CARDINALITY_REQUIRED",
1485-
Cardinality::Repeated => "CARDINALITY_REPEATED",
1482+
Self::Unknown => "CARDINALITY_UNKNOWN",
1483+
Self::Optional => "CARDINALITY_OPTIONAL",
1484+
Self::Required => "CARDINALITY_REQUIRED",
1485+
Self::Repeated => "CARDINALITY_REPEATED",
14861486
}
14871487
}
14881488
/// Creates an enum from field names used in the ProtoBuf definition.
@@ -1562,8 +1562,8 @@ impl Syntax {
15621562
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
15631563
pub fn as_str_name(&self) -> &'static str {
15641564
match self {
1565-
Syntax::Proto2 => "SYNTAX_PROTO2",
1566-
Syntax::Proto3 => "SYNTAX_PROTO3",
1565+
Self::Proto2 => "SYNTAX_PROTO2",
1566+
Self::Proto3 => "SYNTAX_PROTO3",
15671567
}
15681568
}
15691569
/// Creates an enum from field names used in the ProtoBuf definition.
@@ -2139,7 +2139,7 @@ impl NullValue {
21392139
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
21402140
pub fn as_str_name(&self) -> &'static str {
21412141
match self {
2142-
NullValue::NullValue => "NULL_VALUE",
2142+
Self::NullValue => "NULL_VALUE",
21432143
}
21442144
}
21452145
/// Creates an enum from field names used in the ProtoBuf definition.

0 commit comments

Comments
 (0)