Skip to content
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
6 changes: 3 additions & 3 deletions tests-expanded/test_macros_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
extern crate core;
#[prelude_import]
use core::prelude::rust_2021::*;
use proc_macros::parse_item_fn;
use proc_macros::{parse_item_fn, parse_item_impl};
use soroban_sdk::{contract, contractimpl};
pub struct Contract;
///ContractArgs is a type for building arg lists for functions defined in "Contract".
Expand Down Expand Up @@ -313,9 +313,9 @@ mod test {
ignore: false,
ignore_message: ::core::option::Option::None,
source_file: "tests/macros/src/lib.rs",
start_line: 25usize,
start_line: 26usize,
start_col: 8usize,
end_line: 25usize,
end_line: 26usize,
end_col: 18usize,
compile_fail: false,
no_run: false,
Expand Down
2 changes: 1 addition & 1 deletion tests-expanded/test_macros_wasm32v1-none.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
extern crate core;
#[prelude_import]
use core::prelude::rust_2021::*;
use proc_macros::parse_item_fn;
use proc_macros::{parse_item_fn, parse_item_impl};
use soroban_sdk::{contract, contractimpl};
pub struct Contract;
///ContractArgs is a type for building arg lists for functions defined in "Contract".
Expand Down
9 changes: 8 additions & 1 deletion tests/macros/proc_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
/// soroban-sdk macros are composable and compatible with a variety of other macros.
use proc_macro::TokenStream;
use quote::quote;
use syn::{parse_macro_input, ItemFn};
use syn::{parse_macro_input, ItemFn, ItemImpl};

/// An attribute macro that expects to be used on an impl.
#[proc_macro_attribute]
pub fn parse_item_impl(_metadata: TokenStream, input: TokenStream) -> TokenStream {
let item = parse_macro_input!(input as ItemImpl);
quote! { #item }.into()
}

/// An attribute macro that expects to be used on a function.
#[proc_macro_attribute]
Expand Down
3 changes: 2 additions & 1 deletion tests/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
// validating that they are composable and compatible.

#![no_std]
use proc_macros::parse_item_fn;
use proc_macros::{parse_item_fn, parse_item_impl};
use soroban_sdk::{contract, contractimpl};

#[contract]
pub struct Contract;

#[contractimpl]
#[parse_item_impl]
impl Contract {
// Test that attribute macros that expect to be used on fns are composable with contractimpl.
#[parse_item_fn]
Expand Down