From 9e96a7535bafeec39ab64a4e64179180112d3ad6 Mon Sep 17 00:00:00 2001 From: CosmicHorror Date: Sun, 26 Mar 2023 00:48:52 -0600 Subject: [PATCH] Update syn to v2 (#826) --- generator/Cargo.toml | 2 +- generator/src/lib.rs | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/generator/Cargo.toml b/generator/Cargo.toml index 7b4757ca..b9610a95 100644 --- a/generator/Cargo.toml +++ b/generator/Cargo.toml @@ -22,4 +22,4 @@ pest = { path = "../pest", version = "2.5.6", default-features = false } pest_meta = { path = "../meta", version = "2.5.6" } proc-macro2 = "1.0" quote = "1.0" -syn = "1.0" +syn = "2.0" diff --git a/generator/src/lib.rs b/generator/src/lib.rs index 41129ef6..7aed1936 100644 --- a/generator/src/lib.rs +++ b/generator/src/lib.rs @@ -27,7 +27,7 @@ use std::io::{self, Read}; use std::path::Path; use proc_macro2::TokenStream; -use syn::{Attribute, DeriveInput, Generics, Ident, Lit, Meta}; +use syn::{Attribute, DeriveInput, Expr, ExprLit, Generics, Ident, Lit, Meta}; #[macro_use] mod macros; @@ -128,11 +128,9 @@ fn parse_derive(ast: DeriveInput) -> (Ident, Generics, Vec) { let grammar: Vec<&Attribute> = ast .attrs .iter() - .filter(|attr| match attr.parse_meta() { - Ok(Meta::NameValue(name_value)) => { - name_value.path.is_ident("grammar") || name_value.path.is_ident("grammar_inline") - } - _ => false, + .filter(|attr| { + let path = attr.meta.path(); + path.is_ident("grammar") || path.is_ident("grammar_inline") }) .collect(); @@ -149,9 +147,12 @@ fn parse_derive(ast: DeriveInput) -> (Ident, Generics, Vec) { } fn get_attribute(attr: &Attribute) -> GrammarSource { - match attr.parse_meta() { - Ok(Meta::NameValue(name_value)) => match name_value.lit { - Lit::Str(string) => { + match &attr.meta { + Meta::NameValue(name_value) => match &name_value.value { + Expr::Lit(ExprLit { + lit: Lit::Str(string), + .. + }) => { if name_value.path.is_ident("grammar") { GrammarSource::File(string.value()) } else {