diff --git a/Cargo.lock b/Cargo.lock index 82f2572e..177373b4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -307,17 +307,6 @@ dependencies = [ "parking_lot_core 0.9.10", ] -[[package]] -name = "derivative" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "diffy" version = "0.4.0" @@ -357,7 +346,6 @@ dependencies = [ "anyhow", "criterion", "dashmap 5.5.3", - "derivative", "diffy", "faststr", "heck 0.5.0", @@ -848,7 +836,6 @@ dependencies = [ "async-recursion", "bytes", "criterion", - "derivative", "faststr", "integer-encoding", "lazy_static", @@ -871,7 +858,6 @@ dependencies = [ "anyhow", "criterion", "dashmap 6.1.0", - "derivative", "diffy", "faststr", "heck 0.5.0", diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 333e5cfa..6c09ba6e 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -50,7 +50,6 @@ faststr = "0.2" [dev-dependencies] tokio = { version = "1", features = ["io-util"] } -derivative = "2" tempfile = "3" diffy = "0.4" criterion = { version = "0.5", features = ["html_reports"] } diff --git a/pilota-build/Cargo.toml b/pilota-build/Cargo.toml index 1bfcb56b..9fbc3455 100644 --- a/pilota-build/Cargo.toml +++ b/pilota-build/Cargo.toml @@ -50,7 +50,6 @@ faststr = "0.2" [dev-dependencies] pilota = { path = "../pilota" } tokio = { version = "1", features = ["io-util"] } -derivative = "2" tempfile = "3" diffy = "0.4" criterion = { version = "0.5", features = ["html_reports"] } diff --git a/pilota-build/src/plugin/mod.rs b/pilota-build/src/plugin/mod.rs index 0924915a..3173a771 100644 --- a/pilota-build/src/plugin/mod.rs +++ b/pilota-build/src/plugin/mod.rs @@ -391,18 +391,42 @@ impl Plugin for ImplDefaultPlugin { cx.with_adjust_mut(def_id, |adj| adj.add_attrs(&["#[derive(Default)]".into()])) } Item::Enum(e) => { - if !e.variants.is_empty() { - cx.with_adjust_mut(def_id, |adj| { - adj.add_attrs(&[ - "#[derive(::pilota::derivative::Derivative)]".into(), - "#[derivative(Default)]".into(), - ]); - }); - - if let Some(v) = e.variants.first() { - cx.with_adjust_mut(v.did, |adj| { - adj.add_attrs(&["#[derivative(Default)]".into()]); - }) + if let Some(first_variant) = e.variants.first() { + let is_unit_variant = first_variant.fields.is_empty(); + if is_unit_variant { + cx.with_adjust_mut(def_id, |adj| { + adj.add_attrs(&["#[derive(Default)]".into()]); + }); + + if let Some(v) = e.variants.first() { + cx.with_adjust_mut(v.did, |adj| { + adj.add_attrs(&["#[default]".into()]); + }) + } + } else { + // for non unit variant, we need to impl Default for the enum + let enum_name = cx.rust_name(def_id); + let variant_name = cx.rust_name(first_variant.did); + let fields = first_variant + .fields + .iter() + .map(|_| "::std::default::Default::default()".to_string()) + .join(",\n"); + + cx.with_adjust_mut(def_id, |adj| { + adj.add_nested_item( + format!( + r#" + impl ::std::default::Default for {enum_name} {{ + fn default() -> Self {{ + {enum_name}::{variant_name} ({fields}) + }} + }} + "# + ) + .into(), + ) + }); } } } diff --git a/pilota-build/test_data/plugin/serde.rs b/pilota-build/test_data/plugin/serde.rs index 3836f365..a6c5915c 100644 --- a/pilota-build/test_data/plugin/serde.rs +++ b/pilota-build/test_data/plugin/serde.rs @@ -195,9 +195,16 @@ pub mod serde { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(::pilota::serde::Serialize, ::pilota::serde::Deserialize)] + #[derive( + PartialOrd, + Hash, + Eq, + Ord, + Debug, + Default, + ::pilota::serde::Serialize, + ::pilota::serde::Deserialize, + )] #[serde(untagged)] #[serde(transparent)] #[derive(Clone, PartialEq, Copy)] diff --git a/pilota-build/test_data/protobuf/nested_message.rs b/pilota-build/test_data/protobuf/nested_message.rs index 157d6983..322c63e8 100644 --- a/pilota-build/test_data/protobuf/nested_message.rs +++ b/pilota-build/test_data/protobuf/nested_message.rs @@ -84,9 +84,7 @@ pub mod nested_message { } pub mod tt1 { - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq, Copy)] + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq, Copy)] #[repr(transparent)] pub struct Label(i32); diff --git a/pilota-build/test_data/protobuf/oneof.rs b/pilota-build/test_data/protobuf/oneof.rs index 16485a3b..27aa5959 100644 --- a/pilota-build/test_data/protobuf/oneof.rs +++ b/pilota-build/test_data/protobuf/oneof.rs @@ -97,11 +97,14 @@ pub mod oneof { } pub mod test { - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + + impl ::std::default::Default for Test { + fn default() -> Self { + Test::A(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum Test { - #[derivative(Default)] A(::pilota::FastStr), B(i32), @@ -168,11 +171,13 @@ pub mod oneof { ::core::result::Result::Ok(()) } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for Type { + fn default() -> Self { + Type::S(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum Type { - #[derivative(Default)] S(::pilota::FastStr), I(i32), diff --git a/pilota-build/test_data/thrift/apache.rs b/pilota-build/test_data/thrift/apache.rs index da4d8d49..540b3783 100644 --- a/pilota-build/test_data/thrift/apache.rs +++ b/pilota-build/test_data/thrift/apache.rs @@ -2,9 +2,7 @@ pub mod apache { #![allow(warnings, clippy::all)] pub mod apache { - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq, Copy)] + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq, Copy)] #[repr(transparent)] pub struct Numberz(i32); @@ -821,11 +819,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestMultiExceptionException { + fn default() -> Self { + ThriftTestTestMultiExceptionException::Err1(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestMultiExceptionException { - #[derivative(Default)] Err1(Xception), Err2(Xception2), @@ -1278,11 +1278,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestMultiResultRecv { + fn default() -> Self { + ThriftTestTestMultiResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestMultiResultRecv { - #[derivative(Default)] Ok(Xtruct), } @@ -1738,11 +1740,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestEnumResultRecv { + fn default() -> Self { + ThriftTestTestEnumResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestEnumResultRecv { - #[derivative(Default)] Ok(Numberz), } @@ -1880,11 +1884,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestOnewayResultSend { + fn default() -> Self { + ThriftTestTestOnewayResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestOnewayResultSend { - #[derivative(Default)] Ok(()), } @@ -2132,11 +2138,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestMapResultRecv { + fn default() -> Self { + ThriftTestTestMapResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(Debug, Clone, PartialEq)] pub enum ThriftTestTestMapResultRecv { - #[derivative(Default)] Ok(::pilota::AHashMap), } @@ -2524,11 +2532,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestBinaryResultRecv { + fn default() -> Self { + ThriftTestTestBinaryResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestBinaryResultRecv { - #[derivative(Default)] Ok(::pilota::Bytes), } @@ -2662,11 +2672,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for SecondServiceSecondtestStringResultSend { + fn default() -> Self { + SecondServiceSecondtestStringResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum SecondServiceSecondtestStringResultSend { - #[derivative(Default)] Ok(::pilota::FastStr), } @@ -2803,11 +2815,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestByteResultRecv { + fn default() -> Self { + ThriftTestTestByteResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestByteResultRecv { - #[derivative(Default)] Ok(i8), } @@ -3091,11 +3105,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestMapMapResultSend { + fn default() -> Self { + ThriftTestTestMapMapResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(Debug, Clone, PartialEq)] pub enum ThriftTestTestMapMapResultSend { - #[derivative(Default)] Ok(::pilota::AHashMap>), } @@ -3520,11 +3536,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestSetResultSend { + fn default() -> Self { + ThriftTestTestSetResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(Debug, Clone, PartialEq)] pub enum ThriftTestTestSetResultSend { - #[derivative(Default)] Ok(::pilota::AHashSet), } @@ -3691,11 +3709,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestStructResultSend { + fn default() -> Self { + ThriftTestTestStructResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestStructResultSend { - #[derivative(Default)] Ok(Xtruct), } @@ -4264,11 +4284,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestI64ResultSend { + fn default() -> Self { + ThriftTestTestI64ResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestI64ResultSend { - #[derivative(Default)] Ok(i64), } @@ -4589,11 +4611,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestStringResultSend { + fn default() -> Self { + ThriftTestTestStringResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestStringResultSend { - #[derivative(Default)] Ok(::pilota::FastStr), } @@ -6702,11 +6726,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestInsanityResultRecv { + fn default() -> Self { + ThriftTestTestInsanityResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(Debug, Clone, PartialEq)] pub enum ThriftTestTestInsanityResultRecv { - #[derivative(Default)] Ok(::pilota::AHashMap>), } @@ -7289,11 +7315,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestListResultRecv { + fn default() -> Self { + ThriftTestTestListResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestListResultRecv { - #[derivative(Default)] Ok(::std::vec::Vec), } @@ -7577,11 +7605,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestNestResultRecv { + fn default() -> Self { + ThriftTestTestNestResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestNestResultRecv { - #[derivative(Default)] Ok(Xtruct2), } @@ -7930,11 +7960,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestDoubleResultRecv { + fn default() -> Self { + ThriftTestTestDoubleResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Debug, Clone, PartialEq)] pub enum ThriftTestTestDoubleResultRecv { - #[derivative(Default)] Ok(f64), } @@ -8068,11 +8100,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestBoolResultRecv { + fn default() -> Self { + ThriftTestTestBoolResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestBoolResultRecv { - #[derivative(Default)] Ok(bool), } @@ -8439,11 +8473,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestTypedefResultSend { + fn default() -> Self { + ThriftTestTestTypedefResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestTypedefResultSend { - #[derivative(Default)] Ok(UserId), } @@ -8581,11 +8617,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestStringMapResultSend { + fn default() -> Self { + ThriftTestTestStringMapResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(Debug, Clone, PartialEq)] pub enum ThriftTestTestStringMapResultSend { - #[derivative(Default)] Ok(::pilota::AHashMap<::pilota::FastStr, ::pilota::FastStr>), } @@ -8916,11 +8954,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestUuidResultSend { + fn default() -> Self { + ThriftTestTestUuidResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestUuidResultSend { - #[derivative(Default)] Ok([u8; 16]), } @@ -9252,11 +9292,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestI32ResultSend { + fn default() -> Self { + ThriftTestTestI32ResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestI32ResultSend { - #[derivative(Default)] Ok(i32), } @@ -9390,11 +9432,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestVoidResultSend { + fn default() -> Self { + ThriftTestTestVoidResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestVoidResultSend { - #[derivative(Default)] Ok(()), } @@ -10005,11 +10049,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestOnewayResultRecv { + fn default() -> Self { + ThriftTestTestOnewayResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestOnewayResultRecv { - #[derivative(Default)] Ok(()), } @@ -11127,11 +11173,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for SecondServiceSecondtestStringResultRecv { + fn default() -> Self { + SecondServiceSecondtestStringResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum SecondServiceSecondtestStringResultRecv { - #[derivative(Default)] Ok(::pilota::FastStr), } @@ -11601,11 +11649,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestExceptionException { + fn default() -> Self { + ThriftTestTestExceptionException::Err1(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestExceptionException { - #[derivative(Default)] Err1(Xception), } @@ -11893,11 +11943,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestMapMapResultRecv { + fn default() -> Self { + ThriftTestTestMapMapResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(Debug, Clone, PartialEq)] pub enum ThriftTestTestMapMapResultRecv { - #[derivative(Default)] Ok(::pilota::AHashMap>), } @@ -12463,11 +12515,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestSetResultRecv { + fn default() -> Self { + ThriftTestTestSetResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(Debug, Clone, PartialEq)] pub enum ThriftTestTestSetResultRecv { - #[derivative(Default)] Ok(::pilota::AHashSet), } @@ -12782,11 +12836,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestStructResultRecv { + fn default() -> Self { + ThriftTestTestStructResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestStructResultRecv { - #[derivative(Default)] Ok(Xtruct), } @@ -13164,11 +13220,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestI64ResultRecv { + fn default() -> Self { + ThriftTestTestI64ResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestI64ResultRecv { - #[derivative(Default)] Ok(i64), } @@ -13302,11 +13360,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestStringResultRecv { + fn default() -> Self { + ThriftTestTestStringResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestStringResultRecv { - #[derivative(Default)] Ok(::pilota::FastStr), } @@ -13440,11 +13500,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestMultiResultSend { + fn default() -> Self { + ThriftTestTestMultiResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestMultiResultSend { - #[derivative(Default)] Ok(Xtruct), } @@ -13941,11 +14003,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestEnumResultSend { + fn default() -> Self { + ThriftTestTestEnumResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestEnumResultSend { - #[derivative(Default)] Ok(Numberz), } @@ -14234,11 +14298,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestMapResultSend { + fn default() -> Self { + ThriftTestTestMapResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(Debug, Clone, PartialEq)] pub enum ThriftTestTestMapResultSend { - #[derivative(Default)] Ok(::pilota::AHashMap), } @@ -14416,11 +14482,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestExceptionResultSend { + fn default() -> Self { + ThriftTestTestExceptionResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestExceptionResultSend { - #[derivative(Default)] Ok(()), Err1(Xception), @@ -15072,11 +15140,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestBinaryResultSend { + fn default() -> Self { + ThriftTestTestBinaryResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestBinaryResultSend { - #[derivative(Default)] Ok(::pilota::Bytes), } @@ -15360,11 +15430,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestByteResultSend { + fn default() -> Self { + ThriftTestTestByteResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestByteResultSend { - #[derivative(Default)] Ok(i8), } @@ -15498,11 +15570,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestMultiExceptionResultRecv { + fn default() -> Self { + ThriftTestTestMultiExceptionResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestMultiExceptionResultRecv { - #[derivative(Default)] Ok(Xtruct), Err1(Xception), @@ -17581,11 +17655,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestExceptionResultRecv { + fn default() -> Self { + ThriftTestTestExceptionResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestExceptionResultRecv { - #[derivative(Default)] Ok(()), Err1(Xception), @@ -18066,11 +18142,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestTypedefResultRecv { + fn default() -> Self { + ThriftTestTestTypedefResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestTypedefResultRecv { - #[derivative(Default)] Ok(UserId), } @@ -18355,11 +18433,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestStringMapResultRecv { + fn default() -> Self { + ThriftTestTestStringMapResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(Debug, Clone, PartialEq)] pub enum ThriftTestTestStringMapResultRecv { - #[derivative(Default)] Ok(::pilota::AHashMap<::pilota::FastStr, ::pilota::FastStr>), } @@ -18540,11 +18620,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestUuidResultRecv { + fn default() -> Self { + ThriftTestTestUuidResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestUuidResultRecv { - #[derivative(Default)] Ok([u8; 16]), } @@ -19169,11 +19251,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestI32ResultRecv { + fn default() -> Self { + ThriftTestTestI32ResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestI32ResultRecv { - #[derivative(Default)] Ok(i32), } @@ -19307,11 +19391,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestMultiExceptionResultSend { + fn default() -> Self { + ThriftTestTestMultiExceptionResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestMultiExceptionResultSend { - #[derivative(Default)] Ok(Xtruct), Err1(Xception), @@ -19533,11 +19619,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestVoidResultRecv { + fn default() -> Self { + ThriftTestTestVoidResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestVoidResultRecv { - #[derivative(Default)] Ok(()), } @@ -19635,11 +19723,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestInsanityResultSend { + fn default() -> Self { + ThriftTestTestInsanityResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(Debug, Clone, PartialEq)] pub enum ThriftTestTestInsanityResultSend { - #[derivative(Default)] Ok(::pilota::AHashMap>), } @@ -20072,11 +20162,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestListResultSend { + fn default() -> Self { + ThriftTestTestListResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestListResultSend { - #[derivative(Default)] Ok(::std::vec::Vec), } @@ -20431,11 +20523,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestNestResultSend { + fn default() -> Self { + ThriftTestTestNestResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestNestResultSend { - #[derivative(Default)] Ok(Xtruct2), } @@ -20864,11 +20958,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestDoubleResultSend { + fn default() -> Self { + ThriftTestTestDoubleResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Debug, Clone, PartialEq)] pub enum ThriftTestTestDoubleResultSend { - #[derivative(Default)] Ok(f64), } @@ -21153,11 +21249,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ThriftTestTestBoolResultSend { + fn default() -> Self { + ThriftTestTestBoolResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ThriftTestTestBoolResultSend { - #[derivative(Default)] Ok(bool), } @@ -21291,11 +21389,13 @@ pub mod apache { + __protocol.struct_end_len() } } - #[derive(Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for SomeUnion { + fn default() -> Self { + SomeUnion::MapThing(::std::default::Default::default()) + } + } + #[derive(Debug, Clone, PartialEq)] pub enum SomeUnion { - #[derivative(Default)] MapThing(::pilota::AHashMap), StringThing(::pilota::FastStr), diff --git a/pilota-build/test_data/thrift/auto_name.rs b/pilota-build/test_data/thrift/auto_name.rs index 461e1a95..b36a4d7e 100644 --- a/pilota-build/test_data/thrift/auto_name.rs +++ b/pilota-build/test_data/thrift/auto_name.rs @@ -156,11 +156,14 @@ pub mod auto_name { } } pub trait service {} - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + + impl ::std::default::Default for serviceTest2ResultRecv { + fn default() -> Self { + serviceTest2ResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum serviceTest2ResultRecv { - #[derivative(Default)] Ok(Test), } @@ -737,11 +740,13 @@ pub mod auto_name { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for servicetestResultSend { + fn default() -> Self { + servicetestResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum servicetestResultSend { - #[derivative(Default)] Ok(Test), E(TestException), @@ -1233,11 +1238,13 @@ pub mod auto_name { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ServicetestException { + fn default() -> Self { + ServicetestException::E(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ServicetestException { - #[derivative(Default)] E(TestException), } @@ -1375,11 +1382,13 @@ pub mod auto_name { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ServicetestResultRecv { + fn default() -> Self { + ServicetestResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ServicetestResultRecv { - #[derivative(Default)] Ok(Test), E(TestException), @@ -1556,11 +1565,13 @@ pub mod auto_name { } } pub const IP: &'static str = "IP"; - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for serviceTest2ResultSend { + fn default() -> Self { + serviceTest2ResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum serviceTest2ResultSend { - #[derivative(Default)] Ok(Test), } @@ -1698,11 +1709,13 @@ pub mod auto_name { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for serviceTestException { + fn default() -> Self { + serviceTestException::E(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum serviceTestException { - #[derivative(Default)] E(TestException), } @@ -1840,11 +1853,13 @@ pub mod auto_name { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for serviceTestResultRecv { + fn default() -> Self { + serviceTestResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum serviceTestResultRecv { - #[derivative(Default)] Ok(Test), E(TestException), @@ -2336,11 +2351,13 @@ pub mod auto_name { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ServiceTestResultSend { + fn default() -> Self { + ServiceTestResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ServiceTestResultSend { - #[derivative(Default)] Ok(Test), E(TestException), @@ -2707,11 +2724,14 @@ pub mod auto_name { } } pub trait Service {} - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + + impl ::std::default::Default for ServiceTest2ResultRecv { + fn default() -> Self { + ServiceTest2ResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ServiceTest2ResultRecv { - #[derivative(Default)] Ok(Test), } @@ -3049,9 +3069,7 @@ pub mod auto_name { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq, Copy)] + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq, Copy)] #[repr(transparent)] pub struct Index(i32); @@ -3456,11 +3474,13 @@ pub mod auto_name { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for servicetestException { + fn default() -> Self { + servicetestException::E(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum servicetestException { - #[derivative(Default)] E(TestException), } @@ -3598,11 +3618,13 @@ pub mod auto_name { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for servicetestResultRecv { + fn default() -> Self { + servicetestResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum servicetestResultRecv { - #[derivative(Default)] Ok(Test), E(TestException), @@ -3978,11 +4000,13 @@ pub mod auto_name { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ServicetestResultSend { + fn default() -> Self { + ServicetestResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ServicetestResultSend { - #[derivative(Default)] Ok(Test), E(TestException), @@ -4474,11 +4498,13 @@ pub mod auto_name { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for serviceTestResultSend { + fn default() -> Self { + serviceTestResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum serviceTestResultSend { - #[derivative(Default)] Ok(Test), E(TestException), @@ -4654,11 +4680,13 @@ pub mod auto_name { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ServiceTest2ResultSend { + fn default() -> Self { + ServiceTest2ResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ServiceTest2ResultSend { - #[derivative(Default)] Ok(Test), } @@ -4796,11 +4824,13 @@ pub mod auto_name { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ServiceTestException { + fn default() -> Self { + ServiceTestException::E(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ServiceTestException { - #[derivative(Default)] E(TestException), } @@ -4938,11 +4968,13 @@ pub mod auto_name { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ServiceTestResultRecv { + fn default() -> Self { + ServiceTestResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ServiceTestResultRecv { - #[derivative(Default)] Ok(Test), E(TestException), diff --git a/pilota-build/test_data/thrift/btree.rs b/pilota-build/test_data/thrift/btree.rs index ed23456f..e8896029 100644 --- a/pilota-build/test_data/thrift/btree.rs +++ b/pilota-build/test_data/thrift/btree.rs @@ -752,9 +752,7 @@ pub mod btree { map.insert(Index::B, "world"); map }); - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq, Copy)] + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq, Copy)] #[repr(transparent)] pub struct Index(i32); diff --git a/pilota-build/test_data/thrift/const_val.rs b/pilota-build/test_data/thrift/const_val.rs index af874407..4d6cea5f 100644 --- a/pilota-build/test_data/thrift/const_val.rs +++ b/pilota-build/test_data/thrift/const_val.rs @@ -2,9 +2,7 @@ pub mod const_val { #![allow(warnings, clippy::all)] pub mod const_val { - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq, Copy)] + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq, Copy)] #[repr(transparent)] pub struct Index(i32); diff --git a/pilota-build/test_data/thrift/default_value.rs b/pilota-build/test_data/thrift/default_value.rs index 527a02d5..898d1e93 100644 --- a/pilota-build/test_data/thrift/default_value.rs +++ b/pilota-build/test_data/thrift/default_value.rs @@ -2,9 +2,7 @@ pub mod default_value { #![allow(warnings, clippy::all)] pub mod default_value { - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq, Copy)] + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq, Copy)] #[repr(transparent)] pub struct B(i32); diff --git a/pilota-build/test_data/thrift/enum_test.rs b/pilota-build/test_data/thrift/enum_test.rs index 273a4675..823b89ec 100644 --- a/pilota-build/test_data/thrift/enum_test.rs +++ b/pilota-build/test_data/thrift/enum_test.rs @@ -2,9 +2,7 @@ pub mod enum_test { #![allow(warnings, clippy::all)] pub mod enum_test { - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq, Copy)] + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq, Copy)] #[repr(transparent)] pub struct Index(i32); @@ -640,11 +638,13 @@ pub mod enum_test { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for TestTestEnumVarTypeNameConflictResultSend { + fn default() -> Self { + TestTestEnumVarTypeNameConflictResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum TestTestEnumVarTypeNameConflictResultSend { - #[derivative(Default)] Ok(Err), } @@ -939,11 +939,13 @@ pub mod enum_test { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for TestTestEnumResultSend { + fn default() -> Self { + TestTestEnumResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum TestTestEnumResultSend { - #[derivative(Default)] Ok(Err), } @@ -1291,9 +1293,7 @@ pub mod enum_test { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq, Copy)] + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq, Copy)] #[repr(transparent)] pub struct _Enum(i32); @@ -1383,11 +1383,14 @@ pub mod enum_test { } } pub trait Test {} - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + + impl ::std::default::Default for TestTestEnumVarTypeNameConflictResultRecv { + fn default() -> Self { + TestTestEnumVarTypeNameConflictResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum TestTestEnumVarTypeNameConflictResultRecv { - #[derivative(Default)] Ok(Err), } @@ -1529,11 +1532,13 @@ pub mod enum_test { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for TestTestEnumResultRecv { + fn default() -> Self { + TestTestEnumResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum TestTestEnumResultRecv { - #[derivative(Default)] Ok(Err), } diff --git a/pilota-build/test_data/thrift/multi.rs b/pilota-build/test_data/thrift/multi.rs index cb8eeac4..0b0ee0a6 100644 --- a/pilota-build/test_data/thrift/multi.rs +++ b/pilota-build/test_data/thrift/multi.rs @@ -179,9 +179,7 @@ pub mod multi { } } pub const A_S: &'static str = "string"; - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq, Copy)] + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq, Copy)] #[repr(transparent)] pub struct B(i32); diff --git a/pilota-build/test_data/thrift/normal.rs b/pilota-build/test_data/thrift/normal.rs index cc75ee1f..9f3e2390 100644 --- a/pilota-build/test_data/thrift/normal.rs +++ b/pilota-build/test_data/thrift/normal.rs @@ -1062,11 +1062,13 @@ pub mod normal { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for TestTest123ResultSend { + fn default() -> Self { + TestTest123ResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum TestTest123ResultSend { - #[derivative(Default)] Ok(()), } @@ -1607,11 +1609,13 @@ pub mod normal { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for TestTestExceptionException { + fn default() -> Self { + TestTestExceptionException::StException(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum TestTestExceptionException { - #[derivative(Default)] StException(StException), } @@ -1750,11 +1754,13 @@ pub mod normal { + __protocol.struct_end_len() } } - #[derive(Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for TestTestExceptionResultSend { + fn default() -> Self { + TestTestExceptionResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(Debug, Clone, PartialEq)] pub enum TestTestExceptionResultSend { - #[derivative(Default)] Ok(ObjReq), StException(StException), @@ -1931,11 +1937,13 @@ pub mod normal { + __protocol.struct_end_len() } } - #[derive(Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for TestTestExceptionResultRecv { + fn default() -> Self { + TestTestExceptionResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(Debug, Clone, PartialEq)] pub enum TestTestExceptionResultRecv { - #[derivative(Default)] Ok(ObjReq), StException(StException), @@ -2112,11 +2120,13 @@ pub mod normal { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for TestTest123ResultRecv { + fn default() -> Self { + TestTest123ResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum TestTest123ResultRecv { - #[derivative(Default)] Ok(()), } diff --git a/pilota-build/test_data/thrift/pilota_name.rs b/pilota-build/test_data/thrift/pilota_name.rs index c21849f1..dee12f3c 100644 --- a/pilota-build/test_data/thrift/pilota_name.rs +++ b/pilota-build/test_data/thrift/pilota_name.rs @@ -310,11 +310,13 @@ pub mod pilota_name { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for TestServiceTestResultSend { + fn default() -> Self { + TestServiceTestResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum TestServiceTestResultSend { - #[derivative(Default)] Ok(Test1), } @@ -799,11 +801,14 @@ pub mod pilota_name { } pub const LANG_ID: &'static str = "id"; pub trait TestService {} - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + + impl ::std::default::Default for TestServiceTestResultRecv { + fn default() -> Self { + TestServiceTestResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum TestServiceTestResultRecv { - #[derivative(Default)] Ok(Test1), } @@ -941,9 +946,7 @@ pub mod pilota_name { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq, Copy)] + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq, Copy)] #[repr(transparent)] pub struct Index(i32); diff --git a/pilota-build/test_data/thrift/self_kw.rs b/pilota-build/test_data/thrift/self_kw.rs index efbd0169..ba51a1ea 100644 --- a/pilota-build/test_data/thrift/self_kw.rs +++ b/pilota-build/test_data/thrift/self_kw.rs @@ -2,9 +2,7 @@ pub mod self_kw { #![allow(warnings, clippy::all)] pub mod self_kw { - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq, Copy)] + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq, Copy)] #[repr(transparent)] pub struct Index(i32); diff --git a/pilota-build/test_data/thrift/underscore.rs b/pilota-build/test_data/thrift/underscore.rs index fa87a463..eda14b2e 100644 --- a/pilota-build/test_data/thrift/underscore.rs +++ b/pilota-build/test_data/thrift/underscore.rs @@ -2,11 +2,14 @@ pub mod underscore { #![allow(warnings, clippy::all)] pub mod underscore { - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + + impl ::std::default::Default for Test_UnderscoredResultRecv { + fn default() -> Self { + Test_UnderscoredResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum Test_UnderscoredResultRecv { - #[derivative(Default)] Ok(::pilota::FastStr), } @@ -440,11 +443,13 @@ pub mod underscore { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for Test_UnderscoredResultSend { + fn default() -> Self { + Test_UnderscoredResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum Test_UnderscoredResultSend { - #[derivative(Default)] Ok(::pilota::FastStr), } diff --git a/pilota-build/test_data/thrift/union.rs b/pilota-build/test_data/thrift/union.rs index 0cd988b6..3ab549e6 100644 --- a/pilota-build/test_data/thrift/union.rs +++ b/pilota-build/test_data/thrift/union.rs @@ -2,11 +2,14 @@ pub mod union { #![allow(warnings, clippy::all)] pub mod union { - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + + impl ::std::default::Default for Union { + fn default() -> Self { + Union::A(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum Union { - #[derivative(Default)] A(::pilota::FastStr), B(::pilota::Bytes), @@ -169,6 +172,126 @@ pub mod union { + __protocol.struct_end_len() } } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct Default {} + impl ::pilota::thrift::Message for Default { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "Default" }; + + __protocol.write_struct_begin(&struct_ident)?; + + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Default` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self {}; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Default` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self {}; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol + .struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "Default" }) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum Empty {} diff --git a/pilota-build/test_data/thrift/union.thrift b/pilota-build/test_data/thrift/union.thrift index a1bbd6b8..da8b5c36 100644 --- a/pilota-build/test_data/thrift/union.thrift +++ b/pilota-build/test_data/thrift/union.thrift @@ -9,4 +9,6 @@ struct A { union Empty { -} \ No newline at end of file +} + +struct Default {} \ No newline at end of file diff --git a/pilota-build/test_data/thrift/void.rs b/pilota-build/test_data/thrift/void.rs index 9d8e1479..3f269852 100644 --- a/pilota-build/test_data/thrift/void.rs +++ b/pilota-build/test_data/thrift/void.rs @@ -2,11 +2,14 @@ pub mod void { #![allow(warnings, clippy::all)] pub mod void { - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + + impl ::std::default::Default for TestTest123ResultRecv { + fn default() -> Self { + TestTest123ResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum TestTest123ResultRecv { - #[derivative(Default)] Ok(()), } @@ -342,11 +345,13 @@ pub mod void { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for TestTest123ResultSend { + fn default() -> Self { + TestTest123ResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum TestTest123ResultSend { - #[derivative(Default)] Ok(()), } diff --git a/pilota-build/test_data/thrift/wrapper_arc.rs b/pilota-build/test_data/thrift/wrapper_arc.rs index 6134c29e..e7393253 100644 --- a/pilota-build/test_data/thrift/wrapper_arc.rs +++ b/pilota-build/test_data/thrift/wrapper_arc.rs @@ -122,11 +122,14 @@ pub mod wrapper_arc { } } pub trait TestService {} - #[derive(Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + + impl ::std::default::Default for TestServiceTestResultRecv { + fn default() -> Self { + TestServiceTestResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(Debug, Clone, PartialEq)] pub enum TestServiceTestResultRecv { - #[derivative(Default)] Ok(Test), } @@ -419,11 +422,13 @@ pub mod wrapper_arc { + __protocol.struct_end_len() } } - #[derive(Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for TestServiceTestResultSend { + fn default() -> Self { + TestServiceTestResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(Debug, Clone, PartialEq)] pub enum TestServiceTestResultSend { - #[derivative(Default)] Ok(::std::sync::Arc), } diff --git a/pilota-build/test_data/thrift_with_split/wrapper_arc/enum_TestServiceTestResultRecv.rs b/pilota-build/test_data/thrift_with_split/wrapper_arc/enum_TestServiceTestResultRecv.rs index eb02d1a1..2386cf8b 100644 --- a/pilota-build/test_data/thrift_with_split/wrapper_arc/enum_TestServiceTestResultRecv.rs +++ b/pilota-build/test_data/thrift_with_split/wrapper_arc/enum_TestServiceTestResultRecv.rs @@ -1,8 +1,11 @@ -#[derive(Debug, ::pilota::derivative::Derivative)] -#[derivative(Default)] -#[derive(Clone, PartialEq)] + +impl ::std::default::Default for TestServiceTestResultRecv { + fn default() -> Self { + TestServiceTestResultRecv::Ok(::std::default::Default::default()) + } +} +#[derive(Debug, Clone, PartialEq)] pub enum TestServiceTestResultRecv { - #[derivative(Default)] Ok(Test), } diff --git a/pilota-build/test_data/thrift_with_split/wrapper_arc/enum_TestServiceTestResultSend_2.rs b/pilota-build/test_data/thrift_with_split/wrapper_arc/enum_TestServiceTestResultSend_2.rs index 97b0f8b5..3de795a7 100644 --- a/pilota-build/test_data/thrift_with_split/wrapper_arc/enum_TestServiceTestResultSend_2.rs +++ b/pilota-build/test_data/thrift_with_split/wrapper_arc/enum_TestServiceTestResultSend_2.rs @@ -1,8 +1,11 @@ -#[derive(Debug, ::pilota::derivative::Derivative)] -#[derivative(Default)] -#[derive(Clone, PartialEq)] + +impl ::std::default::Default for TestServiceTestResultSend { + fn default() -> Self { + TestServiceTestResultSend::Ok(::std::default::Default::default()) + } +} +#[derive(Debug, Clone, PartialEq)] pub enum TestServiceTestResultSend { - #[derivative(Default)] Ok(::std::sync::Arc), } diff --git a/pilota-build/test_data/thrift_with_split/wrapper_arc/enum_testServiceTestResultRecv_2.rs b/pilota-build/test_data/thrift_with_split/wrapper_arc/enum_testServiceTestResultRecv_2.rs index 1eb96f14..294e19c4 100644 --- a/pilota-build/test_data/thrift_with_split/wrapper_arc/enum_testServiceTestResultRecv_2.rs +++ b/pilota-build/test_data/thrift_with_split/wrapper_arc/enum_testServiceTestResultRecv_2.rs @@ -1,8 +1,11 @@ -#[derive(Debug, ::pilota::derivative::Derivative)] -#[derivative(Default)] -#[derive(Clone, PartialEq)] + +impl ::std::default::Default for testServiceTestResultRecv { + fn default() -> Self { + testServiceTestResultRecv::Ok(::std::default::Default::default()) + } +} +#[derive(Debug, Clone, PartialEq)] pub enum testServiceTestResultRecv { - #[derivative(Default)] Ok(Test), } diff --git a/pilota-build/test_data/thrift_with_split/wrapper_arc/enum_testServiceTestResultSend.rs b/pilota-build/test_data/thrift_with_split/wrapper_arc/enum_testServiceTestResultSend.rs index 2016b6ab..1cb58cce 100644 --- a/pilota-build/test_data/thrift_with_split/wrapper_arc/enum_testServiceTestResultSend.rs +++ b/pilota-build/test_data/thrift_with_split/wrapper_arc/enum_testServiceTestResultSend.rs @@ -1,8 +1,11 @@ -#[derive(Debug, ::pilota::derivative::Derivative)] -#[derivative(Default)] -#[derive(Clone, PartialEq)] + +impl ::std::default::Default for testServiceTestResultSend { + fn default() -> Self { + testServiceTestResultSend::Ok(::std::default::Default::default()) + } +} +#[derive(Debug, Clone, PartialEq)] pub enum testServiceTestResultSend { - #[derivative(Default)] Ok(::std::sync::Arc), } diff --git a/pilota-build/test_data/thrift_workspace/output/article/src/gen.rs b/pilota-build/test_data/thrift_workspace/output/article/src/gen.rs index 5b353c3d..4ea621b7 100644 --- a/pilota-build/test_data/thrift_workspace/output/article/src/gen.rs +++ b/pilota-build/test_data/thrift_workspace/output/article/src/gen.rs @@ -2,9 +2,7 @@ pub mod gen { #![allow(warnings, clippy::all)] pub mod article { - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq, Copy)] + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq, Copy)] #[repr(transparent)] pub struct Status(i32); @@ -246,11 +244,13 @@ pub mod gen { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ArticleServiceGetArticleResultSend { + fn default() -> Self { + ArticleServiceGetArticleResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ArticleServiceGetArticleResultSend { - #[derivative(Default)] Ok(GetArticleResponse), } @@ -852,11 +852,14 @@ pub mod gen { } } pub trait ArticleService {} - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + + impl ::std::default::Default for ArticleServiceGetArticleResultRecv { + fn default() -> Self { + ArticleServiceGetArticleResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ArticleServiceGetArticleResultRecv { - #[derivative(Default)] Ok(GetArticleResponse), } diff --git a/pilota-build/test_data/thrift_workspace/output/author/src/gen.rs b/pilota-build/test_data/thrift_workspace/output/author/src/gen.rs index d06fec3d..02333ae8 100644 --- a/pilota-build/test_data/thrift_workspace/output/author/src/gen.rs +++ b/pilota-build/test_data/thrift_workspace/output/author/src/gen.rs @@ -14,11 +14,14 @@ pub mod gen { pub mod author { pub trait AuthorService {} - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + + impl ::std::default::Default for AuthorServiceGetAuthorResultRecv { + fn default() -> Self { + AuthorServiceGetAuthorResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum AuthorServiceGetAuthorResultRecv { - #[derivative(Default)] Ok(GetAuthorResponse), } @@ -305,11 +308,13 @@ pub mod gen { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for AuthorServiceGetAuthorResultSend { + fn default() -> Self { + AuthorServiceGetAuthorResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum AuthorServiceGetAuthorResultSend { - #[derivative(Default)] Ok(GetAuthorResponse), } diff --git a/pilota-build/test_data/thrift_workspace/output/image/src/gen.rs b/pilota-build/test_data/thrift_workspace/output/image/src/gen.rs index c89387d2..8fe93b2d 100644 --- a/pilota-build/test_data/thrift_workspace/output/image/src/gen.rs +++ b/pilota-build/test_data/thrift_workspace/output/image/src/gen.rs @@ -164,11 +164,13 @@ pub mod gen { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + impl ::std::default::Default for ImageServiceGetImageResultSend { + fn default() -> Self { + ImageServiceGetImageResultSend::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ImageServiceGetImageResultSend { - #[derivative(Default)] Ok(GetImageResponse), } @@ -796,11 +798,14 @@ pub mod gen { } } pub trait ImageService {} - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] + + impl ::std::default::Default for ImageServiceGetImageResultRecv { + fn default() -> Self { + ImageServiceGetImageResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ImageServiceGetImageResultRecv { - #[derivative(Default)] Ok(GetImageResponse), } diff --git a/pilota-build/test_data/thrift_workspace_with_split/output/article/src/article/enum_ArticleServiceGetArticleResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/output/article/src/article/enum_ArticleServiceGetArticleResultRecv.rs index f9bfba0b..50f026da 100644 --- a/pilota-build/test_data/thrift_workspace_with_split/output/article/src/article/enum_ArticleServiceGetArticleResultRecv.rs +++ b/pilota-build/test_data/thrift_workspace_with_split/output/article/src/article/enum_ArticleServiceGetArticleResultRecv.rs @@ -1,8 +1,11 @@ -#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] -#[derivative(Default)] -#[derive(Clone, PartialEq)] + +impl ::std::default::Default for ArticleServiceGetArticleResultRecv { + fn default() -> Self { + ArticleServiceGetArticleResultRecv::Ok(::std::default::Default::default()) + } +} +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ArticleServiceGetArticleResultRecv { - #[derivative(Default)] Ok(GetArticleResponse), } diff --git a/pilota-build/test_data/thrift_workspace_with_split/output/article/src/article/enum_ArticleServiceGetArticleResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/output/article/src/article/enum_ArticleServiceGetArticleResultSend.rs index a84e3837..8289cf34 100644 --- a/pilota-build/test_data/thrift_workspace_with_split/output/article/src/article/enum_ArticleServiceGetArticleResultSend.rs +++ b/pilota-build/test_data/thrift_workspace_with_split/output/article/src/article/enum_ArticleServiceGetArticleResultSend.rs @@ -1,8 +1,11 @@ -#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] -#[derivative(Default)] -#[derive(Clone, PartialEq)] + +impl ::std::default::Default for ArticleServiceGetArticleResultSend { + fn default() -> Self { + ArticleServiceGetArticleResultSend::Ok(::std::default::Default::default()) + } +} +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ArticleServiceGetArticleResultSend { - #[derivative(Default)] Ok(GetArticleResponse), } diff --git a/pilota-build/test_data/thrift_workspace_with_split/output/article/src/article/enum_Status.rs b/pilota-build/test_data/thrift_workspace_with_split/output/article/src/article/enum_Status.rs index 453a7996..d9945484 100644 --- a/pilota-build/test_data/thrift_workspace_with_split/output/article/src/article/enum_Status.rs +++ b/pilota-build/test_data/thrift_workspace_with_split/output/article/src/article/enum_Status.rs @@ -1,6 +1,4 @@ -#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] -#[derivative(Default)] -#[derive(Clone, PartialEq, Copy)] +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq, Copy)] #[repr(transparent)] pub struct Status(i32); diff --git a/pilota-build/test_data/thrift_workspace_with_split/output/author/src/author/enum_AuthorServiceGetAuthorResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/output/author/src/author/enum_AuthorServiceGetAuthorResultRecv.rs index 81045cdb..1f133693 100644 --- a/pilota-build/test_data/thrift_workspace_with_split/output/author/src/author/enum_AuthorServiceGetAuthorResultRecv.rs +++ b/pilota-build/test_data/thrift_workspace_with_split/output/author/src/author/enum_AuthorServiceGetAuthorResultRecv.rs @@ -1,8 +1,11 @@ -#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] -#[derivative(Default)] -#[derive(Clone, PartialEq)] + +impl ::std::default::Default for AuthorServiceGetAuthorResultRecv { + fn default() -> Self { + AuthorServiceGetAuthorResultRecv::Ok(::std::default::Default::default()) + } +} +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum AuthorServiceGetAuthorResultRecv { - #[derivative(Default)] Ok(GetAuthorResponse), } diff --git a/pilota-build/test_data/thrift_workspace_with_split/output/author/src/author/enum_AuthorServiceGetAuthorResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/output/author/src/author/enum_AuthorServiceGetAuthorResultSend.rs index 37419a87..15ba4905 100644 --- a/pilota-build/test_data/thrift_workspace_with_split/output/author/src/author/enum_AuthorServiceGetAuthorResultSend.rs +++ b/pilota-build/test_data/thrift_workspace_with_split/output/author/src/author/enum_AuthorServiceGetAuthorResultSend.rs @@ -1,8 +1,11 @@ -#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] -#[derivative(Default)] -#[derive(Clone, PartialEq)] + +impl ::std::default::Default for AuthorServiceGetAuthorResultSend { + fn default() -> Self { + AuthorServiceGetAuthorResultSend::Ok(::std::default::Default::default()) + } +} +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum AuthorServiceGetAuthorResultSend { - #[derivative(Default)] Ok(GetAuthorResponse), } diff --git a/pilota-build/test_data/thrift_workspace_with_split/output/image/src/article/image/enum_ImageServiceGetImageResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/output/image/src/article/image/enum_ImageServiceGetImageResultRecv.rs index b25d6dc0..7ee77ec2 100644 --- a/pilota-build/test_data/thrift_workspace_with_split/output/image/src/article/image/enum_ImageServiceGetImageResultRecv.rs +++ b/pilota-build/test_data/thrift_workspace_with_split/output/image/src/article/image/enum_ImageServiceGetImageResultRecv.rs @@ -1,8 +1,11 @@ -#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] -#[derivative(Default)] -#[derive(Clone, PartialEq)] + +impl ::std::default::Default for ImageServiceGetImageResultRecv { + fn default() -> Self { + ImageServiceGetImageResultRecv::Ok(::std::default::Default::default()) + } +} +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ImageServiceGetImageResultRecv { - #[derivative(Default)] Ok(GetImageResponse), } diff --git a/pilota-build/test_data/thrift_workspace_with_split/output/image/src/article/image/enum_ImageServiceGetImageResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/output/image/src/article/image/enum_ImageServiceGetImageResultSend.rs index 8caa6563..497c4af0 100644 --- a/pilota-build/test_data/thrift_workspace_with_split/output/image/src/article/image/enum_ImageServiceGetImageResultSend.rs +++ b/pilota-build/test_data/thrift_workspace_with_split/output/image/src/article/image/enum_ImageServiceGetImageResultSend.rs @@ -1,8 +1,11 @@ -#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] -#[derivative(Default)] -#[derive(Clone, PartialEq)] + +impl ::std::default::Default for ImageServiceGetImageResultSend { + fn default() -> Self { + ImageServiceGetImageResultSend::Ok(::std::default::Default::default()) + } +} +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] pub enum ImageServiceGetImageResultSend { - #[derivative(Default)] Ok(GetImageResponse), } diff --git a/pilota-build/test_data/unknown_fields.rs b/pilota-build/test_data/unknown_fields.rs index 49c70526..ef024dd8 100644 --- a/pilota-build/test_data/unknown_fields.rs +++ b/pilota-build/test_data/unknown_fields.rs @@ -1980,11 +1980,23 @@ pub mod unknown_fields { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(::pilota::serde::Serialize, ::pilota::serde::Deserialize, Clone, PartialEq)] + impl ::std::default::Default for TestUnion { + fn default() -> Self { + TestUnion::A(::std::default::Default::default()) + } + } + #[derive( + PartialOrd, + Hash, + Eq, + Ord, + Debug, + ::pilota::serde::Serialize, + ::pilota::serde::Deserialize, + Clone, + PartialEq, + )] pub enum TestUnion { - #[derivative(Default)] A(A), B(B), @@ -2180,11 +2192,23 @@ pub mod unknown_fields { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(::pilota::serde::Serialize, ::pilota::serde::Deserialize, Clone, PartialEq)] + impl ::std::default::Default for TestTestExceptionException { + fn default() -> Self { + TestTestExceptionException::StException(::std::default::Default::default()) + } + } + #[derive( + PartialOrd, + Hash, + Eq, + Ord, + Debug, + ::pilota::serde::Serialize, + ::pilota::serde::Deserialize, + Clone, + PartialEq, + )] pub enum TestTestExceptionException { - #[derivative(Default)] StException(StException), } @@ -2323,11 +2347,23 @@ pub mod unknown_fields { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(::pilota::serde::Serialize, ::pilota::serde::Deserialize, Clone, PartialEq)] + impl ::std::default::Default for TestTestExceptionResultRecv { + fn default() -> Self { + TestTestExceptionResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive( + PartialOrd, + Hash, + Eq, + Ord, + Debug, + ::pilota::serde::Serialize, + ::pilota::serde::Deserialize, + Clone, + PartialEq, + )] pub enum TestTestExceptionResultRecv { - #[derivative(Default)] Ok(ObjReq), StException(StException), @@ -2504,11 +2540,23 @@ pub mod unknown_fields { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(::pilota::serde::Serialize, ::pilota::serde::Deserialize, Clone, PartialEq)] + impl ::std::default::Default for TestTest123ResultRecv { + fn default() -> Self { + TestTest123ResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive( + PartialOrd, + Hash, + Eq, + Ord, + Debug, + ::pilota::serde::Serialize, + ::pilota::serde::Deserialize, + Clone, + PartialEq, + )] pub enum TestTest123ResultRecv { - #[derivative(Default)] Ok(()), } @@ -2606,9 +2654,16 @@ pub mod unknown_fields { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(::pilota::serde::Serialize, ::pilota::serde::Deserialize)] + #[derive( + PartialOrd, + Hash, + Eq, + Ord, + Debug, + Default, + ::pilota::serde::Serialize, + ::pilota::serde::Deserialize, + )] #[serde(transparent)] #[derive(Clone, PartialEq, Copy)] #[repr(transparent)] @@ -3018,11 +3073,23 @@ pub mod unknown_fields { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(::pilota::serde::Serialize, ::pilota::serde::Deserialize, Clone, PartialEq)] + impl ::std::default::Default for TestTest123ResultSend { + fn default() -> Self { + TestTest123ResultSend::Ok(::std::default::Default::default()) + } + } + #[derive( + PartialOrd, + Hash, + Eq, + Ord, + Debug, + ::pilota::serde::Serialize, + ::pilota::serde::Deserialize, + Clone, + PartialEq, + )] pub enum TestTest123ResultSend { - #[derivative(Default)] Ok(()), } @@ -3410,11 +3477,23 @@ pub mod unknown_fields { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(::pilota::serde::Serialize, ::pilota::serde::Deserialize, Clone, PartialEq)] + impl ::std::default::Default for TestTestExceptionResultSend { + fn default() -> Self { + TestTestExceptionResultSend::Ok(::std::default::Default::default()) + } + } + #[derive( + PartialOrd, + Hash, + Eq, + Ord, + Debug, + ::pilota::serde::Serialize, + ::pilota::serde::Deserialize, + Clone, + PartialEq, + )] pub enum TestTestExceptionResultSend { - #[derivative(Default)] Ok(ObjReq), StException(StException), @@ -3603,11 +3682,24 @@ pub mod unknown_fields { pub mod void { pub trait Test {} - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(::pilota::serde::Serialize, ::pilota::serde::Deserialize, Clone, PartialEq)] + + impl ::std::default::Default for TestTest123ResultRecv { + fn default() -> Self { + TestTest123ResultRecv::Ok(::std::default::Default::default()) + } + } + #[derive( + PartialOrd, + Hash, + Eq, + Ord, + Debug, + ::pilota::serde::Serialize, + ::pilota::serde::Deserialize, + Clone, + PartialEq, + )] pub enum TestTest123ResultRecv { - #[derivative(Default)] Ok(()), } @@ -3705,11 +3797,23 @@ pub mod unknown_fields { + __protocol.struct_end_len() } } - #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(::pilota::serde::Serialize, ::pilota::serde::Deserialize, Clone, PartialEq)] + impl ::std::default::Default for TestTest123ResultSend { + fn default() -> Self { + TestTest123ResultSend::Ok(::std::default::Default::default()) + } + } + #[derive( + PartialOrd, + Hash, + Eq, + Ord, + Debug, + ::pilota::serde::Serialize, + ::pilota::serde::Deserialize, + Clone, + PartialEq, + )] pub enum TestTest123ResultSend { - #[derivative(Default)] Ok(()), } diff --git a/pilota/Cargo.toml b/pilota/Cargo.toml index 608da0c3..8062da55 100644 --- a/pilota/Cargo.toml +++ b/pilota/Cargo.toml @@ -25,7 +25,6 @@ async-recursion = "1" tokio = { version = "1", features = ["io-util"] } lazy_static = "1" linkedbytes = "0.1" -derivative = "2" anyhow = "1" thiserror = "1" faststr = { version = "0.2", features = ["serde"] } diff --git a/pilota/src/lib.rs b/pilota/src/lib.rs index 64012cf5..d402e597 100644 --- a/pilota/src/lib.rs +++ b/pilota/src/lib.rs @@ -10,7 +10,6 @@ pub mod thrift; pub use ahash::{AHashMap, AHashSet}; pub use async_recursion; pub use bytes::*; -pub use derivative; pub use faststr::FastStr; pub use lazy_static; pub use ordered_float::OrderedFloat;