From 246308142af9bc61dd637de088607df3856c4991 Mon Sep 17 00:00:00 2001 From: Slaveanu Ionut Date: Tue, 13 Aug 2024 09:11:58 +0300 Subject: [PATCH] Update prost to version 0.13 (#651) Signed-off-by: Ionut Slaveanu --- Cargo.toml | 2 +- compiler/Cargo.toml | 6 +-- compiler/src/codegen.rs | 4 +- grpc-sys/bindings/bindings.rs | 10 ---- grpc-sys/build.rs | 1 + health/Cargo.toml | 2 +- health/src/lib.rs | 1 + health/src/proto/prost/grpc.health.v1.rs | 2 +- health/src/proto/protobuf_v3/health.rs | 4 +- interop/tests/tests.rs | 2 - proto/Cargo.toml | 8 ++-- proto/src/lib.rs | 1 + proto/src/proto/prost/example/routeguide.rs | 6 +-- proto/src/proto/prost/testing/grpc.testing.rs | 46 +++++++++---------- .../proto/protobuf_v3/example/helloworld.rs | 4 +- .../proto/protobuf_v3/example/route_guide.rs | 4 +- .../proto/protobuf_v3/google/rpc/status.rs | 4 +- .../src/proto/protobuf_v3/testing/control.rs | 40 +++++----------- proto/src/proto/protobuf_v3/testing/empty.rs | 4 +- .../src/proto/protobuf_v3/testing/messages.rs | 12 ++--- .../src/proto/protobuf_v3/testing/payloads.rs | 4 +- .../src/proto/protobuf_v3/testing/services.rs | 4 +- proto/src/proto/protobuf_v3/testing/stats.rs | 12 ++--- proto/src/proto/protobuf_v3/testing/test.rs | 4 +- src/channel.rs | 2 +- src/codec.rs | 2 +- src/metadata.rs | 2 +- tests-and-examples/Cargo.toml | 2 +- xtask/Cargo.toml | 2 +- 29 files changed, 82 insertions(+), 115 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 307267ac..29b56186 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ futures-executor = "0.3" futures-util = { version = "0.3", default-features = false, features = ["std", "sink"] } protobuf = { version = "2.0", optional = true } protobufv3 = { package = "protobuf", version = "3.2", optional = true } -prost = { version = "0.12", optional = true } +prost = { version = "0.13", optional = true } bytes = { version = "1.0", optional = true } log = "0.4" parking_lot = "0.12" diff --git a/compiler/Cargo.toml b/compiler/Cargo.toml index 73055c9f..ccc7b7db 100644 --- a/compiler/Cargo.toml +++ b/compiler/Cargo.toml @@ -18,9 +18,9 @@ prost-codec = ["prost-build", "prost-types", "prost", "derive-new", "tempfile"] [dependencies] protobuf = { version = "2", optional = true } -prost = { version = "0.12", optional = true } -prost-build = { version = "0.12", optional = true } -prost-types = { version = "0.12", optional = true } +prost = { version = "0.13", optional = true } +prost-build = { version = "0.13", optional = true } +prost-types = { version = "0.13", optional = true } derive-new = { version = "0.6", optional = true } tempfile = { version = "3.0", optional = true } diff --git a/compiler/src/codegen.rs b/compiler/src/codegen.rs index 20cabc30..6d7bcdef 100644 --- a/compiler/src/codegen.rs +++ b/compiler/src/codegen.rs @@ -574,7 +574,7 @@ impl<'a> ServiceGen<'a> { fn write_client(&self, w: &mut CodeWriter) { w.write_line("#[derive(Clone)]"); - w.pub_struct(&self.client_name(), |w| { + w.pub_struct(self.client_name(), |w| { // This can also be exposed by a method. But it may introduce a name conflict // between service definition and method name. Marking it public may put extra // restrict on compatability, but it should not be an issue. @@ -583,7 +583,7 @@ impl<'a> ServiceGen<'a> { w.write_line(""); - w.impl_self_block(&self.client_name(), |w| { + w.impl_self_block(self.client_name(), |w| { w.pub_fn("new(channel: ::grpcio::Channel) -> Self", |w| { w.expr_block(&self.client_name(), |w| { w.field_entry("client", "::grpcio::Client::new(channel)"); diff --git a/grpc-sys/bindings/bindings.rs b/grpc-sys/bindings/bindings.rs index 270d7aa9..dd654632 100644 --- a/grpc-sys/bindings/bindings.rs +++ b/grpc-sys/bindings/bindings.rs @@ -704,16 +704,6 @@ pub struct grpc_server { pub struct grpc_call { _unused: [u8; 0], } -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct grpc_socket_mutator { - _unused: [u8; 0], -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct grpc_socket_factory { - _unused: [u8; 0], -} #[repr(u32)] #[doc = " Type specifier for grpc_arg"] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] diff --git a/grpc-sys/build.rs b/grpc-sys/build.rs index ea780e20..884a1997 100644 --- a/grpc-sys/build.rs +++ b/grpc-sys/build.rs @@ -464,6 +464,7 @@ fn bindgen_grpc(file_path: &Path) { .blocklist_type(r"gpr_mu") .blocklist_type(r"gpr_cv") .blocklist_type(r"gpr_once") + .blocklist_type(r"grpc_socket_.*") .constified_enum_module(r"grpc_status_code") .layout_tests(gen_tests) .default_enum_style(bindgen::EnumVariation::Rust { diff --git a/health/Cargo.toml b/health/Cargo.toml index f26bccfc..8bad58d7 100644 --- a/health/Cargo.toml +++ b/health/Cargo.toml @@ -22,7 +22,7 @@ prost-codec = ["grpcio/prost-codec", "prost"] futures-executor = "0.3" futures-util = { version = "0.3", default-features = false, features = ["std"] } grpcio = { path = "..", version = "0.13.0", default-features = false } -prost = { version = "0.12", optional = true } +prost = { version = "0.13", optional = true } protobuf = { version = "2", optional = true } protobufv3 = { package = "protobuf", version = "3.2", optional = true } log = "0.4" diff --git a/health/src/lib.rs b/health/src/lib.rs index 7f18fd4f..490ce88c 100644 --- a/health/src/lib.rs +++ b/health/src/lib.rs @@ -31,6 +31,7 @@ //! assert_eq!(statuss_resp.status, ServingStatus::Serving); //! ``` +#[allow(renamed_and_removed_lints)] pub mod proto; mod service; diff --git a/health/src/proto/prost/grpc.health.v1.rs b/health/src/proto/prost/grpc.health.v1.rs index 222daa76..7853ef43 100644 --- a/health/src/proto/prost/grpc.health.v1.rs +++ b/health/src/proto/prost/grpc.health.v1.rs @@ -6,7 +6,7 @@ pub struct HealthCheckRequest { pub service: ::prost::alloc::string::String, } #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct HealthCheckResponse { #[prost(enumeration = "health_check_response::ServingStatus", tag = "1")] pub status: i32, diff --git a/health/src/proto/protobuf_v3/health.rs b/health/src/proto/protobuf_v3/health.rs index 8282afdf..dd97cf29 100644 --- a/health/src/proto/protobuf_v3/health.rs +++ b/health/src/proto/protobuf_v3/health.rs @@ -1,4 +1,4 @@ -// This file is generated by rust-protobuf 3.4.0. Do not edit +// This file is generated by rust-protobuf 3.5.0. Do not edit // @generated // https://github.com/rust-lang/rust-clippy/issues/702 @@ -22,7 +22,7 @@ /// Generated files are compatible only with the same version /// of protobuf runtime. -const _PROTOBUF_VERSION_CHECK: () = ::protobufv3::VERSION_3_4_0; +const _PROTOBUF_VERSION_CHECK: () = ::protobufv3::VERSION_3_5_0; // @@protoc_insertion_point(message:grpc.health.v1.HealthCheckRequest) #[derive(PartialEq,Clone,Default,Debug)] diff --git a/interop/tests/tests.rs b/interop/tests/tests.rs index 868df7f5..b1113676 100644 --- a/interop/tests/tests.rs +++ b/interop/tests/tests.rs @@ -53,11 +53,9 @@ macro_rules! mk_test { mk_test!(empty_unary); mk_test!(large_unary); // FIXME(#305) Intermittent test. -#[cfg(not(feature = "openssl"))] mk_test!(client_streaming); mk_test!(server_streaming); // FIXME(#306) Intermittent test. -#[cfg(not(feature = "openssl"))] mk_test!(ping_pong); mk_test!(custom_metadata); mk_test!(empty_stream); diff --git a/proto/Cargo.toml b/proto/Cargo.toml index 57655323..89b6ec4f 100644 --- a/proto/Cargo.toml +++ b/proto/Cargo.toml @@ -20,13 +20,13 @@ prost-codec = ["prost-build", "prost-derive", "prost-types", "bytes", "lazy_stat [dependencies] grpcio = { path = "..", features = ["boringssl"], version = "0.13.0", default-features = false } bytes = { version = "1.0", optional = true } -prost = { version = "0.12", optional = true } -prost-derive = { version = "0.12", optional = true } -prost-types = { version = "0.12", optional = true } +prost = { version = "0.13", optional = true } +prost-derive = { version = "0.13", optional = true } +prost-types = { version = "0.13", optional = true } protobuf = { version = "2", optional = true } protobufv3 = { package = "protobuf", version = "3.2", optional = true } lazy_static = { version = "1.3", optional = true } [build-dependencies] -prost-build = { version = "0.12", optional = true } +prost-build = { version = "0.13", optional = true } walkdir = "2.2" diff --git a/proto/src/lib.rs b/proto/src/lib.rs index a79d04b7..8a58a7ad 100644 --- a/proto/src/lib.rs +++ b/proto/src/lib.rs @@ -1,5 +1,6 @@ // Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0. +#[allow(renamed_and_removed_lints)] mod proto; #[cfg(any(feature = "protobuf-codec", feature = "protobufv3-codec"))] diff --git a/proto/src/proto/prost/example/routeguide.rs b/proto/src/proto/prost/example/routeguide.rs index 87cf1821..5aa205b3 100644 --- a/proto/src/proto/prost/example/routeguide.rs +++ b/proto/src/proto/prost/example/routeguide.rs @@ -4,7 +4,7 @@ /// Latitudes should be in the range +/- 90 degrees and longitude should be in /// the range +/- 180 degrees (inclusive). #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct Point { #[prost(int32, tag = "1")] pub latitude: i32, @@ -14,7 +14,7 @@ pub struct Point { /// A latitude-longitude rectangle, represented as two diagonally opposite /// points "lo" and "hi". #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct Rectangle { /// One corner of the rectangle. #[prost(message, optional, tag = "1")] @@ -53,7 +53,7 @@ pub struct RouteNote { /// detected features, and the total distance covered as the cumulative sum of /// the distance between each point. #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct RouteSummary { /// The number of points received. #[prost(int32, tag = "1")] diff --git a/proto/src/proto/prost/testing/grpc.testing.rs b/proto/src/proto/prost/testing/grpc.testing.rs index 592f90f4..8c3d7a93 100644 --- a/proto/src/proto/prost/testing/grpc.testing.rs +++ b/proto/src/proto/prost/testing/grpc.testing.rs @@ -1,6 +1,6 @@ // This file is @generated by prost-build. #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct ByteBufferParams { #[prost(int32, tag = "1")] pub req_size: i32, @@ -8,7 +8,7 @@ pub struct ByteBufferParams { pub resp_size: i32, } #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct SimpleProtoParams { #[prost(int32, tag = "1")] pub req_size: i32, @@ -18,10 +18,10 @@ pub struct SimpleProtoParams { /// TODO (vpai): Fill this in once the details of complex, representative /// protos are decided #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct ComplexProtoParams {} #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct PayloadConfig { #[prost(oneof = "payload_config::Payload", tags = "1, 2, 3")] pub payload: ::core::option::Option, @@ -29,7 +29,7 @@ pub struct PayloadConfig { /// Nested message and enum types in `PayloadConfig`. pub mod payload_config { #[allow(clippy::derive_partial_eq_without_eq)] - #[derive(Clone, PartialEq, ::prost::Oneof)] + #[derive(Clone, Copy, PartialEq, ::prost::Oneof)] pub enum Payload { #[prost(message, tag = "1")] BytebufParams(super::ByteBufferParams), @@ -40,7 +40,7 @@ pub mod payload_config { } } #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct ServerStats { /// wall clock time change in seconds since last reset #[prost(double, tag = "1")] @@ -64,7 +64,7 @@ pub struct ServerStats { } /// Histogram params based on grpc/support/histogram.c #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct HistogramParams { /// first bucket is [0, 1 + resolution) #[prost(double, tag = "1")] @@ -91,7 +91,7 @@ pub struct HistogramData { pub count: f64, } #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct RequestResultCount { #[prost(int32, tag = "1")] pub status_code: i32, @@ -121,7 +121,7 @@ pub struct ClientStats { /// Parameters of poisson process distribution, which is a good representation /// of activity coming in from independent identical stationary sources. #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct PoissonParams { /// The rate of arrivals (a.k.a. lambda parameter of the exp distribution). #[prost(double, tag = "1")] @@ -130,10 +130,10 @@ pub struct PoissonParams { /// Once an RPC finishes, immediately start a new one. /// No configuration parameters needed. #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct ClosedLoopParams {} #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct LoadParams { #[prost(oneof = "load_params::Load", tags = "1, 2")] pub load: ::core::option::Option, @@ -141,7 +141,7 @@ pub struct LoadParams { /// Nested message and enum types in `LoadParams`. pub mod load_params { #[allow(clippy::derive_partial_eq_without_eq)] - #[derive(Clone, PartialEq, ::prost::Oneof)] + #[derive(Clone, Copy, PartialEq, ::prost::Oneof)] pub enum Load { #[prost(message, tag = "1")] ClosedLoop(super::ClosedLoopParams), @@ -234,7 +234,7 @@ pub struct ClientStatus { } /// Request current stats #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct Mark { /// if true, the stats will be reset after taking their snapshot. #[prost(bool, tag = "1")] @@ -312,7 +312,7 @@ pub mod server_args { } } #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct ServerStatus { #[prost(message, optional, tag = "1")] pub stats: ::core::option::Option, @@ -324,17 +324,17 @@ pub struct ServerStatus { pub cores: i32, } #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct CoreRequest {} #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct CoreResponse { /// Number of cores available on the server #[prost(int32, tag = "1")] pub cores: i32, } #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct Void {} /// A single performance scenario: input to qps_json_driver #[allow(clippy::derive_partial_eq_without_eq)] @@ -375,7 +375,7 @@ pub struct Scenarios { /// Basic summary that can be computed from ClientStats and ServerStats /// once the scenario has finished. #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct ScenarioResultSummary { /// Total number of operations per second over all clients. #[prost(double, tag = "1")] @@ -565,13 +565,13 @@ impl RpcType { /// }; /// #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct Empty {} /// TODO(dgq): Go back to using well-known types once /// has been fixed. /// import "google/protobuf/wrappers.proto"; #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct BoolValue { /// The bool value. #[prost(bool, tag = "1")] @@ -664,7 +664,7 @@ pub struct StreamingInputCallRequest { } /// Client-streaming response. #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct StreamingInputCallResponse { /// Aggregated size of payloads received from the client. #[prost(int32, tag = "1")] @@ -672,7 +672,7 @@ pub struct StreamingInputCallResponse { } /// Configuration for a particular response. #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct ResponseParameters { /// Desired payload sizes in responses from the server. #[prost(int32, tag = "1")] @@ -720,7 +720,7 @@ pub struct StreamingOutputCallResponse { /// For reconnect interop test only. /// Client tells server what reconnection parameters it used. #[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct ReconnectParams { #[prost(int32, tag = "1")] pub max_reconnect_backoff_ms: i32, diff --git a/proto/src/proto/protobuf_v3/example/helloworld.rs b/proto/src/proto/protobuf_v3/example/helloworld.rs index 9665850f..2b195267 100644 --- a/proto/src/proto/protobuf_v3/example/helloworld.rs +++ b/proto/src/proto/protobuf_v3/example/helloworld.rs @@ -1,4 +1,4 @@ -// This file is generated by rust-protobuf 3.4.0. Do not edit +// This file is generated by rust-protobuf 3.5.0. Do not edit // @generated // https://github.com/rust-lang/rust-clippy/issues/702 @@ -22,7 +22,7 @@ /// Generated files are compatible only with the same version /// of protobuf runtime. -const _PROTOBUF_VERSION_CHECK: () = ::protobufv3::VERSION_3_4_0; +const _PROTOBUF_VERSION_CHECK: () = ::protobufv3::VERSION_3_5_0; // @@protoc_insertion_point(message:helloworld.HelloRequest) #[derive(PartialEq,Clone,Default,Debug)] diff --git a/proto/src/proto/protobuf_v3/example/route_guide.rs b/proto/src/proto/protobuf_v3/example/route_guide.rs index 6404cb54..e761e49d 100644 --- a/proto/src/proto/protobuf_v3/example/route_guide.rs +++ b/proto/src/proto/protobuf_v3/example/route_guide.rs @@ -1,4 +1,4 @@ -// This file is generated by rust-protobuf 3.4.0. Do not edit +// This file is generated by rust-protobuf 3.5.0. Do not edit // @generated // https://github.com/rust-lang/rust-clippy/issues/702 @@ -22,7 +22,7 @@ /// Generated files are compatible only with the same version /// of protobuf runtime. -const _PROTOBUF_VERSION_CHECK: () = ::protobufv3::VERSION_3_4_0; +const _PROTOBUF_VERSION_CHECK: () = ::protobufv3::VERSION_3_5_0; // @@protoc_insertion_point(message:routeguide.Point) #[derive(PartialEq,Clone,Default,Debug)] diff --git a/proto/src/proto/protobuf_v3/google/rpc/status.rs b/proto/src/proto/protobuf_v3/google/rpc/status.rs index 410fde5b..a12a4b66 100644 --- a/proto/src/proto/protobuf_v3/google/rpc/status.rs +++ b/proto/src/proto/protobuf_v3/google/rpc/status.rs @@ -1,4 +1,4 @@ -// This file is generated by rust-protobuf 3.4.0. Do not edit +// This file is generated by rust-protobuf 3.5.0. Do not edit // @generated // https://github.com/rust-lang/rust-clippy/issues/702 @@ -22,7 +22,7 @@ /// Generated files are compatible only with the same version /// of protobuf runtime. -const _PROTOBUF_VERSION_CHECK: () = ::protobufv3::VERSION_3_4_0; +const _PROTOBUF_VERSION_CHECK: () = ::protobufv3::VERSION_3_5_0; // @@protoc_insertion_point(message:google.rpc.Status) #[derive(PartialEq,Clone,Default,Debug)] diff --git a/proto/src/proto/protobuf_v3/testing/control.rs b/proto/src/proto/protobuf_v3/testing/control.rs index d9acda06..9bb50db3 100644 --- a/proto/src/proto/protobuf_v3/testing/control.rs +++ b/proto/src/proto/protobuf_v3/testing/control.rs @@ -1,4 +1,4 @@ -// This file is generated by rust-protobuf 3.4.0. Do not edit +// This file is generated by rust-protobuf 3.5.0. Do not edit // @generated // https://github.com/rust-lang/rust-clippy/issues/702 @@ -22,7 +22,7 @@ /// Generated files are compatible only with the same version /// of protobuf runtime. -const _PROTOBUF_VERSION_CHECK: () = ::protobufv3::VERSION_3_4_0; +const _PROTOBUF_VERSION_CHECK: () = ::protobufv3::VERSION_3_5_0; // @@protoc_insertion_point(message:grpc.testing.PoissonParams) #[derive(PartialEq,Clone,Default,Debug)] @@ -1206,9 +1206,7 @@ impl ::protobufv3::Message for ClientConfig { let len = v.compute_size(); my_size += 1 + ::protobufv3::rt::compute_raw_varint64_size(len) + len; } - for value in &self.core_list { - my_size += ::protobufv3::rt::int32_size(13, *value); - }; + my_size += ::protobufv3::rt::vec_packed_int32_size(13, &self.core_list); if self.core_limit != 0 { my_size += ::protobufv3::rt::int32_size(14, self.core_limit); } @@ -1261,9 +1259,7 @@ impl ::protobufv3::Message for ClientConfig { if let Some(v) = self.histogram_params.as_ref() { ::protobufv3::rt::write_message_field_with_cached_size(12, v, os)?; } - for v in &self.core_list { - os.write_int32(13, *v)?; - }; + os.write_repeated_packed_int32(13, &self.core_list)?; if self.core_limit != 0 { os.write_int32(14, self.core_limit)?; } @@ -2066,9 +2062,7 @@ impl ::protobufv3::Message for ServerConfig { let len = v.compute_size(); my_size += 1 + ::protobufv3::rt::compute_raw_varint64_size(len) + len; } - for value in &self.core_list { - my_size += ::protobufv3::rt::int32_size(10, *value); - }; + my_size += ::protobufv3::rt::vec_packed_int32_size(10, &self.core_list); if !self.other_server_api.is_empty() { my_size += ::protobufv3::rt::string_size(11, &self.other_server_api); } @@ -2106,9 +2100,7 @@ impl ::protobufv3::Message for ServerConfig { if let Some(v) = self.payload_config.as_ref() { ::protobufv3::rt::write_message_field_with_cached_size(9, v, os)?; } - for v in &self.core_list { - os.write_int32(10, *v)?; - }; + os.write_repeated_packed_int32(10, &self.core_list)?; if !self.other_server_api.is_empty() { os.write_string(11, &self.other_server_api)?; } @@ -3923,15 +3915,13 @@ impl ::protobufv3::Message for ScenarioResult { let len = value.compute_size(); my_size += 1 + ::protobufv3::rt::compute_raw_varint64_size(len) + len; }; - for value in &self.server_cores { - my_size += ::protobufv3::rt::int32_size(5, *value); - }; + my_size += ::protobufv3::rt::vec_packed_int32_size(5, &self.server_cores); if let Some(v) = self.summary.as_ref() { let len = v.compute_size(); my_size += 1 + ::protobufv3::rt::compute_raw_varint64_size(len) + len; } - my_size += 2 * self.client_success.len() as u64; - my_size += 2 * self.server_success.len() as u64; + my_size += ::protobufv3::rt::vec_packed_bool_size(7, &self.client_success); + my_size += ::protobufv3::rt::vec_packed_bool_size(8, &self.server_success); for value in &self.request_results { let len = value.compute_size(); my_size += 1 + ::protobufv3::rt::compute_raw_varint64_size(len) + len; @@ -3954,18 +3944,12 @@ impl ::protobufv3::Message for ScenarioResult { for v in &self.server_stats { ::protobufv3::rt::write_message_field_with_cached_size(4, v, os)?; }; - for v in &self.server_cores { - os.write_int32(5, *v)?; - }; + os.write_repeated_packed_int32(5, &self.server_cores)?; if let Some(v) = self.summary.as_ref() { ::protobufv3::rt::write_message_field_with_cached_size(6, v, os)?; } - for v in &self.client_success { - os.write_bool(7, *v)?; - }; - for v in &self.server_success { - os.write_bool(8, *v)?; - }; + os.write_repeated_packed_bool(7, &self.client_success)?; + os.write_repeated_packed_bool(8, &self.server_success)?; for v in &self.request_results { ::protobufv3::rt::write_message_field_with_cached_size(9, v, os)?; }; diff --git a/proto/src/proto/protobuf_v3/testing/empty.rs b/proto/src/proto/protobuf_v3/testing/empty.rs index fc2070d4..42363c10 100644 --- a/proto/src/proto/protobuf_v3/testing/empty.rs +++ b/proto/src/proto/protobuf_v3/testing/empty.rs @@ -1,4 +1,4 @@ -// This file is generated by rust-protobuf 3.4.0. Do not edit +// This file is generated by rust-protobuf 3.5.0. Do not edit // @generated // https://github.com/rust-lang/rust-clippy/issues/702 @@ -22,7 +22,7 @@ /// Generated files are compatible only with the same version /// of protobuf runtime. -const _PROTOBUF_VERSION_CHECK: () = ::protobufv3::VERSION_3_4_0; +const _PROTOBUF_VERSION_CHECK: () = ::protobufv3::VERSION_3_5_0; // @@protoc_insertion_point(message:grpc.testing.Empty) #[derive(PartialEq,Clone,Default,Debug)] diff --git a/proto/src/proto/protobuf_v3/testing/messages.rs b/proto/src/proto/protobuf_v3/testing/messages.rs index 8c3559aa..9aada284 100644 --- a/proto/src/proto/protobuf_v3/testing/messages.rs +++ b/proto/src/proto/protobuf_v3/testing/messages.rs @@ -1,4 +1,4 @@ -// This file is generated by rust-protobuf 3.4.0. Do not edit +// This file is generated by rust-protobuf 3.5.0. Do not edit // @generated // https://github.com/rust-lang/rust-clippy/issues/702 @@ -22,7 +22,7 @@ /// Generated files are compatible only with the same version /// of protobuf runtime. -const _PROTOBUF_VERSION_CHECK: () = ::protobufv3::VERSION_3_4_0; +const _PROTOBUF_VERSION_CHECK: () = ::protobufv3::VERSION_3_5_0; // @@protoc_insertion_point(message:grpc.testing.BoolValue) #[derive(PartialEq,Clone,Default,Debug)] @@ -1763,9 +1763,7 @@ impl ::protobufv3::Message for ReconnectInfo { if self.passed != false { my_size += 1 + 1; } - for value in &self.backoff_ms { - my_size += ::protobufv3::rt::int32_size(2, *value); - }; + my_size += ::protobufv3::rt::vec_packed_int32_size(2, &self.backoff_ms); my_size += ::protobufv3::rt::unknown_fields_size(self.special_fields.unknown_fields()); self.special_fields.cached_size().set(my_size as u32); my_size @@ -1775,9 +1773,7 @@ impl ::protobufv3::Message for ReconnectInfo { if self.passed != false { os.write_bool(1, self.passed)?; } - for v in &self.backoff_ms { - os.write_int32(2, *v)?; - }; + os.write_repeated_packed_int32(2, &self.backoff_ms)?; os.write_unknown_fields(self.special_fields.unknown_fields())?; ::std::result::Result::Ok(()) } diff --git a/proto/src/proto/protobuf_v3/testing/payloads.rs b/proto/src/proto/protobuf_v3/testing/payloads.rs index 915cda7f..f3f05b47 100644 --- a/proto/src/proto/protobuf_v3/testing/payloads.rs +++ b/proto/src/proto/protobuf_v3/testing/payloads.rs @@ -1,4 +1,4 @@ -// This file is generated by rust-protobuf 3.4.0. Do not edit +// This file is generated by rust-protobuf 3.5.0. Do not edit // @generated // https://github.com/rust-lang/rust-clippy/issues/702 @@ -22,7 +22,7 @@ /// Generated files are compatible only with the same version /// of protobuf runtime. -const _PROTOBUF_VERSION_CHECK: () = ::protobufv3::VERSION_3_4_0; +const _PROTOBUF_VERSION_CHECK: () = ::protobufv3::VERSION_3_5_0; // @@protoc_insertion_point(message:grpc.testing.ByteBufferParams) #[derive(PartialEq,Clone,Default,Debug)] diff --git a/proto/src/proto/protobuf_v3/testing/services.rs b/proto/src/proto/protobuf_v3/testing/services.rs index 8259d703..8c58626f 100644 --- a/proto/src/proto/protobuf_v3/testing/services.rs +++ b/proto/src/proto/protobuf_v3/testing/services.rs @@ -1,4 +1,4 @@ -// This file is generated by rust-protobuf 3.4.0. Do not edit +// This file is generated by rust-protobuf 3.5.0. Do not edit // @generated // https://github.com/rust-lang/rust-clippy/issues/702 @@ -22,7 +22,7 @@ /// Generated files are compatible only with the same version /// of protobuf runtime. -const _PROTOBUF_VERSION_CHECK: () = ::protobufv3::VERSION_3_4_0; +const _PROTOBUF_VERSION_CHECK: () = ::protobufv3::VERSION_3_5_0; static file_descriptor_proto_data: &'static [u8] = b"\ \n\x1bgrpc/testing/services.proto\x12\x0cgrpc.testing\x1a\x1bgrpc/testin\ diff --git a/proto/src/proto/protobuf_v3/testing/stats.rs b/proto/src/proto/protobuf_v3/testing/stats.rs index bd5782f4..480b4a7d 100644 --- a/proto/src/proto/protobuf_v3/testing/stats.rs +++ b/proto/src/proto/protobuf_v3/testing/stats.rs @@ -1,4 +1,4 @@ -// This file is generated by rust-protobuf 3.4.0. Do not edit +// This file is generated by rust-protobuf 3.5.0. Do not edit // @generated // https://github.com/rust-lang/rust-clippy/issues/702 @@ -22,7 +22,7 @@ /// Generated files are compatible only with the same version /// of protobuf runtime. -const _PROTOBUF_VERSION_CHECK: () = ::protobufv3::VERSION_3_4_0; +const _PROTOBUF_VERSION_CHECK: () = ::protobufv3::VERSION_3_5_0; // @@protoc_insertion_point(message:grpc.testing.ServerStats) #[derive(PartialEq,Clone,Default,Debug)] @@ -492,9 +492,7 @@ impl ::protobufv3::Message for HistogramData { #[allow(unused_variables)] fn compute_size(&self) -> u64 { let mut my_size = 0; - for value in &self.bucket { - my_size += ::protobufv3::rt::uint32_size(1, *value); - }; + my_size += ::protobufv3::rt::vec_packed_uint32_size(1, &self.bucket); if self.min_seen != 0. { my_size += 1 + 8; } @@ -516,9 +514,7 @@ impl ::protobufv3::Message for HistogramData { } fn write_to_with_cached_sizes(&self, os: &mut ::protobufv3::CodedOutputStream<'_>) -> ::protobufv3::Result<()> { - for v in &self.bucket { - os.write_uint32(1, *v)?; - }; + os.write_repeated_packed_uint32(1, &self.bucket)?; if self.min_seen != 0. { os.write_double(2, self.min_seen)?; } diff --git a/proto/src/proto/protobuf_v3/testing/test.rs b/proto/src/proto/protobuf_v3/testing/test.rs index c51ca595..c0556946 100644 --- a/proto/src/proto/protobuf_v3/testing/test.rs +++ b/proto/src/proto/protobuf_v3/testing/test.rs @@ -1,4 +1,4 @@ -// This file is generated by rust-protobuf 3.4.0. Do not edit +// This file is generated by rust-protobuf 3.5.0. Do not edit // @generated // https://github.com/rust-lang/rust-clippy/issues/702 @@ -22,7 +22,7 @@ /// Generated files are compatible only with the same version /// of protobuf runtime. -const _PROTOBUF_VERSION_CHECK: () = ::protobufv3::VERSION_3_4_0; +const _PROTOBUF_VERSION_CHECK: () = ::protobufv3::VERSION_3_5_0; static file_descriptor_proto_data: &'static [u8] = b"\ \n\x17grpc/testing/test.proto\x12\x0cgrpc.testing\x1a\x18grpc/testing/em\ diff --git a/src/channel.rs b/src/channel.rs index 118f1a31..9add19ed 100644 --- a/src/channel.rs +++ b/src/channel.rs @@ -7,7 +7,7 @@ use std::ffi::{CStr, CString}; use std::future::Future; use std::sync::Arc; use std::time::Duration; -use std::{cmp, i32, ptr}; +use std::{cmp, ptr}; use crate::{ grpc_sys::{self, gpr_timespec, grpc_arg_pointer_vtable, grpc_channel, grpc_channel_args}, diff --git a/src/codec.rs b/src/codec.rs index c51a284d..d5771fd8 100644 --- a/src/codec.rs +++ b/src/codec.rs @@ -9,7 +9,7 @@ pub type SerializeFn = fn(&T, &mut GrpcSlice) -> Result<()>; /// According to https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md, grpc uses /// a four bytes to describe the length of a message, so it should not exceed u32::MAX. -pub const MAX_MESSAGE_SIZE: usize = std::u32::MAX as usize; +pub const MAX_MESSAGE_SIZE: usize = u32::MAX as usize; /// Defines how to serialize and deserialize between the specialized type and byte slice. pub struct Marshaller { diff --git a/src/metadata.rs b/src/metadata.rs index bf4953e2..b600e23a 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -194,7 +194,7 @@ impl Metadata { let key = grpc_sys::grpcwrap_metadata_array_get_key(&self.0, index, &mut key_len); let val = grpc_sys::grpcwrap_metadata_array_get_value(&self.0, index, &mut val_len); let key_str = str::from_utf8_unchecked(slice::from_raw_parts(key as _, key_len)); - let val_bytes = slice::from_raw_parts(val as *const u8, val_len); + let val_bytes = slice::from_raw_parts(val.cast(), val_len); Some((key_str, val_bytes)) } } diff --git a/tests-and-examples/Cargo.toml b/tests-and-examples/Cargo.toml index 5063599e..218b45cf 100644 --- a/tests-and-examples/Cargo.toml +++ b/tests-and-examples/Cargo.toml @@ -20,7 +20,7 @@ futures-util = { version = "0.3", features = ["sink"] } futures-timer = "3.0" protobuf = { version = "2", optional = true } protobufv3 = { package = "protobuf", version = "3.2", optional = true } -prost = { version = "0.12", optional = true } +prost = { version = "0.13", optional = true } bytes = { version = "1.0", optional = true } log = "0.4" grpcio = { path = "..", default-features = false, features = ["boringssl"] } diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index f98c8fec..72cd21e3 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -prost-build = "0.12" +prost-build = "0.13" # Use an old enough version to make sure generated code with TiKV's fork. # TODO: use latest one when TiKV's fork is updated protoc-rust = "=2.8"