Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump syn to 2.0 #329

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions full-moon-derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "full_moon_derive"
version = "0.11.0"
version = "0.11.1"
authors = ["Kampfkarren <[email protected]>"]
description = "Internally used for the full_moon project. Do not use."
license = "MPL-2.0"
Expand All @@ -14,4 +14,4 @@ proc-macro = true
indexmap = "2.0.2"
proc-macro2 = "1.0"
quote = "1.0"
syn = { version = "1.0.107", features = ["extra-traits"] }
syn = "2.0"
29 changes: 14 additions & 15 deletions full-moon-derive/src/derive.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use proc_macro2::TokenStream;
use quote::{format_ident, quote};
use syn::{parse_macro_input, DeriveInput};
use syn::punctuated::Punctuated;
use syn::{parse_macro_input, DeriveInput, Meta, Token};

pub trait DeriveGenerator: EnumGenerator + StructGenerator {
fn complete(input: &syn::DeriveInput, tokens: TokenStream) -> TokenStream;
Expand Down Expand Up @@ -110,27 +111,25 @@ pub fn search_hint<T: Hint>(name: &str, attrs: &[syn::Attribute]) -> Option<T> {
}

for attr in attrs {
let meta = match attr.parse_meta() {
Ok(meta) => meta,
Err(_) => continue,
};

if path_ident!(meta.path()) != name {
if !attr.path().is_ident(name) {
continue;
};
}

if let syn::Meta::List(list) = meta {
for nested in list.nested {
match nested {
syn::NestedMeta::Meta(syn::Meta::Path(path)) => {
if let Ok(nested) = attr.parse_args_with(Punctuated::<Meta, Token![,]>::parse_terminated) {
for nested_meta in nested {
match nested_meta {
Meta::Path(path) => {
return T::unit(path_ident!(path).to_string());
}

syn::NestedMeta::Meta(syn::Meta::NameValue(name_value)) => {
Meta::NameValue(name_value) => {
return T::key_value(
path_ident!(name_value.path).to_string(),
match name_value.lit {
syn::Lit::Str(lit_str) => lit_str.value(),
match name_value.value {
syn::Expr::Lit(syn::ExprLit {
lit: syn::Lit::Str(lit_str),
..
}) => lit_str.value(),

other => unimplemented!("nested meta value: {:#?}", other),
},
Expand Down
2 changes: 1 addition & 1 deletion full-moon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ no-source-tests = []
bytecount = "0.6"
cfg-if = "1.0"
derive_more = { version = "1.0", features = ["display"] }
full_moon_derive = { path = "../full-moon-derive", version = "=0.11.0" }
full_moon_derive = { path = "../full-moon-derive", version = "=0.11.1" }
paste = "1.0"
serde = { version = "1.0", features = ["derive", "rc"], optional = true }
smol_str = { version = "0.3.1", features = ["serde"] }
Expand Down