diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bb3abd85..708b24f2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -105,7 +105,7 @@ jobs: name: Code coverage runs-on: ubuntu-latest container: - image: xd009642/tarpaulin:develop + image: xd009642/tarpaulin:0.27.1 options: --security-opt seccomp=unconfined steps: - name: Checkout sources diff --git a/Cargo.lock b/Cargo.lock index 3fe76bac..b14c33e2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,12 +19,6 @@ version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - [[package]] name = "base16ct" version = "0.2.0" @@ -354,7 +348,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" dependencies = [ "curve25519-dalek", - "hashbrown", + "hashbrown 0.12.3", "hex", "rand_core 0.6.4", "serde", @@ -387,6 +381,12 @@ dependencies = [ "zeroize", ] +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "ff" version = "0.13.0" @@ -445,6 +445,12 @@ dependencies = [ "ahash", ] +[[package]] +name = "hashbrown" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" + [[package]] name = "hex" version = "0.4.3" @@ -462,12 +468,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.9.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ - "autocfg", - "hashbrown", + "equivalent", + "hashbrown 0.14.3", ] [[package]] @@ -539,18 +545,9 @@ checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" [[package]] name = "memchr" -version = "2.5.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" - -[[package]] -name = "nom8" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae01545c9c7fc4486ab7debaf2aad7003ac19431791868fb2e8066df97fad2f8" -dependencies = [ - "memchr", -] +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "once_cell" @@ -576,9 +573,9 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66618389e4ec1c7afe67d51a9bf34ff9236480f8d51e7489b7d5ab0303c13f34" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", "toml_edit", @@ -610,9 +607,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.69" +version = "1.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" dependencies = [ "unicode-ident", ] @@ -637,14 +634,14 @@ dependencies = [ "itertools 0.11.0", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] name = "quote" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -768,7 +765,7 @@ checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -879,7 +876,7 @@ dependencies = [ "proc-macro2", "quote", "sylvia-runtime-macros", - "syn 1.0.107", + "syn 2.0.48", ] [[package]] @@ -906,9 +903,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.39" +version = "2.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" dependencies = [ "proc-macro2", "quote", @@ -932,24 +929,24 @@ checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] name = "toml_datetime" -version = "0.5.1" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4553f467ac8e3d374bc9a177a26801e5d0f9b211aa1673fb137a403afd1c9cf5" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" [[package]] name = "toml_edit" -version = "0.18.1" +version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56c59d8dd7d0dcbc6428bf7aa2f0e823e26e43b3c9aca15bbc9475d23e5fa12b" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ "indexmap", - "nom8", "toml_datetime", + "winnow", ] [[package]] @@ -982,6 +979,15 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "winnow" +version = "0.5.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7cf47b659b318dccbd69cc4797a39ae128f533dce7902a1096044d1967b9c16" +dependencies = [ + "memchr", +] + [[package]] name = "zeroize" version = "1.5.7" diff --git a/examples/Cargo.lock b/examples/Cargo.lock index fbe60c45..4f5b49af 100644 --- a/examples/Cargo.lock +++ b/examples/Cargo.lock @@ -843,9 +843,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.69" +version = "1.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" dependencies = [ "unicode-ident", ] @@ -870,14 +870,14 @@ dependencies = [ "itertools 0.11.0", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] name = "quote" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -1001,7 +1001,7 @@ checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -1108,7 +1108,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.48", ] [[package]] @@ -1124,9 +1124,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.39" +version = "2.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" dependencies = [ "proc-macro2", "quote", @@ -1150,7 +1150,7 @@ checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -1227,7 +1227,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", "wasm-bindgen-shared", ] @@ -1249,7 +1249,7 @@ checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", "wasm-bindgen-backend", "wasm-bindgen-shared", ] diff --git a/sylvia-derive/Cargo.toml b/sylvia-derive/Cargo.toml index ebbcdf9e..7c6d084c 100644 --- a/sylvia-derive/Cargo.toml +++ b/sylvia-derive/Cargo.toml @@ -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", diff --git a/sylvia-derive/src/input.rs b/sylvia-derive/src/input.rs index 839702cc..873987d2 100644 --- a/sylvia-derive/src/input.rs +++ b/sylvia-derive/src/input.rs @@ -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); diff --git a/sylvia-derive/src/interfaces.rs b/sylvia-derive/src/interfaces.rs index fbfe9718..31c92be2 100644 --- a/sylvia-derive/src/interfaces.rs +++ b/sylvia-derive/src/interfaces.rs @@ -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); diff --git a/sylvia-derive/src/message.rs b/sylvia-derive/src/message.rs index 2ac57d84..198b21b8 100644 --- a/sylvia-derive/src/message.rs +++ b/sylvia-derive/src/message.rs @@ -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() + .find(|attr: &&Attribute| attr.path().is_ident("msg"))?; + let attr = match msg_attr + .meta + .require_list() + .and_then(|meta| MsgAttr::parse.parse2(meta.tokens.clone())) + { Ok(attr) => attr, Err(err) => { emit_error!(method.span(), err); @@ -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() + .and_then(|meta| MsgAttr::parse.parse2(meta.tokens.clone())) + { Ok(attr) => attr, Err(err) => { emit_error!(variant_desc.span(), err); @@ -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())) + { 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(); diff --git a/sylvia-derive/src/parser.rs b/sylvia-derive/src/parser.rs index 5f80d0a0..0fb39c63 100644 --- a/sylvia-derive/src/parser.rs +++ b/sylvia-derive/src/parser.rs @@ -6,8 +6,8 @@ use syn::parse::{Error, Nothing, Parse, ParseBuffer, ParseStream, Parser}; use syn::punctuated::Punctuated; use syn::spanned::Spanned; use syn::{ - parenthesized, parse_quote, Attribute, GenericArgument, Ident, ImplItem, ImplItemMethod, - ItemImpl, ItemTrait, Path, PathArguments, Result, Token, TraitItem, Type, + parenthesized, parse_quote, Attribute, GenericArgument, Ident, ImplItem, ImplItemFn, ItemImpl, + ItemTrait, Path, PathArguments, Result, Token, TraitItem, Type, }; use crate::crate_module; @@ -205,7 +205,7 @@ impl PartialEq for MsgAttr { } impl MsgAttr { - fn parse_query(content: ParseBuffer) -> Result { + fn parse_query(content: &ParseBuffer) -> Result { if content.peek2(Ident) { let _: Punct = content.parse()?; let _: Ident = content.parse()?; @@ -232,25 +232,23 @@ impl MsgAttr { impl Parse for MsgAttr { fn parse(input: ParseStream) -> Result { - let content; - parenthesized!(content in input); + let ty: Ident = input.parse()?; - let ty: Ident = content.parse()?; if ty == "exec" { Ok(Self::Exec) } else if ty == "query" { - Self::parse_query(content) + Self::parse_query(input) } else if ty == "instantiate" { - let name = Ident::new("InstantiateMsg", content.span()); + let name = Ident::new("InstantiateMsg", input.span()); Ok(Self::Instantiate { name }) } else if ty == "migrate" { - let name = Ident::new("MigrateMsg", content.span()); + let name = Ident::new("MigrateMsg", input.span()); Ok(Self::Migrate { name }) } else if ty == "reply" { Ok(Self::Reply) } else { Err(Error::new( - ty.span(), + input.span(), "Invalid message type, expected one of: `exec`, `query`, `instantiate`, `migrate`", )) } @@ -266,10 +264,7 @@ pub struct ContractErrorAttr { // False negative. It is being called in closure impl Parse for ContractErrorAttr { fn parse(input: ParseStream) -> Result { - let content; - parenthesized!(content in input); - - content.parse().map(|error| Self { error }) + input.parse().map(|error| Self { error }) } } @@ -350,21 +345,18 @@ fn extract_generics_from_path(module: &Path) -> Punctuated Result { - let content; - parenthesized!(content in input); - - let module = content.parse()?; + let module = input.parse()?; let generics = extract_generics_from_path(&module); let module = StripGenerics.fold_path(module); - let _: Token![as] = content.parse()?; - let variant = content.parse()?; + let _: Token![as] = input.parse()?; + let variant = input.parse()?; - let customs = interface_has_custom(&content)?; + let customs = interface_has_custom(input)?; - if !content.is_empty() { + if !input.is_empty() { return Err(Error::new( - content.span(), + input.span(), "Unexpected token on the end of `message` attribtue", )); } @@ -378,11 +370,19 @@ impl Parse for ContractMessageAttr { } } -pub fn parse_struct_message(source: &ItemImpl, ty: MsgType) -> Option<(&ImplItemMethod, MsgAttr)> { +pub fn parse_struct_message(source: &ItemImpl, ty: MsgType) -> Option<(&ImplItemFn, MsgAttr)> { let mut methods = source.items.iter().filter_map(|item| match item { - ImplItem::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()) { + ImplItem::Fn(method) => { + let msg_attr = method + .attrs + .iter() + .find(|attr| attr.path().is_ident("msg"))?; + + let attr = match msg_attr + .meta + .require_list() + .and_then(|meta| MsgAttr::parse.parse2(meta.tokens.clone())) + { Ok(attr) => attr, Err(err) => { emit_error!(method.span(), err); @@ -444,7 +444,11 @@ impl<'a> Custom<'a> { None => false, }) .filter_map(|attr| { - let custom = match Custom::parse.parse2(attr.tokens.clone()) { + let custom = match attr + .meta + .require_list() + .and_then(|meta| Custom::parse.parse2(meta.tokens.clone())) + { Ok(mut custom) => { custom.input_attr = Some(attr); custom @@ -498,27 +502,25 @@ impl<'a> Custom<'a> { // False negative. It is being called in closure impl Parse for Custom<'_> { fn parse(input: ParseStream) -> Result { - let content; - parenthesized!(content in input); let mut custom = Self::default(); - while !content.is_empty() { - let ty: Ident = content.parse()?; - let _: Token![=] = content.parse()?; + while !input.is_empty() { + let ty: Ident = input.parse()?; + let _: Token![=] = input.parse()?; if ty == "msg" { - custom.msg = Some(content.parse()?) + custom.msg = Some(input.parse()?) } else if ty == "query" { - custom.query = Some(content.parse()?) + custom.query = Some(input.parse()?) } else { return Err(Error::new( ty.span(), "Invalid custom type. Expected msg or query", )); }; - if !content.peek(Token![,]) { + if !input.peek(Token![,]) { break; } - let _: Token![,] = content.parse()?; + let _: Token![,] = input.parse()?; } Ok(custom) @@ -562,15 +564,19 @@ impl OverrideEntryPoints { Some(attr) => attr == "override_entry_point", None => false, }) - .filter_map( - |attr| match OverrideEntryPoint::parse.parse2(attr.tokens.clone()) { + .filter_map(|attr| { + match attr + .meta + .require_list() + .and_then(|meta| OverrideEntryPoint::parse.parse2(meta.tokens.clone())) + { Ok(entry_point) => Some(entry_point), Err(err) => { emit_error!(attr.span(), err); None } - }, - ) + } + }) .collect(); Self(entry_points) @@ -585,15 +591,12 @@ impl OverrideEntryPoints { // False negative. It is being called in closure impl Parse for OverrideEntryPoint { fn parse(input: ParseStream) -> Result { - let content; - parenthesized!(content in input); - - let ty: Ident = content.parse()?; - let _: Token![=] = content.parse()?; - let entry_point = content.parse()?; + let ty: Ident = input.parse()?; + let _: Token![=] = input.parse()?; + let entry_point = input.parse()?; let msg_content; - parenthesized!(msg_content in content); + parenthesized!(msg_content in input); let msg_name = msg_content.parse()?; @@ -621,8 +624,8 @@ impl Parse for OverrideEntryPoint { } pub fn sylvia_attribute(attr: &Attribute) -> Option<&Ident> { - if attr.path.segments.len() == 2 && attr.path.segments[0].ident == "sv" { - Some(&attr.path.segments[1].ident) + if attr.path().segments.len() == 2 && attr.path().segments[0].ident == "sv" { + Some(&attr.path().segments[1].ident) } else { None } diff --git a/sylvia-derive/src/strip_input.rs b/sylvia-derive/src/strip_input.rs index 4fd4b772..96fe1b1c 100644 --- a/sylvia-derive/src/strip_input.rs +++ b/sylvia-derive/src/strip_input.rs @@ -1,8 +1,7 @@ use syn::fold::{self, Fold}; use syn::punctuated::Punctuated; use syn::{ - FnArg, ImplItemMethod, ItemImpl, ItemTrait, PatType, Receiver, Signature, Token, - TraitItemMethod, + FnArg, ImplItemFn, ItemImpl, ItemTrait, PatType, Receiver, Signature, Token, TraitItemFn, }; use crate::parser::sylvia_attribute; @@ -34,28 +33,28 @@ fn remove_input_attr(inputs: Punctuated) -> Punctuated TraitItemMethod { + fn fold_trait_item_fn(&mut self, i: TraitItemFn) -> TraitItemFn { let attrs = i .attrs .into_iter() - .filter(|attr| !attr.path.is_ident("msg")) + .filter(|attr| !attr.path().is_ident("msg")) .collect(); let inputs = remove_input_attr(i.sig.inputs); let sig = Signature { inputs, ..i.sig }; - fold::fold_trait_item_method(self, TraitItemMethod { attrs, sig, ..i }) + fold::fold_trait_item_fn(self, TraitItemFn { attrs, sig, ..i }) } - fn fold_impl_item_method(&mut self, i: ImplItemMethod) -> ImplItemMethod { + fn fold_impl_item_fn(&mut self, i: ImplItemFn) -> ImplItemFn { let attrs = i .attrs .into_iter() - .filter(|attr| !attr.path.is_ident("msg")) + .filter(|attr| !attr.path().is_ident("msg")) .collect(); let inputs = remove_input_attr(i.sig.inputs); let sig = Signature { inputs, ..i.sig }; - fold::fold_impl_item_method(self, ImplItemMethod { attrs, sig, ..i }) + fold::fold_impl_item_fn(self, ImplItemFn { attrs, sig, ..i }) } fn fold_item_trait(&mut self, i: ItemTrait) -> ItemTrait { @@ -73,8 +72,8 @@ impl Fold for StripInput { .attrs .into_iter() .filter(|attr| { - !(attr.path.is_ident("messages") - || attr.path.is_ident("error") + !(attr.path().is_ident("messages") + || attr.path().is_ident("error") || sylvia_attribute(attr).is_some()) }) .collect(); diff --git a/sylvia-derive/src/variant_descs.rs b/sylvia-derive/src/variant_descs.rs index 111b2a59..827421bc 100644 --- a/sylvia-derive/src/variant_descs.rs +++ b/sylvia-derive/src/variant_descs.rs @@ -18,12 +18,10 @@ impl<'a> VariantDesc<'a> { } pub fn attr_msg(&self) -> Option<&Attribute> { - self.attrs.iter().find(|attr| attr.path.is_ident("msg")) + self.attrs.iter().find(|attr| attr.path().is_ident("msg")) } -} -impl Spanned for VariantDesc<'_> { - fn span(&self) -> Span { + pub fn span(&self) -> Span { self.span } } @@ -46,7 +44,7 @@ impl AsVariantDescs for ItemImpl { fn as_variants(&self) -> Self::Iter<'_> { Box::new(self.items.iter().filter_map(|item| match item { - ImplItem::Method(method) => { + ImplItem::Fn(method) => { Some(VariantDesc::new(&method.attrs, &method.sig, method.span())) } _ => None, @@ -59,7 +57,7 @@ impl AsVariantDescs for ItemTrait { fn as_variants(&self) -> Self::Iter<'_> { Box::new(self.items.iter().filter_map(|item| match item { - TraitItem::Method(method) => { + TraitItem::Fn(method) => { Some(VariantDesc::new(&method.attrs, &method.sig, method.span())) } _ => None,