Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warnings on contract and contractimpl macros #1344

Merged
merged 3 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions soroban-sdk-macros/src/derive_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ pub fn derive_contract_function_registration_ctor<'a>(

quote! {
#[doc(hidden)]
#[cfg(any(test, feature = "testutils"))]
#[#crate_path::reexports_for_macros::ctor::ctor]
#[allow(non_snake_case)]
fn #ctor_ident() {
#(
<#ty as #crate_path::testutils::ContractFunctionRegister>::register(
Expand Down
2 changes: 2 additions & 0 deletions soroban-sdk-macros/src/derive_spec_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,13 @@ pub fn derive_fn_spec(
Ok(quote! {
#[doc(hidden)]
#[allow(non_snake_case)]
#[allow(non_upper_case_globals)]
#(#attrs)*
#export_attr
pub static #spec_ident: [u8; #spec_xdr_len] = #ty::#spec_fn_ident();

impl #ty {
#[allow(non_snake_case)]
#(#attrs)*
pub const fn #spec_fn_ident() -> [u8; #spec_xdr_len] {
*#spec_xdr_lit
Expand Down
18 changes: 8 additions & 10 deletions soroban-sdk-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ pub fn contract(metadata: TokenStream, input: TokenStream) -> TokenStream {
let ty_str = quote!(#ty).to_string();

let client_ident = format!("{ty_str}Client");
let fn_set_registry_ident = format_ident!("__{ty_str}_fn_set_registry");
let fn_set_registry_ident = format_ident!("__{}_fn_set_registry", ty_str.to_lowercase());
let crate_path = &args.crate_path;
let client = derive_client_type(&args.crate_path, &ty_str, &client_ident);
let mut output = quote! {
Expand Down Expand Up @@ -244,15 +244,13 @@ pub fn contractimpl(metadata: TokenStream, input: TokenStream) -> TokenStream {
#imp
#derived_ok
};
if cfg!(feature = "testutils") {
let cfs = derive_contract_function_registration_ctor(
crate_path,
ty,
trait_ident,
pub_methods.into_iter(),
);
output.extend(quote! { #cfs });
}
let cfs = derive_contract_function_registration_ctor(
dmkozh marked this conversation as resolved.
Show resolved Hide resolved
crate_path,
ty,
trait_ident,
pub_methods.into_iter(),
);
output.extend(quote! { #cfs });
output.into()
}
Err(derived_err) => quote! {
Expand Down
Loading