diff --git a/bolos-derive/Cargo.toml b/bolos-derive/Cargo.toml
index 9e29d46..b3fbd52 100644
--- a/bolos-derive/Cargo.toml
+++ b/bolos-derive/Cargo.toml
@@ -9,12 +9,11 @@ edition = "2018"
proc-macro = true
[dependencies]
-syn = { version = "1.0", features = ["full", "extra-traits", "visit"] }
-quote = "1.0"
-proc-macro2 = "1"
-proc-macro-error = { version = "1" }
+syn = { version = "2.0.106", features = ["full", "extra-traits", "visit"] }
+quote = "1.0.40"
+proc-macro2 = "1.0.101"
-convert_case = "0.6"
+convert_case = "0.8.0"
[dev-dependencies]
bolos = { path = "../bolos" }
diff --git a/bolos-derive/src/enum_init.rs b/bolos-derive/src/enum_init.rs
index 1788049..d2fd9c0 100644
--- a/bolos-derive/src/enum_init.rs
+++ b/bolos-derive/src/enum_init.rs
@@ -14,7 +14,6 @@
* limitations under the License.
********************************************************************************/
use proc_macro::TokenStream;
-use proc_macro_error::{abort, abort_if_dirty};
use quote::{quote, ToTokens};
use syn::{
parse_macro_input, parse_quote, parse_quote_spanned, punctuated::Punctuated, token::Comma,
@@ -74,6 +73,7 @@ pub fn enum_init(_metadata: TokenStream, input: TokenStream) -> TokenStream {
&Field {
attrs: variant.attrs.clone(),
vis: Visibility::Inherited,
+ mutability: syn::FieldMutability::None,
ident: None,
colon_token: None,
ty: inner.clone(),
@@ -107,7 +107,7 @@ pub fn enum_init(_metadata: TokenStream, input: TokenStream) -> TokenStream {
let unnamed = &unnamed.unnamed;
if unnamed.len() != 1 {
- abort!(variant.ident.span(), "only 1 item in field supported")
+ panic!("only 1 item in field supported")
} else {
let field = unnamed.first().unwrap();
let variant_struct = create_variant_struct_for_unnamed(
@@ -137,9 +137,6 @@ pub fn enum_init(_metadata: TokenStream, input: TokenStream) -> TokenStream {
}
});
- //if we emitted errors let's abort before we emit weird data
- abort_if_dirty();
-
quote! {
#type_enum
diff --git a/bolos-derive/src/lazy_static.rs b/bolos-derive/src/lazy_static.rs
index 21ec046..e867dae 100644
--- a/bolos-derive/src/lazy_static.rs
+++ b/bolos-derive/src/lazy_static.rs
@@ -17,12 +17,14 @@ use proc_macro::TokenStream;
use proc_macro2::TokenStream as TokenStream2;
use quote::quote;
use syn::{
- parse_macro_input, spanned::Spanned, AttributeArgs, Error, Expr, Ident, ItemStatic, Meta,
- NestedMeta, Token, Type,
+ parse::Parser, parse_macro_input, punctuated::Punctuated, spanned::Spanned, Error, Expr, Ident,
+ ItemStatic, Meta, Token, Type,
};
pub fn lazy_static(metadata: TokenStream, input: TokenStream) -> TokenStream {
- let args = parse_macro_input!(metadata as AttributeArgs);
+ let args = Punctuated::::parse_terminated
+ .parse(metadata)
+ .unwrap();
let input = parse_macro_input!(input as ItemStatic);
let ItemStatic {
@@ -39,7 +41,7 @@ pub fn lazy_static(metadata: TokenStream, input: TokenStream) -> TokenStream {
&name,
*ty,
*expr,
- mutability.is_some(),
+ matches!(mutability, syn::StaticMutability::Mut(_)),
is_cbindgen_mode(&args),
)
.map_err(|e| e.into_compile_error())
@@ -242,9 +244,9 @@ fn produce_custom_ty(
// For example, it will return true for
//#[attr(cbindgen)]
#[allow(clippy::ptr_arg)]
-fn is_cbindgen_mode(args: &AttributeArgs) -> bool {
+fn is_cbindgen_mode(args: &Punctuated) -> bool {
for arg in args {
- if let NestedMeta::Meta(Meta::Path(path)) = arg {
+ if let Meta::Path(path) = arg {
if path
.segments
.iter()
diff --git a/bolos-derive/src/lib.rs b/bolos-derive/src/lib.rs
index aef2b54..587d399 100644
--- a/bolos-derive/src/lib.rs
+++ b/bolos-derive/src/lib.rs
@@ -28,8 +28,6 @@ use proc_macro::TokenStream;
use quote::quote;
use syn::{parse_macro_input, ItemStatic};
-use proc_macro_error::proc_macro_error;
-
pub(crate) mod utils;
// #[bolos::nvm]
@@ -123,7 +121,6 @@ pub fn lazy_static(metadata: TokenStream, input: TokenStream) -> TokenStream {
mod enum_init;
-#[proc_macro_error]
#[proc_macro_attribute]
/// The aim of this macro is to ease the writing of boilerplate for enums
/// where we want to initialize said enum using [`MaybeUninit`].
diff --git a/bolos-derive/src/utils.rs b/bolos-derive/src/utils.rs
index f74d62f..ad52db5 100644
--- a/bolos-derive/src/utils.rs
+++ b/bolos-derive/src/utils.rs
@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
********************************************************************************/
-use proc_macro_error::emit_error;
use syn::{
- punctuated::Punctuated, spanned::Spanned, visit::Visit, Attribute, GenericArgument,
- GenericParam, Generics, Ident, Type, TypePath,
+ punctuated::Punctuated, visit::Visit, Attribute, GenericArgument, GenericParam, Generics,
+ Ident, Type, TypePath,
};
/// Helper extension iterator to `syn` things
@@ -68,7 +67,7 @@ impl<'ast> GenericArgumentsCollector<'ast> {
Type::Array(i) => this.visit_type_array(i),
Type::Path(i) => this.visit_type_path(i),
Type::Tuple(i) => this.visit_type_tuple(i),
- _ => emit_error!(ty.span(), "unsupported type"),
+ _ => panic!("unsupported type"),
}
this
@@ -97,9 +96,9 @@ impl<'ast> GenericArgumentsCollector<'ast> {
impl<'ast> Visit<'ast> for GenericArgumentsCollector<'ast> {
fn visit_parenthesized_generic_arguments(
&mut self,
- i: &'ast syn::ParenthesizedGenericArguments,
+ _i: &'ast syn::ParenthesizedGenericArguments,
) {
- emit_error!(i.span(), "paranthesized generics arguments not supported")
+ panic!("paranthesized generics arguments not supported")
}
fn visit_generic_argument(&mut self, i: &'ast GenericArgument) {
@@ -186,7 +185,7 @@ impl<'ast> Visit<'ast> for GenericParamsCollector<'ast> {
pub fn remove_doc_comment_attributes(attrs: Vec) -> Vec {
attrs
.into_iter()
- .filter(|a| !a.path.is_ident("doc"))
+ .filter(|a| !a.path().is_ident("doc"))
.collect()
}
@@ -196,7 +195,7 @@ pub fn remove_doc_comment_attributes(attrs: Vec) -> Vec {
pub fn cfg_variant_attributes(attrs: Vec) -> Vec {
attrs
.into_iter()
- .filter(|a| a.path.is_ident("cfg"))
+ .filter(|a| a.path().is_ident("cfg"))
.collect()
}