Skip to content

Commit

Permalink
Update syn to v2 (#826)
Browse files Browse the repository at this point in the history
  • Loading branch information
CosmicHorrorDev authored Mar 26, 2023
1 parent b98805c commit 9e96a75
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion generator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
19 changes: 10 additions & 9 deletions generator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -128,11 +128,9 @@ fn parse_derive(ast: DeriveInput) -> (Ident, Generics, Vec<GrammarSource>) {
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();

Expand All @@ -149,9 +147,12 @@ fn parse_derive(ast: DeriveInput) -> (Ident, Generics, Vec<GrammarSource>) {
}

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 {
Expand Down

0 comments on commit 9e96a75

Please sign in to comment.