diff --git a/Cargo.lock b/Cargo.lock index 6c1bee28..18817b20 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -106,9 +106,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.92" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74f37166d7d48a0284b99dd824694c26119c700b53bf0d1540cdb147dbdaaf13" +checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" [[package]] name = "async-broadcast" @@ -320,9 +320,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.34" +version = "1.1.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67b9470d453346108f93a59222a9a1a5724db32d0a4727b7ab7ace4b4d822dc9" +checksum = "baee610e9452a8f6f0a1b6194ec09ff9e2d85dea54432acdae41aa0761c95d70" dependencies = [ "jobserver", "libc", @@ -527,19 +527,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "dashmap" -version = "5.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" -dependencies = [ - "cfg-if", - "hashbrown 0.14.5", - "lock_api", - "once_cell", - "parking_lot_core 0.9.10", -] - [[package]] name = "dashmap" version = "6.1.0" @@ -970,7 +957,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0746aa765db78b521451ef74221663b57ba595bf83f75d0ce23cc09447c8139f" dependencies = [ "cfg-if", - "dashmap 6.1.0", + "dashmap", "futures-sink", "futures-timer", "futures-util", @@ -2281,13 +2268,13 @@ dependencies = [ [[package]] name = "pilota-build" -version = "0.11.23" +version = "0.11.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c64e8bd976ebde1815859eafc66bd9c1a27df23c599bb97530b9052335d45c9" +checksum = "996a8c160a151f95b19e96b38728e7981ac198dcb2e46f1196378745b2c00362" dependencies = [ "ahash", "anyhow", - "dashmap 5.5.3", + "dashmap", "faststr", "heck 0.5.0", "itertools", @@ -2314,9 +2301,9 @@ dependencies = [ [[package]] name = "pilota-thrift-parser" -version = "0.11.3" +version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61300587788c60c862833333c118e33183ba08f41be5ace9c931f00b43be9d8" +checksum = "6f96e098d21a8d4f88242e9523140036a0e31bde96edc915c7b5ed24e32980c8" dependencies = [ "nom", ] @@ -3951,7 +3938,7 @@ name = "volo" version = "0.10.3" dependencies = [ "async-broadcast", - "dashmap 6.1.0", + "dashmap", "faststr", "futures", "libc", @@ -3979,7 +3966,7 @@ dependencies = [ [[package]] name = "volo-build" -version = "0.10.16" +version = "0.10.17" dependencies = [ "ahash", "anyhow", @@ -4139,7 +4126,7 @@ version = "0.10.0" [[package]] name = "volo-thrift" -version = "0.10.4" +version = "0.10.5" dependencies = [ "ahash", "anyhow", diff --git a/tests/code-generation/thrift/test.thrift b/tests/code-generation/thrift/test.thrift index 91d716ff..57991a4d 100644 --- a/tests/code-generation/thrift/test.thrift +++ b/tests/code-generation/thrift/test.thrift @@ -13,13 +13,13 @@ struct TestResponse { } service TestService { - TestResponse Test (1: TestRequest req), + TestResponse Test (1: TestRequest req, 2: list reqs), TestResponse test (1: TestRequest Req), TestResponse Test2 (1: TestRequest type), TestResponse Test3 (1: TestRequest self), } service testService { - TestResponse Test (1: TestRequest req), + TestResponse Test (1: TestRequest req, 2: list reqs), TestResponse test (1: TestRequest Req), } diff --git a/volo-build/Cargo.toml b/volo-build/Cargo.toml index 4b467cde..01f4a26f 100644 --- a/volo-build/Cargo.toml +++ b/volo-build/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "volo-build" -version = "0.10.16" +version = "0.10.17" edition.workspace = true homepage.workspace = true repository.workspace = true diff --git a/volo-build/src/grpc_backend.rs b/volo-build/src/grpc_backend.rs index de04c454..55372bd2 100644 --- a/volo-build/src/grpc_backend.rs +++ b/volo-build/src/grpc_backend.rs @@ -34,7 +34,7 @@ impl VoloGrpcBackend { ) -> FastStr { let ty = self.cx().codegen_item_ty(ty.kind); let ty_str = if global_path { - format!("volo_gen{}", ty.global_path()) + format!("{}", ty.global_path("volo_gen")) } else { format!("{}", ty) }; @@ -54,7 +54,7 @@ impl VoloGrpcBackend { ) -> FastStr { let ret_ty = self.cx().codegen_item_ty(ty.kind); let ret_ty_str = if global_path { - format!("volo_gen{}", ret_ty.global_path()) + format!("{}", ret_ty.global_path("volo_gen")) } else { format!("{}", ret_ty) }; @@ -402,7 +402,7 @@ impl CodegenBackend for VoloGrpcBackend { "", |enum_variant_names| -> "Self::{enum_variant_names}(s) => {{ ::volo_grpc::codec::encode::encode(s, compression_encoding) - }}," + }}," ); let req_recv_from_body = crate::join_multi_strs!( diff --git a/volo-build/src/thrift_backend.rs b/volo-build/src/thrift_backend.rs index fbe9aa97..df411fde 100644 --- a/volo-build/src/thrift_backend.rs +++ b/volo-build/src/thrift_backend.rs @@ -4,7 +4,6 @@ use pilota_build::{ db::RirDatabase, rir::{self, Method}, tags::RustWrapperArc, - ty::TyKind, CodegenBackend, Context, DefId, IdentName, Symbol, ThriftBackend, }; use quote::format_ident; @@ -648,11 +647,8 @@ impl pilota_build::CodegenBackend for VoloThriftBackend { let mut ret_ty = self .inner .codegen_item_ty(method.ret.kind.clone()) - .global_path() + .global_path("volo_gen") .to_string(); - if need_prepend_volo_gen_path(&method.ret.kind) { - ret_ty = format!("volo_gen{ret_ty}"); - } if let Some(RustWrapperArc(true)) = self .cx() .tags(method.ret.tags_id) @@ -665,13 +661,12 @@ impl pilota_build::CodegenBackend for VoloThriftBackend { .args .iter() .map(|a| { - let ty = self.inner.codegen_item_ty(a.ty.kind.clone()).global_path(); + let ty = self + .inner + .codegen_item_ty(a.ty.kind.clone()) + .global_path("volo_gen"); let ident = self.cx().rust_name(a.def_id).0.field_ident(); // use the _{rust-style fieldname} without keyword escaping - if need_prepend_volo_gen_path(&a.ty.kind) { - format!("_{ident}: volo_gen{ty}") - } else { - format!("_{ident}: {ty}") - } + format!("_{ident}: {ty}") }) .join(","); @@ -701,14 +696,6 @@ impl pilota_build::CodegenBackend for VoloThriftBackend { } } -fn need_prepend_volo_gen_path(ty: &TyKind) -> bool { - match ty { - TyKind::Arc(t) => need_prepend_volo_gen_path(&t.kind), - TyKind::Path(_) => true, - _ => false, - } -} - fn rust_name(cx: &Context, def_id: DefId) -> FastStr { let name = cx.rust_name(def_id); if cx.names.contains(&def_id) { diff --git a/volo-thrift/Cargo.toml b/volo-thrift/Cargo.toml index db433f44..b0f63e1a 100644 --- a/volo-thrift/Cargo.toml +++ b/volo-thrift/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "volo-thrift" -version = "0.10.4" +version = "0.10.5" edition.workspace = true homepage.workspace = true repository.workspace = true diff --git a/volo-thrift/src/error.rs b/volo-thrift/src/error.rs index e1887710..2a5dd917 100644 --- a/volo-thrift/src/error.rs +++ b/volo-thrift/src/error.rs @@ -229,3 +229,9 @@ pub enum MaybeException { Ok(T), Exception(E), } + +impl Default for MaybeException { + fn default() -> Self { + MaybeException::Ok(Default::default()) + } +}