Commit 94eeb16e authored by Emilio Cobos Álvarez's avatar Emilio Cobos Álvarez
Browse files

Bug 1587468 - Update cssparser to v0.25.9. r=boris

Differential Revision: https://phabricator.services.mozilla.com/D48727

--HG--
extra : moz-landing-system : lando
parent ad570ba4
......@@ -160,7 +160,7 @@ dependencies = [
[[package]]
name = "autocfg"
version = "0.1.2"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
......@@ -701,19 +701,20 @@ dependencies = [
[[package]]
name = "cssparser"
version = "0.25.7"
version = "0.25.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser-macros 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"dtoa-short 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"itoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"phf 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"procedural-masquerade 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
......@@ -1168,7 +1169,7 @@ name = "geckoservo"
version = "0.0.1"
dependencies = [
"atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.25.7 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.25.9 (registry+https://github.com/rust-lang/crates.io-index)",
"cstr 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -1672,7 +1673,7 @@ name = "malloc_size_of"
version = "0.0.1"
dependencies = [
"app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.25.7 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.25.9 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"hashglobe 0.1.0",
"selectors 0.21.0",
......@@ -2336,7 +2337,7 @@ name = "rand"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -2354,7 +2355,7 @@ name = "rand_chacha"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
......@@ -2415,7 +2416,7 @@ name = "rand_pcg"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
......@@ -2662,7 +2663,7 @@ name = "selectors"
version = "0.21.0"
dependencies = [
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.25.7 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.25.9 (registry+https://github.com/rust-lang/crates.io-index)",
"derive_more 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
"fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -2912,7 +2913,7 @@ dependencies = [
"bindgen 0.51.1 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.25.7 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.25.9 (registry+https://github.com/rust-lang/crates.io-index)",
"derive_more 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"fallible 0.0.1",
......@@ -2975,7 +2976,7 @@ version = "0.0.1"
dependencies = [
"app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.25.7 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.25.9 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"malloc_size_of 0.0.1",
......@@ -2991,7 +2992,7 @@ name = "stylo_tests"
version = "0.0.1"
dependencies = [
"atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.25.7 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.25.9 (registry+https://github.com/rust-lang/crates.io-index)",
"cstr 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"geckoservo 0.0.1",
......@@ -3159,7 +3160,7 @@ dependencies = [
name = "to_shmem"
version = "0.0.1"
dependencies = [
"cssparser 0.25.7 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.25.9 (registry+https://github.com/rust-lang/crates.io-index)",
"servo_arc 0.1.1",
"smallbitvec 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -3816,7 +3817,7 @@ dependencies = [
"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652"
"checksum audio_thread_priority 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4c1e4aab7f57d8334168073cd0d0f11c7d1f7f3aabef84a1733a42629d0da80c"
"checksum authenticator 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ec149e5d5d4caa2c9ead53a8ce1ea9c4204c388c65bf3b96c2d1dc0fcf4aeb66"
"checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799"
"checksum autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b671c8fb71b457dd4ae18c4ba1e59aa81793daacc361d82fcd410cef0d491875"
"checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a"
"checksum backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c66d56ac8dabd07f6aacdaf633f4b8262f5b3601a810a0dcddffd5c22c69daa0"
"checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e"
......@@ -3864,7 +3865,7 @@ dependencies = [
"checksum crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fedcd6772e37f3da2a9af9bf12ebe046c0dfe657992377b4df982a2b54cd37a9"
"checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b"
"checksum crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f8306fcef4a7b563b76b7dd949ca48f52bc1141aa067d2ea09565f3e2652aa5c"
"checksum cssparser 0.25.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a921abc45ea75c2c817d951caeda31b94539d09a6b5e8d58a857b3b35c9c3894"
"checksum cssparser 0.25.9 (registry+https://github.com/rust-lang/crates.io-index)" = "fbe18ca4efb9ba3716c6da66cc3d7e673bf59fa576353011f48c4cfddbdd740e"
"checksum cssparser-macros 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "b16e382d9b983fdb9ac6a36b37fdeb84ce3ea81f749febfee3463cfa7f24275e"
"checksum cstr 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b6557bdb1dc9647eae1cf7f5601b14cd45fc3c7ccf2df618387416fe542da6ea"
"checksum cstr-macros 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0f12dd847ec773fc98d75edba5394cb87d0f35e7ee548a4c81849ca6374b3d48"
......
{"files":{"Cargo.toml":"59b541962c15f51087a11d7296e3b69ec6d9b8a8e9e8db949e7629ea28183564","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"27995d58ad5c1145c1a8cd86244ce844886958a35eb2b78c6b772748669999ac","README.md":"d0e320dccace525a2cbcf3bc5d43ac9b7b61ee86b9c9713bf68993c3ad789d0a","examples/integers.rs":"589ff4271566dfa322becddf3e2c7b592e6e0bc97b02892ce75619b7e452e930","examples/paths.rs":"1b30e466b824ce8df7ad0a55334424131d9d2573d6cf9f7d5d50c09c8901d526","examples/traits.rs":"cbee6a3e1f7db60b02ae25b714926517144a77cb492021f492774cf0e1865a9e","examples/versions.rs":"38535e6d9f5bfae0de474a3db79a40e8f5da8ba9334c5ff4c363de9bc99d4d12","src/error.rs":"12de7dafea4a35d1dc2f0fa79bfa038386bbbea72bf083979f4ddf227999eeda","src/lib.rs":"7392068683dc86107bcf8073c81ff8fb7026f5fb98a355a4d47301c5946eeccb","src/tests.rs":"34bdceeffdbdd7f2535a6ed8272482b17325dba044c91bb96f3f8caeec58a83d","src/version.rs":"165324950f2195aaf068c47a4f2f0992b2bf18d8b7f4f17b6b264767523c0e5d"},"package":"a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799"}
\ No newline at end of file
{"files":{"Cargo.lock":"461e5e87b13d7faf25813b08b5003060c39d8af0953f30d5b80ae0926c888022","Cargo.toml":"1eded5c9954b3bb92bb2c7403e026198e66a2a42199db06fc9cafddc8d1fd677","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"27995d58ad5c1145c1a8cd86244ce844886958a35eb2b78c6b772748669999ac","README.md":"ba9a1621483e0b9f017f07c282d00d5cf3a2d8660cca6df6b14941319d748953","examples/integers.rs":"589ff4271566dfa322becddf3e2c7b592e6e0bc97b02892ce75619b7e452e930","examples/paths.rs":"1b30e466b824ce8df7ad0a55334424131d9d2573d6cf9f7d5d50c09c8901d526","examples/traits.rs":"cbee6a3e1f7db60b02ae25b714926517144a77cb492021f492774cf0e1865a9e","examples/versions.rs":"38535e6d9f5bfae0de474a3db79a40e8f5da8ba9334c5ff4c363de9bc99d4d12","src/error.rs":"12de7dafea4a35d1dc2f0fa79bfa038386bbbea72bf083979f4ddf227999eeda","src/lib.rs":"411d8dbc48ab0f67cb10243f1e16b235407818c96556c838182e4004da995dff","src/tests.rs":"0b1353344e832553d328c47f1639ced877b5dff70fd2024d84130bd1c33eee07","src/version.rs":"175727d5f02f2fe2271ddc9b041db2a5b9c6fe0f95afd17c73a4d982612764a3"},"package":"b671c8fb71b457dd4ae18c4ba1e59aa81793daacc361d82fcd410cef0d491875"}
\ No newline at end of file
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "autocfg"
version = "0.1.6"
......@@ -3,7 +3,7 @@
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g. crates.io) dependencies
# to registry (e.g., crates.io) dependencies
#
# If you believe there's an error in this file please file an
# issue against the rust-lang/cargo repository. If you're
......@@ -12,7 +12,7 @@
[package]
name = "autocfg"
version = "0.1.2"
version = "0.1.6"
authors = ["Josh Stone <cuviper@gmail.com>"]
description = "Automatic cfg for Rust compiler features"
readme = "README.md"
......
......@@ -43,7 +43,20 @@ should only be used when the compiler supports it.
## Release Notes
- 0.1.2 (2018-01-16)
- 0.1.6 (2019-08-19)
- Add `probe`/`emit_sysroot_crate`, by @leo60228
- 0.1.5 (2019-07-16)
- Mask some warnings from newer rustc.
- 0.1.4 (2019-05-22)
- Relax `std`/`no_std` probing to a warning instead of an error.
- Improve `rustc` bootstrap compatibility.
- 0.1.3 (2019-05-21)
- Auto-detects if `#![no_std]` is needed for the `$TARGET`
- 0.1.2 (2019-01-16)
- Add `rerun_env(ENV)` to print `cargo:rerun-if-env-changed=ENV`
- Add `rerun_path(PATH)` to print `cargo:rerun-if-changed=PATH`
......
......@@ -36,13 +36,20 @@
#![deny(missing_debug_implementations)]
#![deny(missing_docs)]
// allow future warnings that can't be fixed while keeping 1.0 compatibility
#![allow(unknown_lints)]
#![allow(bare_trait_objects)]
#![allow(ellipsis_inclusive_range_patterns)]
use std::env;
use std::ffi::OsString;
use std::fs;
use std::io::Write;
use std::io::{stderr, Write};
use std::path::PathBuf;
use std::process::{Command, Stdio};
#[allow(deprecated)]
use std::sync::atomic::ATOMIC_USIZE_INIT;
use std::sync::atomic::{AtomicUsize, Ordering};
mod error;
pub use error::Error;
......@@ -60,6 +67,7 @@ pub struct AutoCfg {
rustc: PathBuf,
rustc_version: Version,
target: Option<OsString>,
no_std: bool,
}
/// Writes a config flag for rustc on standard out.
......@@ -137,12 +145,25 @@ impl AutoCfg {
return Err(error::from_str("output path is not a writable directory"));
}
Ok(AutoCfg {
let mut ac = AutoCfg {
out_dir: dir,
rustc: rustc,
rustc_version: rustc_version,
target: env::var_os("TARGET"),
})
no_std: false,
};
// Sanity check with and without `std`.
if !ac.probe("").unwrap_or(false) {
ac.no_std = true;
if !ac.probe("").unwrap_or(false) {
// Neither worked, so assume nothing...
ac.no_std = false;
let warning = b"warning: autocfg could not probe for `std`\n";
stderr().write_all(warning).ok();
}
}
Ok(ac)
}
/// Test whether the current `rustc` reports a version greater than
......@@ -160,14 +181,14 @@ impl AutoCfg {
}
fn probe<T: AsRef<[u8]>>(&self, code: T) -> Result<bool, Error> {
use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT};
#[allow(deprecated)]
static ID: AtomicUsize = ATOMIC_USIZE_INIT;
let id = ID.fetch_add(1, Ordering::Relaxed);
let mut command = Command::new(&self.rustc);
command
.arg(format!("--crate-name=probe{}", id))
.arg("--crate-name")
.arg(format!("probe{}", id))
.arg("--crate-type=lib")
.arg("--out-dir")
.arg(&self.out_dir)
......@@ -179,19 +200,37 @@ impl AutoCfg {
command.arg("-").stdin(Stdio::piped());
let mut child = try!(command.spawn().map_err(error::from_io));
try!(
child
.stdin
.take()
.expect("rustc stdin")
.write_all(code.as_ref())
.map_err(error::from_io)
);
let mut stdin = child.stdin.take().expect("rustc stdin");
if self.no_std {
try!(stdin.write_all(b"#![no_std]\n").map_err(error::from_io));
}
try!(stdin.write_all(code.as_ref()).map_err(error::from_io));
drop(stdin);
let status = try!(child.wait().map_err(error::from_io));
Ok(status.success())
}
/// Tests whether the given sysroot crate can be used.
///
/// The test code is subject to change, but currently looks like:
///
/// ```ignore
/// extern crate CRATE as probe;
/// ```
pub fn probe_sysroot_crate(&self, name: &str) -> bool {
self.probe(format!("extern crate {} as probe;", name)) // `as _` wasn't stabilized until Rust 1.33
.unwrap_or(false)
}
/// Emits a config value `has_CRATE` if `probe_sysroot_crate` returns true.
pub fn emit_sysroot_crate(&self, name: &str) {
if self.probe_sysroot_crate(name) {
emit(&format!("has_{}", mangle(name)));
}
}
/// Tests whether the given path can be used.
///
/// The test code is subject to change, but currently looks like:
......@@ -284,5 +323,6 @@ fn mangle(s: &str) -> String {
.map(|c| match c {
'A'...'Z' | 'a'...'z' | '0'...'9' => c,
_ => '_',
}).collect()
})
.collect()
}
use super::AutoCfg;
impl AutoCfg {
fn core_std(&self, path: &str) -> String {
let krate = if self.no_std { "core" } else { "std" };
format!("{}::{}", krate, path)
}
}
#[test]
fn autocfg_version() {
let ac = AutoCfg::with_dir("target").unwrap();
......@@ -23,26 +30,32 @@ fn version_cmp() {
#[test]
fn probe_add() {
let ac = AutoCfg::with_dir("target").unwrap();
assert!(ac.probe_path("std::ops::Add"));
assert!(ac.probe_trait("std::ops::Add"));
assert!(ac.probe_trait("std::ops::Add<i32>"));
assert!(ac.probe_trait("std::ops::Add<i32, Output = i32>"));
assert!(ac.probe_type("std::ops::Add<i32, Output = i32>"));
let add = ac.core_std("ops::Add");
let add_rhs = ac.core_std("ops::Add<i32>");
let add_rhs_output = ac.core_std("ops::Add<i32, Output = i32>");
assert!(ac.probe_path(&add));
assert!(ac.probe_trait(&add));
assert!(ac.probe_trait(&add_rhs));
assert!(ac.probe_trait(&add_rhs_output));
assert!(ac.probe_type(&add_rhs_output));
}
#[test]
fn probe_as_ref() {
let ac = AutoCfg::with_dir("target").unwrap();
assert!(ac.probe_path("std::convert::AsRef"));
assert!(ac.probe_trait("std::convert::AsRef<str>"));
assert!(ac.probe_type("std::convert::AsRef<str>"));
let as_ref = ac.core_std("convert::AsRef");
let as_ref_str = ac.core_std("convert::AsRef<str>");
assert!(ac.probe_path(&as_ref));
assert!(ac.probe_trait(&as_ref_str));
assert!(ac.probe_type(&as_ref_str));
}
#[test]
fn probe_i128() {
let ac = AutoCfg::with_dir("target").unwrap();
let missing = !ac.probe_rustc_version(1, 26);
assert!(missing ^ ac.probe_path("std::i128"));
let i128_path = ac.core_std("i128");
assert!(missing ^ ac.probe_path(&i128_path));
assert!(missing ^ ac.probe_type("i128"));
}
......@@ -50,8 +63,37 @@ fn probe_i128() {
fn probe_sum() {
let ac = AutoCfg::with_dir("target").unwrap();
let missing = !ac.probe_rustc_version(1, 12);
assert!(missing ^ ac.probe_path("std::iter::Sum"));
assert!(missing ^ ac.probe_trait("std::iter::Sum"));
assert!(missing ^ ac.probe_trait("std::iter::Sum<i32>"));
assert!(missing ^ ac.probe_type("std::iter::Sum<i32>"));
let sum = ac.core_std("iter::Sum");
let sum_i32 = ac.core_std("iter::Sum<i32>");
assert!(missing ^ ac.probe_path(&sum));
assert!(missing ^ ac.probe_trait(&sum));
assert!(missing ^ ac.probe_trait(&sum_i32));
assert!(missing ^ ac.probe_type(&sum_i32));
}
#[test]
fn probe_std() {
let ac = AutoCfg::with_dir("target").unwrap();
assert_eq!(ac.probe_sysroot_crate("std"), !ac.no_std);
}
#[test]
fn probe_alloc() {
let ac = AutoCfg::with_dir("target").unwrap();
let missing = !ac.probe_rustc_version(1, 36);
assert!(missing ^ ac.probe_sysroot_crate("alloc"));
}
#[test]
fn probe_bad_sysroot_crate() {
let ac = AutoCfg::with_dir("target").unwrap();
assert!(!ac.probe_sysroot_crate("doesnt_exist"));
}
#[test]
fn probe_no_std() {
let ac = AutoCfg::with_dir("target").unwrap();
assert!(ac.probe_type("i32"));
assert!(ac.probe_type("[i32]"));
assert_eq!(ac.probe_type("Vec<i32>"), !ac.no_std);
}
......@@ -24,12 +24,10 @@ impl Version {
pub fn from_rustc(rustc: &Path) -> Result<Self, Error> {
// Get rustc's verbose version
let output = try!(
Command::new(rustc)
.args(&["--version", "--verbose"])
.output()
.map_err(error::from_io)
);
let output = try!(Command::new(rustc)
.args(&["--version", "--verbose"])
.output()
.map_err(error::from_io));
if !output.status.success() {
return Err(error::from_str("could not execute rustc"));
}
......
{"files":{"Cargo.toml":"435243ec516989de48ba8715497f53c86efdd24b776e64d3667c3c9630f74695","LICENSE":"fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85","README.md":"a533b45a9c43083c6a6000a9c99a1acfed123d6430b232352ae02f1144a09f12","build.rs":"08e4a99d5184b2f22ab93bc0a024fec18dbd8fd38b9db638f19d4defede858ee","build/match_byte.rs":"e8537833ff1599a1bdbd0167f6295af7bd21e42024f32b982af32d58c156685c","docs/404.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","docs/index.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","src/color.rs":"8d3017ba8d644172908bd80d35e9be1081db477d2e0b0ea13971e29a466d451f","src/cow_rc_str.rs":"89b5dff5cf80eef3fcff0c11799e54a978d02d8b8963a621fbb999d35e7c03a3","src/from_bytes.rs":"b1cf15c4e975523fef46b575598737a39f3c63e5ce0b2bfd6ec627c69c6ea54a","src/lib.rs":"98b28ca7c72b8d20b3d76ae5b841be87bcadfc89e433ecc95fcf37aa15731442","src/macros.rs":"a50a0a7afa43e099dc008e54956e4c1fdfba2e9795d006b22e9eb45065fed61e","src/nth.rs":"a9d5fa0bd2c3ae7c48c851b9f5508ebdb07affdf5d0737bb8d85a7befab2ef9c","src/parser.rs":"fe2eb2be084923bf362de4b95c029beb21f172ad972a6452c400f640b43a583e","src/rules_and_declarations.rs":"b0288def4392faad529296ea7850895470dce8322a712056c5232699688df67a","src/serializer.rs":"4f47d46d0d056baa1dbbef3168c5d400645062eaff5dd637b0172bd2af784ed4","src/size_of_tests.rs":"a628cacc876f240ac1bb9e287cdae293bffc4b86d45d9307e4fc2f822e8f3e84","src/tests.rs":"bf97071b691c0b0c932af5813e876142ce707ba57774742dbe60889b1dc54069","src/tokenizer.rs":"483c6629a4b057d56be6aada97689aa03a914702d4e78618fb095b4ee5b6f90d","src/unicode_range.rs":"c4655c817db0dabb1d55669ac61a56ecf7f6a6c4353cf5b539b13bea6511c3dd"},"package":"a921abc45ea75c2c817d951caeda31b94539d09a6b5e8d58a857b3b35c9c3894"}
\ No newline at end of file
{"files":{"Cargo.toml":"9b63e0b5efaef0d3eaf50854bb45a8dd559f6eae4f69640943b27de4e4597023","LICENSE":"fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85","README.md":"a533b45a9c43083c6a6000a9c99a1acfed123d6430b232352ae02f1144a09f12","build.rs":"a41191c5917b37c911d4c191305ad975ad6d4c6cc778c38cfdf5c63c161aaffb","build/match_byte.rs":"190fa542a4a69ac197f9768320b03750cce2f61b3d99d84491d3c3116dafb461","docs/404.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","docs/index.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","src/color.rs":"af1c53f333cabde0736cc3e43e9045b0727eee6220eda7041af894abed1f0baa","src/cow_rc_str.rs":"89b5dff5cf80eef3fcff0c11799e54a978d02d8b8963a621fbb999d35e7c03a3","src/from_bytes.rs":"b1cf15c4e975523fef46b575598737a39f3c63e5ce0b2bfd6ec627c69c6ea54a","src/lib.rs":"980f4d339e77926eeb2c556f2716f6ed42b7aa38c3ce4ede7079ab67ca70a843","src/macros.rs":"a67ee23aace36d9f407c544b8b522b8180be04e239d1afdc9d849c5ca8022d51","src/nth.rs":"6896c997742af6f014b37ad57a5450c979054fd9c311fed29ec1ac42b2b256d6","src/parser.rs":"fe2eb2be084923bf362de4b95c029beb21f172ad972a6452c400f640b43a583e","src/rules_and_declarations.rs":"b0288def4392faad529296ea7850895470dce8322a712056c5232699688df67a","src/serializer.rs":"18c6e1533a2d84cf080444f034d3690c1a87c354609c5d336bb46d8b63448911","src/size_of_tests.rs":"a628cacc876f240ac1bb9e287cdae293bffc4b86d45d9307e4fc2f822e8f3e84","src/tests.rs":"b7391de644691e1a2d5af6c8c6f7575fa5895010a65c5ba5eae65376bd2c35af","src/tokenizer.rs":"7967940ff2970d6eef9a97feecf3c09f30c19b6d8a1f3e68594305a2dc59e85d","src/unicode_range.rs":"c4655c817db0dabb1d55669ac61a56ecf7f6a6c4353cf5b539b13bea6511c3dd"},"package":"fbe18ca4efb9ba3716c6da66cc3d7e673bf59fa576353011f48c4cfddbdd740e"}
\ No newline at end of file
......@@ -12,7 +12,7 @@
[package]
name = "cssparser"
version = "0.25.7"
version = "0.25.9"
authors = ["Simon Sapin <simon.sapin@exyr.org>"]
build = "build.rs"
exclude = ["src/css-parsing-tests/**", "src/big-data-url.css"]
......@@ -56,16 +56,19 @@ version = "2.0"
[dev-dependencies.encoding_rs]
version = "0.8"
[dev-dependencies.rustc-serialize]
version = "0.3"
[dev-dependencies.serde_json]
version = "1.0"
[build-dependencies.autocfg]
version = "0.1.4"
[build-dependencies.proc-macro2]
version = "0.4"
version = "1"
[build-dependencies.quote]
version = "0.6"
version = "1"
[build-dependencies.syn]
version = "0.15.12"
version = "1"
features = ["extra-traits", "fold", "full"]
[features]
......
......@@ -2,6 +2,7 @@
* 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/. */
extern crate autocfg;
#[macro_use]
extern crate quote;
#[macro_use]
......@@ -10,7 +11,6 @@ extern crate proc_macro2;
#[cfg(feature = "dummy_match_byte")]
mod codegen {
use std::path::Path;
pub fn main() {}
}
......@@ -50,5 +50,7 @@ fn main() {
println!("cargo:rustc-cfg=rustc_has_pr45225")
}
autocfg::new().emit_has_path("std::mem::MaybeUninit");
codegen::main();
}
......@@ -72,6 +72,54 @@ fn get_byte_from_expr_lit(expr: &Box<syn::Expr>) -> u8 {
}
}
/// Parse a pattern and fill the table accordingly
fn parse_pat_to_table<'a>(pat: &'a syn::Pat, case_id: u8, wildcard: &mut Option<&'a syn::Ident>, table: &mut [u8; 256]) {
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;
}
}
&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;
}
}
if table[hi as usize] == 0 {
table[hi as usize] = case_id;
}
}
&syn::Pat::Wild(_) => {
for byte in table.iter_mut() {
if *byte == 0 {
*byte = case_id;
}
}
}
&syn::Pat::Ident(syn::PatIdent { ref ident, .. }) => {
assert_eq!(*wildcard, None);
*wildcard = Some(ident);
for byte in table.iter_mut() {
if *byte == 0 {
*byte = case_id;
}
}
},
&syn::Pat::Or(syn::PatOr { ref cases, .. }) => {
for case in cases {
parse_pat_to_table(case, case_id, wildcard, table);
}
}
_ => {
panic!("Unexpected pattern: {:?}. Buggy code ?", pat);
}
}
}
/// Expand a TokenStream corresponding to the `match_byte` macro.
///
/// ## Example
......@@ -97,48 +145,8 @@ fn expand_match_byte(body: &TokenStream) -> syn::Expr {
let case_id = i + 1;
let index = case_id as isize;
let name = syn::Ident::new(&format!("Case{}", case_id), Span::call_site());
parse_pat_to_table(&arm.pat, case_id as u8, &mut wildcard, &mut table);
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[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;
}
}
}
&syn::Pat::Ident(syn::PatIdent { ref 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);
}
}
}
cases.push(quote!(#name = #index));
let body = &arm.body;
match_body.push(quote!(Case::#name => { #body }))
......@@ -170,7 +178,7 @@ impl Fold for MatchByteParser {
if mac.path == parse_quote!(match_byte) {
return syn::fold::fold_stmt(
self,
syn::Stmt::Expr(expand_match_byte(&mac.tts)),
syn::Stmt::Expr(expand_match_byte(&mac.tokens)),
);
}
}
......@@ -184,7 +192,7 @@ impl Fold for MatchByteParser {
match expr {
syn::Expr::Macro(syn::ExprMacro { ref mac, .. }) => {