From 90a4a9aadfad7b8099604c6b3d279472f2dcd850 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Wo=C5=BAniak?= Date: Thu, 19 Sep 2024 14:31:45 +0200 Subject: [PATCH] chore: Rename variables to be more intuitive --- .../src/contract/communication/reply.rs | 24 ++++++++++++------- sylvia-derive/src/contract/mt.rs | 4 ++-- sylvia-derive/src/entry_points.rs | 8 +++---- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/sylvia-derive/src/contract/communication/reply.rs b/sylvia-derive/src/contract/communication/reply.rs index 78dadd86..7c403501 100644 --- a/sylvia-derive/src/contract/communication/reply.rs +++ b/sylvia-derive/src/contract/communication/reply.rs @@ -161,15 +161,15 @@ impl<'a> ReplyData<'a> { fn emit_match_arms(&self, contract: &Type, generics: &[&GenericParam]) -> TokenStream { let Self { reply_id, handlers } = self; - let contract_turbo: Type = if !generics.is_empty() { + let contract_turbofish: Type = if !generics.is_empty() { let contract_name = StripGenerics.fold_type((contract.clone()).clone()); parse_quote! { #contract_name :: < #(#generics),* > } } else { parse_quote! { #contract } }; - let success_match_arm = emit_success_match_arm(handlers, &contract_turbo); - let failure_match_arm = emit_failure_match_arm(handlers, &contract_turbo); + let success_match_arm = emit_success_match_arm(handlers, &contract_turbofish); + let failure_match_arm = emit_failure_match_arm(handlers, &contract_turbofish); quote! { #reply_id => { @@ -185,7 +185,10 @@ impl<'a> ReplyData<'a> { /// Emits match arm for [ReplyOn::Success]. /// In case neither [ReplyOn::Success] nor [ReplyOn::Always] is present, `Response::events` /// and `Response::data` are forwarded in the `Response` -fn emit_success_match_arm(handlers: &[(&Ident, ReplyOn)], contract_turbo: &Type) -> TokenStream { +fn emit_success_match_arm( + handlers: &[(&Ident, ReplyOn)], + contract_turbofish: &Type, +) -> TokenStream { let sylvia = crate_module(); match handlers @@ -196,12 +199,12 @@ fn emit_success_match_arm(handlers: &[(&Ident, ReplyOn)], contract_turbo: &Type) #sylvia ::cw_std::SubMsgResult::Ok(sub_msg_resp) => { #[allow(deprecated)] let #sylvia ::cw_std::SubMsgResponse { events, data, msg_responses} = sub_msg_resp; - #contract_turbo ::new(). #function_name ((deps, env, gas_used, events, msg_responses).into(), data, payload) + #contract_turbofish ::new(). #function_name ((deps, env, gas_used, events, msg_responses).into(), data, payload) } }, Some((function_name, reply_on)) if reply_on == &ReplyOn::Always => quote! { #sylvia ::cw_std::SubMsgResult::Ok(_) => { - #contract_turbo ::new(). #function_name ((deps, env, gas_used, vec![], vec![]).into(), result, payload) + #contract_turbofish ::new(). #function_name ((deps, env, gas_used, vec![], vec![]).into(), result, payload) } }, _ => quote! { @@ -222,7 +225,10 @@ fn emit_success_match_arm(handlers: &[(&Ident, ReplyOn)], contract_turbo: &Type) /// Emits match arm for [ReplyOn::Failure]. /// In case neither [ReplyOn::Failure] nor [ReplyOn::Always] is present, /// the error is forwarded. -fn emit_failure_match_arm(handlers: &[(&Ident, ReplyOn)], contract_turbo: &Type) -> TokenStream { +fn emit_failure_match_arm( + handlers: &[(&Ident, ReplyOn)], + contract_turbofish: &Type, +) -> TokenStream { let sylvia = crate_module(); match handlers @@ -231,12 +237,12 @@ fn emit_failure_match_arm(handlers: &[(&Ident, ReplyOn)], contract_turbo: &Type) { Some((function_name, reply_on)) if reply_on == &ReplyOn::Failure => quote! { #sylvia ::cw_std::SubMsgResult::Err(error) => { - #contract_turbo ::new(). #function_name ((deps, env, gas_used, vec![], vec![]).into(), error, payload) + #contract_turbofish ::new(). #function_name ((deps, env, gas_used, vec![], vec![]).into(), error, payload) } }, Some((function_name, reply_on)) if reply_on == &ReplyOn::Always => quote! { #sylvia ::cw_std::SubMsgResult::Err(_) => { - #contract_turbo ::new(). #function_name ((deps, env, gas_used, vec![], vec![]).into(), result, payload) + #contract_turbofish ::new(). #function_name ((deps, env, gas_used, vec![], vec![]).into(), result, payload) } }, _ => quote! { diff --git a/sylvia-derive/src/contract/mt.rs b/sylvia-derive/src/contract/mt.rs index 185614e6..2da8aa17 100644 --- a/sylvia-derive/src/contract/mt.rs +++ b/sylvia-derive/src/contract/mt.rs @@ -533,7 +533,7 @@ impl<'a> MtHelpers<'a> { .as_ref() .map(|_reply| { let contract_ident = get_ident_from_type(contract_name); - let contract_turbo = if !generic_params.is_empty() { + let contract_turbofish = if !generic_params.is_empty() { quote! { #contract_ident ::< #(#generic_params,)* > } } else { quote! { #contract_ident } @@ -541,7 +541,7 @@ impl<'a> MtHelpers<'a> { if cfg!(feature = "sv_replies") { quote! { - let contract = #contract_turbo ::new(); + let contract = #contract_turbofish ::new(); dispatch_reply(deps, env, msg, contract).map_err(Into::into) } } else { diff --git a/sylvia-derive/src/entry_points.rs b/sylvia-derive/src/entry_points.rs index 11591f2a..611c4aff 100644 --- a/sylvia-derive/src/entry_points.rs +++ b/sylvia-derive/src/entry_points.rs @@ -177,7 +177,7 @@ impl<'a> EntryPoints<'a> { let sylvia = crate_module(); let attr_generics = &attrs.generics; - let (contract, contract_turbo) = if attr_generics.is_empty() { + let (contract, contract_turbofish) = if attr_generics.is_empty() { (quote! { #name }, quote! { #name }) } else { ( @@ -202,14 +202,14 @@ impl<'a> EntryPoints<'a> { }; let dispatch = match msg_ty { MsgType::Reply if cfg!(feature = "sv_replies") => quote! { - let contract = #contract_turbo ::new(); + let contract = #contract_turbofish ::new(); sv::dispatch_reply(deps, env, msg, contract).map_err(Into::into) }, MsgType::Reply => quote! { - #contract_turbo ::new(). #reply((deps, env).into(), msg).map_err(Into::into) + #contract_turbofish ::new(). #reply((deps, env).into(), msg).map_err(Into::into) }, _ => quote! { - msg.dispatch(& #contract_turbo ::new() , ( #values )).map_err(Into::into) + msg.dispatch(& #contract_turbofish ::new() , ( #values )).map_err(Into::into) }, };