Skip to content

Commit f44264a

Browse files
committed
Update syn to 2.0
1 parent 40aaee6 commit f44264a

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

scylla-macros/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ license = "MIT OR Apache-2.0"
1212
proc-macro = true
1313

1414
[dependencies]
15-
syn = "1.0"
15+
syn = "2.0"
1616
quote = "1.0"
1717
proc-macro2 = "1.0"

scylla-macros/src/parser.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use syn::{Data, DeriveInput, Fields, FieldsNamed};
2-
use syn::{Lit, Meta};
1+
use syn::{Data, DeriveInput, ExprLit, Fields, FieldsNamed, Lit};
2+
use syn::{Expr, Meta};
33

44
/// Parses the tokens_input to a DeriveInput and returns the struct name from which it derives and
55
/// the named fields
@@ -22,37 +22,37 @@ pub(crate) fn parse_named_fields<'a>(
2222
pub(crate) fn get_path(input: &DeriveInput) -> Result<proc_macro2::TokenStream, syn::Error> {
2323
let mut this_path: Option<proc_macro2::TokenStream> = None;
2424
for attr in input.attrs.iter() {
25-
if !attr.path.is_ident("scylla_crate") {
25+
if !attr.path().is_ident("scylla_crate") {
2626
continue;
2727
}
28-
match attr.parse_meta() {
29-
Ok(Meta::NameValue(meta_name_value)) => {
30-
if let Lit::Str(lit_str) = &meta_name_value.lit {
31-
let path_val = &lit_str.value().parse::<proc_macro2::TokenStream>().unwrap();
28+
match &attr.meta {
29+
Meta::NameValue(name_value) => {
30+
if let Expr::Lit(ExprLit {
31+
lit: Lit::Str(lit), ..
32+
}) = &name_value.value
33+
{
34+
let path = syn::Ident::new(&lit.value(), lit.span());
3235
if this_path.is_none() {
33-
this_path = Some(quote::quote!(#path_val::_macro_internal));
36+
this_path = Some(quote::quote!(#path::_macro_internal));
3437
} else {
3538
return Err(syn::Error::new_spanned(
36-
&meta_name_value.lit,
39+
&name_value.path,
3740
"the `scylla_crate` attribute was set multiple times",
3841
));
3942
}
4043
} else {
4144
return Err(syn::Error::new_spanned(
42-
&meta_name_value.lit,
45+
&name_value.value,
4346
"the `scylla_crate` attribute should be a string literal",
4447
));
4548
}
4649
}
47-
Ok(other) => {
50+
other => {
4851
return Err(syn::Error::new_spanned(
4952
other,
5053
"the `scylla_crate` attribute have a single value",
5154
));
5255
}
53-
Err(err) => {
54-
return Err(err);
55-
}
5656
}
5757
}
5858
Ok(this_path.unwrap_or_else(|| quote::quote!(scylla::_macro_internal)))

0 commit comments

Comments
 (0)