diff --git a/tests-expanded/test_macros_tests.rs b/tests-expanded/test_macros_tests.rs index 91d7e99b8..19df078f6 100644 --- a/tests-expanded/test_macros_tests.rs +++ b/tests-expanded/test_macros_tests.rs @@ -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". @@ -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, diff --git a/tests-expanded/test_macros_wasm32v1-none.rs b/tests-expanded/test_macros_wasm32v1-none.rs index 27f0c0f87..3bd394e1e 100644 --- a/tests-expanded/test_macros_wasm32v1-none.rs +++ b/tests-expanded/test_macros_wasm32v1-none.rs @@ -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". diff --git a/tests/macros/proc_macros/src/lib.rs b/tests/macros/proc_macros/src/lib.rs index 896a330a6..339fd5ef9 100644 --- a/tests/macros/proc_macros/src/lib.rs +++ b/tests/macros/proc_macros/src/lib.rs @@ -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] diff --git a/tests/macros/src/lib.rs b/tests/macros/src/lib.rs index a95135e71..2347ffe29 100644 --- a/tests/macros/src/lib.rs +++ b/tests/macros/src/lib.rs @@ -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]