public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/rust-cssparser] epel10: Bump syn to 0.12, quote to 0.4
@ 2026-06-15 14:13 Igor Gnatenko
  0 siblings, 0 replies; only message in thread
From: Igor Gnatenko @ 2026-06-15 14:13 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : rpms/rust-cssparser
            Branch : epel10
            Commit : 61b72a2d4b2bcbd41bcf449aa7749020c90cfc72
            Author : Igor Gnatenko <ignatenkobrain@fedoraproject.org>
            Date   : 2018-03-09T13:37:06+01:00
            Stats  : +455/-4 in 3 file(s)
            URL    : https://src.fedoraproject.org/rpms/rust-cssparser/c/61b72a2d4b2bcbd41bcf449aa7749020c90cfc72?branch=epel10

            Log:
            Bump syn to 0.12, quote to 0.4

Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>

---
diff --git a/0001-Update-syn-to-0.12-and-quote-to-0.4.patch b/0001-Update-syn-to-0.12-and-quote-to-0.4.patch
new file mode 100644
index 0000000..ba143c0
--- /dev/null
+++ b/0001-Update-syn-to-0.12-and-quote-to-0.4.patch
@@ -0,0 +1,428 @@
+From a244c3c36194a90e8081a1a89bf424a3cc70294d Mon Sep 17 00:00:00 2001
+From: Bastien Orivel <eijebong@bananium.fr>
+Date: Thu, 11 Jan 2018 13:38:20 +0100
+Subject: [PATCH] Update syn to 0.12 and quote to 0.4
+
+---
+ build.rs            |   3 +
+ build/match_byte.rs | 345 +++++++++++++++++++---------------------------------
+ 2 files changed, 129 insertions(+), 219 deletions(-)
+
+diff --git a/build.rs b/build.rs
+index 5c06d29..70339f4 100644
+--- a/build.rs
++++ b/build.rs
+@@ -2,8 +2,11 @@
+  * License, v. 2.0. If a copy of the MPL was not distributed with this
+  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+ 
++#[macro_use]
+ extern crate quote;
++#[macro_use]
+ extern crate syn;
++extern crate proc_macro2;
+ 
+ use std::env;
+ use std::path::Path;
+diff --git a/build/match_byte.rs b/build/match_byte.rs
+index 6680c67..cbf62a5 100644
+--- a/build/match_byte.rs
++++ b/build/match_byte.rs
+@@ -2,83 +2,63 @@
+  * License, v. 2.0. If a copy of the MPL was not distributed with this
+  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+ 
+-use quote::{ToTokens, Tokens};
++use quote::ToTokens;
+ use std::fs::File;
+ use std::io::{Read, Write};
+ use std::path::Path;
+-use std::vec;
+-use std::iter;
+ use syn;
++use syn::fold::Fold;
++
++use proc_macro2::TokenStream;
++
++struct MatchByteParser {
++}
+ 
+ pub fn expand(from: &Path, to: &Path) {
+     let mut source = String::new();
+     File::open(from).unwrap().read_to_string(&mut source).unwrap();
+-    let tts = syn::parse_token_trees(&source).expect("Parsing rules.rs module");
+-    let mut tokens = Tokens::new();
+-    tokens.append_all(expand_tts(tts));
++    let ast = syn::parse_file(&source).expect("Parsing rules.rs module");
++    let mut m = MatchByteParser {};
++    let ast = m.fold_file(ast);
+ 
+-    let code = tokens.to_string().replace("{ ", "{\n").replace(" }", "\n}");
++    let code = ast.into_tokens().to_string().replace("{ ", "{\n").replace(" }", "\n}");
+     File::create(to).unwrap().write_all(code.as_bytes()).unwrap();
+ }
+ 
+-fn expand_tts(tts: Vec<syn::TokenTree>) -> Vec<syn::TokenTree> {
+-    use syn::*;
+-    let mut expanded = Vec::new();
+-    let mut tts = tts.into_iter();
+-    while let Some(tt) = tts.next() {
+-        match tt {
+-            TokenTree::Token(Token::Ident(ident)) => {
+-                if ident != "match_byte" {
+-                    expanded.push(TokenTree::Token(Token::Ident(ident)));
+-                    continue;
+-                }
+-
+-                match tts.next() {
+-                    Some(TokenTree::Token(Token::Not)) => {},
+-                    other => {
+-                        expanded.push(TokenTree::Token(Token::Ident(ident)));
+-                        if let Some(other) = other {
+-                            expanded.push(other);
+-                        }
+-                        continue;
+-                    }
+-                }
+-
+-                let tts = match tts.next() {
+-                    Some(TokenTree::Delimited(Delimited { tts, .. })) => tts,
+-                    other => {
+-                        expanded.push(TokenTree::Token(Token::Ident(ident)));
+-                        expanded.push(TokenTree::Token(Token::Not));
+-                        if let Some(other) = other {
+-                            expanded.push(other);
+-                        }
+-                        continue;
+-                    }
+-                };
++struct MatchByte {
++    expr: syn::Expr,
++    arms: Vec<syn::Arm>,
++}
+ 
+-                let (to_be_matched, table, cases, wildcard_binding) = parse_match_bytes_macro(tts);
+-                let expr = expand_match_bytes_macro(to_be_matched,
+-                                                    &table,
+-                                                    cases,
+-                                                    wildcard_binding);
++impl syn::synom::Synom for MatchByte {
++    named!(parse -> Self, do_parse!(
++        expr: syn!(syn::Expr) >>
++        punct!(,) >>
++        arms: many0!(syn!(syn::Arm)) >> (
++            MatchByte {
++                expr,
++                arms
++            }
++        )
++    ));
++}
+ 
+-                let tts = syn::parse_token_trees(&expr)
+-                    .expect("parsing macro expansion as token trees");
+-                expanded.extend(expand_tts(tts));
++fn get_byte_from_expr_lit(expr: &Box<syn::Expr>) -> u8 {
++    match **expr {
++        syn::Expr::Lit(syn::ExprLit { ref lit, .. }) => {
++            if let syn::Lit::Byte(ref byte) = *lit {
++                byte.value()
+             }
+-            TokenTree::Delimited(Delimited { delim, tts }) => {
+-                expanded.push(TokenTree::Delimited(Delimited {
+-                    delim: delim,
+-                    tts: expand_tts(tts),
+-                }))
++            else {
++                panic!("Found a pattern that wasn't a byte")
+             }
+-            other => expanded.push(other),
+-        }
++        },
++        _ => unreachable!(),
+     }
+-    expanded
+ }
+ 
+-/// Parses a token tree corresponding to the `match_byte` macro.
++
++/// Expand a TokenStream corresponding to the `match_byte` macro.
+ ///
+ /// ## Example
+ ///
+@@ -88,184 +68,111 @@ fn expand_tts(tts: Vec<syn::TokenTree>) -> Vec<syn::TokenTree> {
+ ///     b'0'..b'9' => { ... }
+ ///     b'\n' | b'\\' => { ... }
+ ///     foo => { ... }
+-/// }
+-///
+-/// Returns:
+-///  * The token tree that contains the expression to be matched (in this case
+-///    `tokenizer.next_byte_unchecked()`.
++///  }
++///  ```
+ ///
+-///  * The table with the different cases per byte, each entry in the table
+-///    contains a non-zero integer representing a different arm of the
+-///    match expression.
+-///
+-///  * The list of cases containing the expansion of the arms of the match
+-///    expression.
+-///
+-///  * An optional identifier to which the wildcard pattern is matched (`foo` in
+-///    this case).
+-///
+-fn parse_match_bytes_macro(tts: Vec<syn::TokenTree>) -> (Vec<syn::TokenTree>, [u8; 256], Vec<Case>, Option<syn::Ident>) {
+-    let mut tts = tts.into_iter();
+-
+-    // Grab the thing we're matching, until we find a comma.
+-    let mut left_hand_side = vec![];
+-    loop {
+-        match tts.next() {
+-            Some(syn::TokenTree::Token(syn::Token::Comma)) => break,
+-            Some(other) => left_hand_side.push(other),
+-            None => panic!("Expected not to run out of tokens looking for a comma"),
+-        }
+-    }
+-
+-    let mut cases = vec![];
++fn expand_match_byte(body: &TokenStream) -> syn::Expr {
++    let match_byte: MatchByte = syn::parse2(body.clone()).unwrap();
++    let expr = match_byte.expr;
++    let mut cases = Vec::new();
+     let mut table = [0u8; 256];
+-
+-    let mut tts = tts.peekable();
+-    let mut case_id: u8 = 1;
+-    let mut binding = None;
+-    while tts.len() > 0 {
+-        cases.push(parse_case(&mut tts, &mut table, &mut binding, case_id));
+-
+-        // Allow an optional comma between cases.
+-        match tts.peek() {
+-            Some(&syn::TokenTree::Token(syn::Token::Comma)) => {
+-                tts.next();
+-            },
+-            _ => {},
+-        }
+-
+-        case_id += 1;
+-    }
+-
+-    (left_hand_side, table, cases, binding)
+-}
+-
+-#[derive(Debug)]
+-struct Case(Vec<syn::TokenTree>);
+-
+-/// Parses a single pattern => expression, and returns the case, filling in the
+-/// table with the case id for every byte that matched.
+-///
+-/// The `binding` parameter is the identifier that is used by the wildcard
+-/// pattern.
+-fn parse_case(tts: &mut iter::Peekable<vec::IntoIter<syn::TokenTree>>,
+-              table: &mut [u8; 256],
+-              binding: &mut Option<syn::Ident>,
+-              case_id: u8)
+-              -> Case {
+-    // The last byte checked, as part of this pattern, to properly detect
+-    // ranges.
+-    let mut last_byte: Option<u8> = None;
+-
+-    // Loop through the pattern filling with bytes the table.
+-    loop {
+-        match tts.next() {
+-            Some(syn::TokenTree::Token(syn::Token::Literal(syn::Lit::Byte(byte)))) => {
+-                table[byte as usize] = case_id;
+-                last_byte = Some(byte);
+-            }
+-            Some(syn::TokenTree::Token(syn::Token::BinOp(syn::BinOpToken::Or))) => {
+-                last_byte = None; // This pattern is over.
+-            },
+-            Some(syn::TokenTree::Token(syn::Token::DotDotDot)) => {
+-                assert!(last_byte.is_some(), "Expected closed range!");
+-                match tts.next() {
+-                    Some(syn::TokenTree::Token(syn::Token::Literal(syn::Lit::Byte(byte)))) => {
+-                        for b in last_byte.take().unwrap()..byte {
+-                            if table[b as usize] == 0 {
+-                                table[b as usize] = case_id;
+-                            }
++    let mut match_body = Vec::new();
++    let mut wildcard = None;
++
++    for (i, ref arm) in match_byte.arms.iter().enumerate() {
++        let case_id = i + 1;
++        let index = case_id as isize;
++        let name = syn::Ident::from(format!("Case{}", case_id));
++
++        for pat in &arm.pats {
++            match pat {
++                &syn::Pat::Lit(syn::PatLit{ref expr}) => {
++                    let value = get_byte_from_expr_lit(expr);
++                    if table[value as usize] == 0 {
++                        table[value as usize] = case_id as u8;
++                    }
++                },
++                &syn::Pat::Range(syn::PatRange { ref lo, ref hi, .. }) => {
++                    let lo = get_byte_from_expr_lit(lo);
++                    let hi = get_byte_from_expr_lit(hi);
++                    for value in lo..hi {
++                        if table[value as usize] == 0 {
++                            table[value as usize] = case_id as u8;
+                         }
+-                        if table[byte as usize] == 0 {
+-                            table[byte as usize] = case_id;
++                    }
++                    if table[hi as usize] == 0 {
++                        table[hi as usize] = case_id as u8;
++                    }
++                },
++                &syn::Pat::Wild(_) => {
++                    for byte in table.iter_mut() {
++                        if *byte == 0 {
++                            *byte = case_id as u8;
+                         }
+                     }
+-                    other => panic!("Expected closed range, got: {:?}", other),
+-                }
+-            },
+-            Some(syn::TokenTree::Token(syn::Token::FatArrow)) => break,
+-            Some(syn::TokenTree::Token(syn::Token::Ident(ident))) => {
+-                assert_eq!(last_byte, None, "I don't support ranges with identifiers!");
+-                assert_eq!(*binding, None);
+-                for byte in table.iter_mut() {
+-                    if *byte == 0 {
+-                        *byte = case_id;
++                },
++                &syn::Pat::Ident(syn::PatIdent { ident, .. }) => {
++                    assert_eq!(wildcard, None);
++                    wildcard = Some(ident);
++                    for byte in table.iter_mut() {
++                        if *byte == 0 {
++                            *byte = case_id as u8;
++                        }
+                     }
++                },
++                _ => {
++                    panic!("Unexpected pattern: {:?}. Buggy code ?", pat);
+                 }
+-                *binding = Some(ident)
+             }
+-            Some(syn::TokenTree::Token(syn::Token::Underscore)) => {
+-                assert_eq!(last_byte, None);
+-                for byte in table.iter_mut() {
+-                    if *byte == 0 {
+-                        *byte = case_id;
+-                    }
+-                }
+-            },
+-            other => panic!("Expected literal byte, got: {:?}", other),
+-        }
+-    }
+-
+-    match tts.next() {
+-        Some(syn::TokenTree::Delimited(syn::Delimited { delim: syn::DelimToken::Brace, tts })) => {
+-            Case(tts)
+         }
+-        other => panic!("Expected case with braces after fat arrow, got: {:?}", other),
+-    }
+-}
+-
+-fn expand_match_bytes_macro(to_be_matched: Vec<syn::TokenTree>,
+-                            table: &[u8; 256],
+-                            cases: Vec<Case>,
+-                            binding: Option<syn::Ident>)
+-                            -> String {
+-    use std::fmt::Write;
+-
+-    assert!(!to_be_matched.is_empty());
+-    assert!(table.iter().all(|b| *b != 0), "Incomplete pattern? Bogus code!");
+-
+-    // We build the expression with text since it's easier.
+-    let mut expr = "{\n".to_owned();
+-    expr.push_str("enum Case {\n");
+-    for (i, _) in cases.iter().enumerate() {
+-        write!(&mut expr, "Case{} = {},", i + 1, i + 1).unwrap();
++        cases.push(quote!(#name = #index));
++        let body = &arm.body;
++        match_body.push(quote!(Case::#name => { #body }))
+     }
+-    expr.push_str("}\n"); // enum Case
+-
+-    expr.push_str("static __CASES: [Case; 256] = [");
+-    for byte in table.iter() {
+-        write!(&mut expr, "Case::Case{}, ", *byte).unwrap();
++    let en = quote!(enum Case {
++        #(#cases),*
++    });
++
++    let mut table_content = Vec::new();
++    for entry in table.iter() {
++        let name: syn::Path = syn::parse_str(&format!("Case::Case{}", entry)).unwrap();
++        table_content.push(name);
+     }
+-    expr.push_str("];\n");
++    let table = quote!(static __CASES: [Case; 256] = [#(#table_content),*];);
+ 
+-    let mut tokens = Tokens::new();
+-    let to_be_matched = syn::Delimited {
+-        delim: if binding.is_some() { syn::DelimToken::Brace } else { syn::DelimToken::Paren },
+-        tts: to_be_matched
++    let expr = if let Some(binding) = wildcard {
++        quote!({ #en #table let #binding = #expr; match __CASES[#binding as usize] { #(#match_body),* }})
++    } else {
++        quote!({ #en #table match __CASES[#expr as usize] { #(#match_body),* }})
+     };
+-    to_be_matched.to_tokens(&mut tokens);
+ 
+-    if let Some(ref binding) = binding {
+-        write!(&mut expr, "let {} = {};\n", binding.to_string(), tokens.as_str()).unwrap();
+-    }
++    syn::parse2(expr.into()).unwrap()
++}
+ 
+-    write!(&mut expr, "match __CASES[{} as usize] {{", match binding {
+-        Some(binding) => binding.to_string(),
+-        None => tokens.to_string(),
+-    }).unwrap();
++impl Fold for MatchByteParser {
++    fn fold_stmt(&mut self, stmt: syn::Stmt) -> syn::Stmt {
++        match stmt {
++            syn::Stmt::Item(syn::Item::Macro(syn::ItemMacro{ ref mac, .. })) => {
++                if mac.path == parse_quote!(match_byte) {
++                    return syn::fold::fold_stmt(self, syn::Stmt::Expr(expand_match_byte(&mac.tts)))
++                }
++            },
++            _ => {}
++        }
+ 
+-    for (i, case) in cases.into_iter().enumerate() {
+-        let mut case_tokens = Tokens::new();
+-        let case = syn::Delimited {
+-            delim: syn::DelimToken::Brace,
+-            tts: case.0
+-        };
+-        case.to_tokens(&mut case_tokens);
+-        write!(&mut expr, "Case::Case{} => {},\n", i + 1, case_tokens.as_str()).unwrap();
++        syn::fold::fold_stmt(self, stmt)
+     }
+-    expr.push_str("}\n"); // match
+ 
+-    expr.push_str("}\n"); // top
++    fn fold_expr(&mut self, expr: syn::Expr) -> syn::Expr {
++        match expr {
++            syn::Expr::Macro(syn::ExprMacro{ ref mac, .. }) => {
++                if mac.path == parse_quote!(match_byte) {
++                    return syn::fold::fold_expr(self, expand_match_byte(&mac.tts))
++                }
++            },
++            _ => {}
++        }
+ 
+-    expr
++        syn::fold::fold_expr(self, expr)
++    }
+ }
+-- 
+2.16.2
+

diff --git a/cssparser-0.23.2-fix-metadata.diff b/cssparser-0.23.2-fix-metadata.diff
index 0a53833..a83fd03 100644
--- a/cssparser-0.23.2-fix-metadata.diff
+++ b/cssparser-0.23.2-fix-metadata.diff
@@ -1,5 +1,5 @@
 --- cssparser-0.23.2/Cargo.toml	1970-01-01T01:00:00+01:00
-+++ cssparser-0.23.2/Cargo.toml	2018-01-24T16:33:34.633474+01:00
++++ cssparser-0.23.2/Cargo.toml	2018-03-09T13:36:43.388490+01:00
 @@ -51,7 +51,7 @@
  [dependencies.smallvec]
  version = "0.6"
@@ -9,3 +9,20 @@
  
  [dev-dependencies.encoding_rs]
  version = "0.7"
+@@ -59,10 +59,14 @@
+ [dev-dependencies.rustc-serialize]
+ version = "0.3"
+ [build-dependencies.quote]
+-version = "0.3"
++version = "0.4.1"
++
++[build-dependencies.proc-macro2]
++version = "0.2"
+ 
+ [build-dependencies.syn]
+-version = "0.11"
++version = "0.12"
++features = ["extra-traits", "fold"]
+ 
+ [features]
+ bench = []

diff --git a/rust-cssparser.spec b/rust-cssparser.spec
index afaae54..45def58 100644
--- a/rust-cssparser.spec
+++ b/rust-cssparser.spec
@@ -6,7 +6,7 @@
 
 Name:           rust-%{crate}
 Version:        0.23.2
-Release:        2%{?dist}
+Release:        3%{?dist}
 Summary:        Rust implementation of CSS Syntax Level 3
 
 License:        MPLv2.0
@@ -14,7 +14,9 @@ URL:            https://crates.io/crates/cssparser
 Source0:        https://crates.io/api/v1/crates/%{crate}/%{version}/download#/%{crate}-%{version}.crate
 # Initial patched metadata
 # * Bump difference to 2.0, https://github.com/servo/rust-cssparser/pull/212
+# * Bump syn to 0.12, quote to 0.4, https://github.com/servo/rust-cssparser/commit/a244c3c36194a90e8081a1a89bf424a3cc70294d
 Patch0:         cssparser-0.23.2-fix-metadata.diff
+Patch1:         0001-Update-syn-to-0.12-and-quote-to-0.4.patch
 
 ExclusiveArch:  %{rust_arches}
 
@@ -30,8 +32,9 @@ BuildRequires:  (crate(procedural-masquerade) >= 0.1.0 with crate(procedural-mas
 BuildRequires:  (crate(serde) >= 1.0.0 with crate(serde) < 2.0.0)
 BuildRequires:  (crate(smallvec) >= 0.6.0 with crate(smallvec) < 0.7.0)
 # [build-dependencies]
-BuildRequires:  (crate(quote) >= 0.3.0 with crate(quote) < 0.4.0)
-BuildRequires:  (crate(syn) >= 0.11.0 with crate(syn) < 0.12.0)
+BuildRequires:  (crate(proc-macro2) >= 0.2.0 with crate(proc-macro2) < 0.3.0)
+BuildRequires:  (crate(quote) >= 0.4.1 with crate(quote) < 0.5.0)
+BuildRequires:  ((crate(syn) >= 0.12.0 with crate(syn) < 0.13.0) with crate(syn/extra-traits) with crate(syn/fold))
 %if %{with check}
 # [dev-dependencies]
 BuildRequires:  (crate(difference) >= 2.0.0 with crate(difference) < 3.0.0)
@@ -72,6 +75,9 @@ which use %{crate} from crates.io.
 %{cargo_registry}/%{crate}-%{version}/
 
 %changelog
+* Fri Mar 09 2018 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 0.23.2-3
+- Bump syn to 0.12, quote to 0.4
+
 * Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.23.2-2
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
 

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-06-15 14:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-15 14:13 [rpms/rust-cssparser] epel10: Bump syn to 0.12, quote to 0.4 Igor Gnatenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox