Skip to content

Commit

Permalink
Update syn to 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
OpenByteDev committed Jun 7, 2023
1 parent 473f8ff commit 32efccd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dlopen2-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ license = "MIT"
proc-macro = true

[dependencies]
syn = "1.0"
syn = "2.0"
quote = "1.0"
proc-macro2 = "1.0"
18 changes: 10 additions & 8 deletions dlopen2-derive/src/common.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use syn::{Attribute, Data, DeriveInput, Field, Fields, FieldsNamed, Lit, Meta};
use syn::{Attribute, Data, DeriveInput, Expr, ExprLit, Field, Fields, FieldsNamed, Lit, Meta};

pub fn symbol_name(field: &Field) -> String {
match find_str_attr_val(field, "dlopen2_name") {
Expand All @@ -15,12 +15,14 @@ pub fn symbol_name(field: &Field) -> String {

pub fn find_str_attr_val(field: &Field, attr_name: &str) -> Option<String> {
for attr in field.attrs.iter() {
match attr.parse_meta() {
Ok(Meta::NameValue(ref meta)) => {
match attr.meta {
Meta::NameValue(ref meta) => {
if let Some(ident) = meta.path.get_ident() {
if ident == attr_name {
return match meta.lit {
Lit::Str(ref val, ..) => Some(val.value()),
return match &meta.value {
Expr::Lit(ExprLit {
lit: Lit::Str(val), ..
}) => Some(val.value()),
_ => panic!("{} attribute must be a string", attr_name),
};
}
Expand All @@ -37,7 +39,7 @@ pub fn get_non_marker_attrs(field: &Field) -> Vec<&Attribute> {
.attrs
.iter()
.filter(|attr| {
if let Some(ident) = attr.path.get_ident() {
if let Some(ident) = attr.path().get_ident() {
if ident.to_string().starts_with("dlopen2_") {
return false;
}
Expand All @@ -49,8 +51,8 @@ pub fn get_non_marker_attrs(field: &Field) -> Vec<&Attribute> {

pub fn has_marker_attr(field: &Field, attr_name: &str) -> bool {
for attr in field.attrs.iter() {
match attr.parse_meta() {
Ok(Meta::Path(val)) => {
match attr.meta {
Meta::Path(ref val) => {
if let Some(ident) = val.get_ident() {
return ident == attr_name;
}
Expand Down

0 comments on commit 32efccd

Please sign in to comment.