Skip to content

Commit

Permalink
Iterate in the correct order, add error to attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
aumetra committed Apr 24, 2024
1 parent 6f7ec50 commit 9ea997f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,17 @@ pub fn entry_point(
}

fn expand_attributes(func: &mut ItemFn) -> syn::Result<TokenStream> {
let mut attributes = std::mem::take(&mut func.attrs);
let attributes = std::mem::take(&mut func.attrs);
let mut stream = TokenStream::new();
while let Some(attribute) = attributes.pop() {
for attribute in attributes {
if !attribute.path().is_ident("set_contract_state_version") {
func.attrs.push(attribute);
continue;
}

if func.sig.ident != "migrate" {
return Err(syn::Error::new_spanned(
&func.sig.ident,
&attribute,
"you only want to add this macro to your migrate function",
));

Check warning on line 135 in packages/derive/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

packages/derive/src/lib.rs#L132-L135

Added lines #L132 - L135 were not covered by tests
}
Expand Down

0 comments on commit 9ea997f

Please sign in to comment.