Skip to content

Commit

Permalink
chore: bump syn -> 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kulikthebird committed Jan 18, 2024
1 parent 511d88b commit 63c0b9e
Show file tree
Hide file tree
Showing 8 changed files with 151 additions and 124 deletions.
84 changes: 45 additions & 39 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions sylvia-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ cosmwasm_1_2 = []
proc-macro = true

[dependencies]
syn = { version = "1.0.107", features = [
"parsing",
"derive",
syn = { version = "2.0.48", features = [
"fold",
"visit",
"full",
Expand Down
14 changes: 9 additions & 5 deletions sylvia-derive/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,20 @@ impl<'a> ImplInput<'a> {
let error = item
.attrs
.iter()
.find(|attr| attr.path.is_ident("error"))
.and_then(
|attr| match ContractErrorAttr::parse.parse2(attr.tokens.clone()) {
.find(|attr| attr.path().is_ident("error"))
.and_then(|attr| {
match attr
.meta
.require_list()
.and_then(|meta| ContractErrorAttr::parse.parse2(meta.tokens.clone()))
{
Ok(error) => Some(error.error),
Err(err) => {
emit_error!(attr.span(), err);
None
}
},
)
}
})
.unwrap_or_else(|| parse_quote! { #sylvia ::cw_std::StdError });

let custom = Custom::new(&item.attrs);
Expand Down
8 changes: 6 additions & 2 deletions sylvia-derive/src/interfaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ impl Interfaces {
let interfaces: Vec<_> = source
.attrs
.iter()
.filter(|attr| attr.path.is_ident("messages"))
.filter(|attr| attr.path().is_ident("messages"))
.filter_map(|attr| {
let interface = match ContractMessageAttr::parse.parse2(attr.tokens.clone()) {
let interface = match attr
.meta
.require_list()
.and_then(|meta| ContractMessageAttr::parse.parse2(meta.tokens.clone()))
{
Ok(interface) => interface,
Err(err) => {
emit_error!(attr.span(), err);
Expand Down
33 changes: 24 additions & 9 deletions sylvia-derive/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,16 @@ impl<'a> EnumMessage<'a> {
.items
.iter()
.filter_map(|item| match item {
TraitItem::Method(method) => {
let msg_attr = method.attrs.iter().find(|attr| attr.path.is_ident("msg"))?;
let attr = match MsgAttr::parse.parse2(msg_attr.tokens.clone()) {
TraitItem::Fn(method) => {
let msg_attr = method
.attrs
.iter()

Check warning on line 181 in sylvia-derive/src/message.rs

View check run for this annotation

Codecov / codecov/patch

sylvia-derive/src/message.rs#L180-L181

Added lines #L180 - L181 were not covered by tests
.find(|attr: &&Attribute| attr.path().is_ident("msg"))?;
let attr = match msg_attr
.meta
.require_list()

Check warning on line 185 in sylvia-derive/src/message.rs

View check run for this annotation

Codecov / codecov/patch

sylvia-derive/src/message.rs#L184-L185

Added lines #L184 - L185 were not covered by tests
.and_then(|meta| MsgAttr::parse.parse2(meta.tokens.clone()))
{
Ok(attr) => attr,
Err(err) => {
emit_error!(method.span(), err);
Expand Down Expand Up @@ -841,7 +848,11 @@ where
let variants: Vec<_> = source
.filter_map(|variant_desc| {
let msg_attr = variant_desc.attr_msg()?;
let attr = match MsgAttr::parse.parse2(msg_attr.tokens.clone()) {
let attr = match msg_attr
.meta
.require_list()

Check warning on line 853 in sylvia-derive/src/message.rs

View check run for this annotation

Codecov / codecov/patch

sylvia-derive/src/message.rs#L852-L853

Added lines #L852 - L853 were not covered by tests
.and_then(|meta| MsgAttr::parse.parse2(meta.tokens.clone()))
{
Ok(attr) => attr,
Err(err) => {
emit_error!(variant_desc.span(), err);
Expand Down Expand Up @@ -1621,16 +1632,20 @@ impl<'a> EntryPoints<'a> {
let error = source
.attrs
.iter()
.find(|attr| attr.path.is_ident("error"))
.and_then(
|attr| match ContractErrorAttr::parse.parse2(attr.tokens.clone()) {
.find(|attr| attr.path().is_ident("error"))
.and_then(|attr| {
match attr
.meta
.require_list()
.and_then(|meta| ContractErrorAttr::parse.parse2(meta.tokens.clone()))

Check warning on line 1640 in sylvia-derive/src/message.rs

View check run for this annotation

Codecov / codecov/patch

sylvia-derive/src/message.rs#L1635-L1640

Added lines #L1635 - L1640 were not covered by tests
{
Ok(error) => Some(error.error),
Err(err) => {
emit_error!(attr.span(), err);
None
}
},
)
}
})
.unwrap_or_else(|| parse_quote! { #sylvia ::cw_std::StdError });

let generics: Vec<_> = source.generics.params.iter().collect();
Expand Down
Loading

0 comments on commit 63c0b9e

Please sign in to comment.