Skip to content

Update syn, quote and proc-macro2 #217

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

Merged
merged 2 commits into from
Apr 10, 2018
Merged
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
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cssparser"
version = "0.23.3"
version = "0.23.4"
authors = [ "Simon Sapin <simon.sapin@exyr.org>" ]

description = "Rust implementation of CSS Syntax Level 3"
Expand Down Expand Up @@ -30,9 +30,9 @@ serde = {version = "1.0", optional = true}
smallvec = "0.6"

[build-dependencies]
syn = { version = "0.12", features = ["extra-traits", "fold"] }
quote = "0.4.1"
proc-macro2 = "0.2"
syn = { version = "0.13", features = ["extra-traits", "fold"] }
quote = "0.5"
proc-macro2 = "0.3"

[features]
bench = []
Expand Down
8 changes: 4 additions & 4 deletions macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cssparser-macros"
version = "0.3.2"
version = "0.3.3"
authors = ["Simon Sapin <simon.sapin@exyr.org>"]
description = "Procedural macros for cssparser"
documentation = "https://docs.rs/cssparser-macros/"
Expand All @@ -14,6 +14,6 @@ proc-macro = true
[dependencies]
procedural-masquerade = {path = "../procedural-masquerade", version = "0.1"}
phf_codegen = "0.7"
quote = "0.4"
syn = {version = "0.12", features = ["full", "extra-traits"]}
proc-macro2 = "0.2"
quote = "0.5"
syn = {version = "0.13", features = ["full", "extra-traits"]}
proc-macro2 = "0.3"
14 changes: 7 additions & 7 deletions macros/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ extern crate proc_macro2;
extern crate syn;

#[allow(unused_imports)] use std::ascii::AsciiExt;
use quote::ToTokens;
use proc_macro2::{TokenNode, TokenStream, TokenTree};
use std::iter;
use proc_macro2::{TokenStream, TokenTree};

define_proc_macros! {
/// Input: the arms of a `match` expression.
Expand All @@ -24,12 +24,12 @@ define_proc_macros! {
pub fn cssparser_internal__assert_ascii_lowercase__max_len(input: &str) -> String {
let expr = syn::parse_str(&format!("match x {{ {} }}", input)).unwrap();
let arms = match expr {
syn::Expr::Match(syn::ExprMatch { ref arms, .. }) => arms,
syn::Expr::Match(syn::ExprMatch { arms, .. }) => arms,
_ => panic!("expected a match expression, got {:?}", expr)
};
max_len(arms.iter().flat_map(|arm| &arm.pats).filter_map(|pattern| {
let expr = match *pattern {
syn::Pat::Lit(ref expr) => expr,
max_len(arms.into_iter().flat_map(|arm| arm.pats).filter_map(|pattern| {
let expr = match pattern {
syn::Pat::Lit(expr) => expr,
syn::Pat::Wild(_) => return None,
_ => panic!("expected string or wildcard pattern, got {:?}", pattern)
};
Expand Down Expand Up @@ -93,6 +93,6 @@ fn max_len<I: Iterator<Item=usize>>(lengths: I) -> String {
}

fn string_literal(token: &TokenTree) -> String {
let lit: syn::LitStr = syn::parse2(token.clone().into()).expect(&format!("expected string literal, got {:?}", token));
let lit: syn::LitStr = syn::parse2(iter::once(token.clone()).collect()).expect(&format!("expected string literal, got {:?}", token));
lit.value()
}