Skip to content

Commit

Permalink
Bump syn to v2.0.38 (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lancern authored Oct 27, 2023
1 parent acfe95c commit 0a2489c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion spdlog-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ proc-macro = true
nom = "7.1.1"
proc-macro2 = "1.0.47"
quote = "1.0.21"
syn = { version = "1.0.103", features = ["full"] }
syn = { version = "2.0.38", features = ["full"] }
3 changes: 1 addition & 2 deletions spdlog-macros/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,7 @@ pub(crate) struct CustomPatternMapping {

impl Parse for CustomPatternMapping {
fn parse(input: ParseStream) -> syn::Result<Self> {
let items: Punctuated<_, Token![,]> =
input.parse_terminated(CustomPatternMappingItem::parse)?;
let items = Punctuated::<CustomPatternMappingItem, Token![,]>::parse_terminated(input)?;

let mapping_pairs = items.into_iter().fold(vec![], |mut prev, item| {
prev.push((item.name, item.factory));
Expand Down
17 changes: 6 additions & 11 deletions spdlog-macros/src/synthesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{

use proc_macro2::{Span, TokenStream};
use quote::ToTokens;
use syn::{punctuated::Punctuated, token::Paren, Expr, ExprLit, ExprTuple, Lit, LitStr, Path};
use syn::{Expr, ExprLit, Lit, LitStr, Path};

use crate::parse::{
PatternTemplate, PatternTemplateFormatter, PatternTemplateLiteral, PatternTemplateStyleRange,
Expand Down Expand Up @@ -126,14 +126,7 @@ impl Synthesiser {
template: &PatternTemplate,
mut style_range_seen: bool,
) -> Result<Expr, SynthesisError> {
let mut template_expr = ExprTuple {
attrs: Vec::new(),
paren_token: Paren {
span: Span::mixed_site(),
},
elems: Punctuated::new(),
};

let mut tuple_elems = Vec::with_capacity(template.tokens.len());
for token in &template.tokens {
let token_template_expr = match token {
PatternTemplateToken::Literal(literal_token) => {
Expand All @@ -150,10 +143,12 @@ impl Synthesiser {
self.build_style_range_template_pattern_expr(style_range_token)?
}
};
template_expr.elems.push(token_template_expr);
tuple_elems.push(token_template_expr);
}

Ok(Expr::Tuple(template_expr))
let stream = quote::quote! { ( #(#tuple_elems ,)* ) };
let expr = syn::parse2(stream).unwrap();
Ok(Expr::Tuple(expr))
}

fn build_literal_template_pattern_expr(
Expand Down

0 comments on commit 0a2489c

Please sign in to comment.