Skip to content

Commit

Permalink
Upgrade to syn 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
chifflier committed Apr 5, 2023
1 parent ad6c4cf commit df44b67
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ serialize = ["cookie-factory"]
std = []

[dependencies]
asn1-rs-derive = { version="0.4", path="./derive" }
asn1-rs-impl = { version="0.1", path="./impl" }
asn1-rs-derive = { version="0.5", path="./derive" }
asn1-rs-impl = { version="0.2", path="./impl" }
bitvec = { version="1.0", optional=true }
cookie-factory = { version="0.3.0", optional=true }
displaydoc = "0.2.2"
Expand Down
6 changes: 3 additions & 3 deletions derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "asn1-rs-derive"
version = "0.4.0"
version = "0.5.0"
authors = ["Pierre Chifflier <chifflier@wzdftpd.net>"]
description = "Derive macros for the `asn1-rs` crate"
license = "MIT/Apache-2.0"
Expand All @@ -14,5 +14,5 @@ proc-macro = true
[dependencies]
proc-macro2 = "1.0"
quote = "1.0"
syn = { version="1.0", features = ["full"] }
synstructure = "0.12"
syn = { version = "2.0", features = ["full"] }
synstructure = "0.13"
6 changes: 4 additions & 2 deletions derive/src/alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ pub fn derive_ber_alias(s: synstructure::Structure) -> proc_macro2::TokenStream
};

let debug_derive = ast.attrs.iter().any(|attr| {
attr.path
attr.meta
.path()
.is_ident(&Ident::new("debug_derive", Span::call_site()))
});

Expand All @@ -39,7 +40,8 @@ pub fn derive_der_alias(s: synstructure::Structure) -> proc_macro2::TokenStream
};

let debug_derive = ast.attrs.iter().any(|attr| {
attr.path
attr.meta
.path()
.is_ident(&Ident::new("debug_derive", Span::call_site()))
});
let impl_tryfrom = container.gen_tryfrom();
Expand Down
12 changes: 8 additions & 4 deletions derive/src/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ impl Container {
let error = ast
.attrs
.iter()
.find(|attr| attr.path.is_ident(&Ident::new("error", Span::call_site())))
.find(|attr| {
attr.meta
.path()
.is_ident(&Ident::new("error", Span::call_site()))
})
.cloned();

Container {
Expand Down Expand Up @@ -326,7 +330,7 @@ impl From<&Field> for FieldInfo {
.as_ref()
.map_or_else(|| Ident::new("_", Span::call_site()), |s| s.clone());
for attr in &field.attrs {
let ident = match attr.path.get_ident() {
let ident = match attr.meta.path().get_ident() {
Some(ident) => ident.to_string(),
None => continue,
};
Expand Down Expand Up @@ -476,8 +480,8 @@ fn get_field_parser(f: &FieldInfo, asn1_type: Asn1Type, custom_errors: bool) ->
}

fn get_attribute_meta(attr: &Attribute) -> Result<TokenStream, syn::Error> {
if let Ok(Meta::List(meta)) = attr.parse_meta() {
let content = &meta.nested;
if let Meta::List(meta) = &attr.meta {
let content = &meta.tokens;
Ok(quote! { #content })
} else {
Err(syn::Error::new(
Expand Down
6 changes: 4 additions & 2 deletions derive/src/sequence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ pub fn derive_ber_sequence(s: synstructure::Structure) -> proc_macro2::TokenStre
};

let debug_derive = ast.attrs.iter().any(|attr| {
attr.path
attr.meta
.path()
.is_ident(&Ident::new("debug_derive", Span::call_site()))
});

Expand All @@ -39,7 +40,8 @@ pub fn derive_der_sequence(s: synstructure::Structure) -> proc_macro2::TokenStre
};

let debug_derive = ast.attrs.iter().any(|attr| {
attr.path
attr.meta
.path()
.is_ident(&Ident::new("debug_derive", Span::call_site()))
});
let impl_tryfrom = container.gen_tryfrom();
Expand Down
6 changes: 4 additions & 2 deletions derive/src/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ pub fn derive_ber_set(s: synstructure::Structure) -> proc_macro2::TokenStream {
};

let debug_derive = ast.attrs.iter().any(|attr| {
attr.path
attr.meta
.path()
.is_ident(&Ident::new("debug_derive", Span::call_site()))
});

Expand All @@ -39,7 +40,8 @@ pub fn derive_der_set(s: synstructure::Structure) -> proc_macro2::TokenStream {
};

let debug_derive = ast.attrs.iter().any(|attr| {
attr.path
attr.meta
.path()
.is_ident(&Ident::new("debug_derive", Span::call_site()))
});
let impl_tryfrom = container.gen_tryfrom();
Expand Down
4 changes: 2 additions & 2 deletions impl/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "asn1-rs-impl"
version = "0.1.0"
version = "0.2.0"
authors = ["Pierre Chifflier <chifflier@wzdftpd.net>"]
description = "Implementation details for the `asn1-rs` crate"
license = "MIT/Apache-2.0"
Expand All @@ -14,4 +14,4 @@ proc-macro = true
[dependencies]
proc-macro2 = "1"
quote = "1"
syn = "1"
syn = "2.0"

0 comments on commit df44b67

Please sign in to comment.