From 3298817f16ac6f686d85c5533b19d379f90d9975 Mon Sep 17 00:00:00 2001 From: Millione Date: Wed, 7 Jun 2023 13:22:28 +0800 Subject: [PATCH] fix: missing `_` in pb encode --- Cargo.lock | 2 +- pilota-build/Cargo.toml | 2 +- pilota-build/src/codegen/protobuf/mod.rs | 2 +- pilota-build/test_data/protobuf/oneof.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f855597e..c5fc85e6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -737,7 +737,7 @@ dependencies = [ [[package]] name = "pilota-build" -version = "0.7.4" +version = "0.7.5" dependencies = [ "anyhow", "async-trait", diff --git a/pilota-build/Cargo.toml b/pilota-build/Cargo.toml index d92405df..91baf9fa 100644 --- a/pilota-build/Cargo.toml +++ b/pilota-build/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pilota-build" -version = "0.7.4" +version = "0.7.5" edition = "2021" description = "Compile thrift and protobuf idl into rust code at compile-time." documentation = "https://docs.rs/pilota-build" diff --git a/pilota-build/src/codegen/protobuf/mod.rs b/pilota-build/src/codegen/protobuf/mod.rs index 44db6536..c3fba6e7 100644 --- a/pilota-build/src/codegen/protobuf/mod.rs +++ b/pilota-build/src/codegen/protobuf/mod.rs @@ -230,7 +230,7 @@ impl ProtobufBackend { .into() } else { let encode: FastStr = if self.is_one_of(ty) { - "pilota_inner_value.encode(buf);".into() + "_pilota_inner_value.encode(buf);".into() } else { let ident: FastStr = match kind { FieldKind::Required => format!("(&{ident})").into(), diff --git a/pilota-build/test_data/protobuf/oneof.rs b/pilota-build/test_data/protobuf/oneof.rs index df4832b4..0d66cd8b 100644 --- a/pilota-build/test_data/protobuf/oneof.rs +++ b/pilota-build/test_data/protobuf/oneof.rs @@ -16,7 +16,7 @@ pub mod oneof { B: ::pilota::prost::bytes::BufMut, { if let Some(_pilota_inner_value) = self.r#type.as_ref() { - pilota_inner_value.encode(buf); + _pilota_inner_value.encode(buf); } }