From 2bd99317fbe77e7475255d58f6b6f24ec80f7e41 Mon Sep 17 00:00:00 2001 From: Bastien Orivel Date: Mon, 5 Mar 2018 15:32:44 +0100 Subject: [PATCH 1/2] Update toml to 0.4 --- Cargo.lock | 9 +++++--- components/style/Cargo.toml | 2 +- components/style/build_gecko.rs | 40 +++++++++++++-------------------- 3 files changed, 23 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0973bb94a3a..0506eb301eb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2986,7 +2986,7 @@ dependencies = [ "style_derive 0.0.1", "style_traits 0.0.1", "time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "uluru 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-bidi 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-segmentation 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3210,8 +3210,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "toml" -version = "0.2.1" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "traitobject" @@ -3944,7 +3947,7 @@ dependencies = [ "checksum time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "ffd7ccbf969a892bf83f1e441126968a07a3941c24ff522a26af9f9f4585d1a3" "checksum tinyfiledialogs 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d92a5f7395a9e2895a2361c3121d4a0be0f8dac3be7d91841a5c1c5291b1c6dc" "checksum token_store 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a686838375fc11103b9c1529c6508320b7bd5e2401cd62831ca51b3e82e61849" -"checksum toml 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "736b60249cb25337bc196faa43ee12c705e426f3d55c214d73a4e7be06f92cb4" +"checksum toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a7540f4ffc193e0d3c94121edb19b055670d369f77d5804db11ae053a45b6e7e" "checksum traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" "checksum truetype 0.26.0 (registry+https://github.com/rust-lang/crates.io-index)" = "acec30350633d6dac9dc1a625786b6cbe9150664be941aac2c35ad7199eab877" "checksum typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887" diff --git a/components/style/Cargo.toml b/components/style/Cargo.toml index 88b64ca8144..2a81d1e0fea 100644 --- a/components/style/Cargo.toml +++ b/components/style/Cargo.toml @@ -81,4 +81,4 @@ log = "0.3" bindgen = { version = "0.33.1", optional = true, default-features = false } regex = {version = "0.2", optional = true} walkdir = "1.0" -toml = {version = "0.2.1", optional = true, default-features = false} +toml = {version = "0.4.5", optional = true, default-features = false} diff --git a/components/style/build_gecko.rs b/components/style/build_gecko.rs index eeb15c8e718..0ff05604966 100644 --- a/components/style/build_gecko.rs +++ b/components/style/build_gecko.rs @@ -43,42 +43,32 @@ mod bindings { use super::common::*; use super::super::PYTHON; use toml; + use toml::value::Table; const STRUCTS_FILE: &'static str = "structs.rs"; const BINDINGS_FILE: &'static str = "bindings.rs"; - fn read_config(path: &PathBuf) -> toml::Table { + fn read_config(path: &PathBuf) -> Table { println!("cargo:rerun-if-changed={}", path.to_str().unwrap()); update_last_modified(&path); let mut contents = String::new(); File::open(path).expect("Failed to open config file") .read_to_string(&mut contents).expect("Failed to read config file"); - let mut parser = toml::Parser::new(&contents); - if let Some(result) = parser.parse() { - result - } else { - use std::fmt::Write; - let mut reason = String::from("Failed to parse config file:"); - for err in parser.errors.iter() { - let parsed = &contents[..err.lo]; - write!(&mut reason, "\n* line {} column {}: {}", - parsed.lines().count(), - parsed.lines().last().map_or(0, |l| l.len()), - err).unwrap(); - } - panic!(reason) + match toml::from_str::(&contents) { + Ok(result) => result, + Err(e) => panic!("Failed to parse config file: {}", e) } } lazy_static! { - static ref CONFIG: toml::Table = { + static ref CONFIG: Table = { // Load Gecko's binding generator config from the source tree. let path = PathBuf::from(env::var_os("MOZ_SRC").unwrap()) .join("layout/style/ServoBindings.toml"); read_config(&path) }; - static ref BUILD_CONFIG: toml::Table = { + static ref BUILD_CONFIG: Table = { // Load build-specific config overrides. // FIXME: We should merge with CONFIG above instead of // forcing callers to do it. @@ -169,7 +159,7 @@ mod bindings { fn mutable_borrowed_type(self, ty: &str) -> Builder; } - fn add_clang_args(mut builder: Builder, config: &toml::Table, matched_os: &mut bool) -> Builder { + fn add_clang_args(mut builder: Builder, config: &Table, matched_os: &mut bool) -> Builder { fn add_args(mut builder: Builder, values: &[toml::Value]) -> Builder { for item in values.iter() { builder = builder.clang_arg(item.as_str().expect("Expect string in list")); @@ -178,7 +168,7 @@ mod bindings { } for (k, v) in config.iter() { if k == "args" { - builder = add_args(builder, v.as_slice().unwrap()); + builder = add_args(builder, v.as_array().unwrap().as_slice()); continue; } let equal_idx = k.find('=').expect(&format!("Invalid key: {}", k)); @@ -324,11 +314,11 @@ mod bindings { struct BuilderWithConfig<'a> { builder: Builder, - config: &'a toml::Table, + config: &'a Table, used_keys: HashSet<&'static str>, } impl<'a> BuilderWithConfig<'a> { - fn new(builder: Builder, config: &'a toml::Table) -> Self { + fn new(builder: Builder, config: &'a Table) -> Self { BuilderWithConfig { builder, config, used_keys: HashSet::new(), @@ -342,7 +332,7 @@ mod bindings { let mut used_keys = self.used_keys; if let Some(list) = config.get(key) { used_keys.insert(key); - builder = func(builder, list.as_slice().unwrap().iter()); + builder = func(builder, list.as_array().unwrap().as_slice().iter()); } BuilderWithConfig { builder, config, used_keys } } @@ -355,7 +345,9 @@ mod bindings { self.handle_items(key, |b, item| func(b, item.as_str().unwrap())) } fn handle_table_items(self, key: &'static str, mut func: F) -> BuilderWithConfig<'a> - where F: FnMut(Builder, &'a toml::Table) -> Builder { + where + F: FnMut(Builder, &'a Table) -> Builder + { self.handle_items(key, |b, item| func(b, item.as_table().unwrap())) } fn handle_common(self, fixups: &mut Vec) -> BuilderWithConfig<'a> { @@ -419,7 +411,7 @@ mod bindings { for item in iter { let item = item.as_table().unwrap(); let name = item["enum"].as_str().unwrap(); - let variants = item["variants"].as_slice().unwrap().iter() + let variants = item["variants"].as_array().unwrap().as_slice().iter() .map(|item| item.as_str().unwrap()); map.insert(name.into(), RegexSet::new(variants).unwrap()); } From fcc64e659d371a2d1479d905a8721566b74563f3 Mon Sep 17 00:00:00 2001 From: Bastien Orivel Date: Mon, 5 Mar 2018 15:33:41 +0100 Subject: [PATCH 2/2] Update error-chain to 0.11 --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0506eb301eb..053c2747b7f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -373,7 +373,7 @@ dependencies = [ "objc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "objc-foundation 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "objc_id 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "x11-clipboard 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "x11-clipboard 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -845,7 +845,7 @@ dependencies = [ [[package]] name = "error-chain" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3638,11 +3638,11 @@ dependencies = [ [[package]] name = "x11-clipboard" -version = "0.2.0" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "xcb 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "xcb 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3657,11 +3657,11 @@ dependencies = [ [[package]] name = "xcb" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3771,7 +3771,7 @@ dependencies = [ "checksum energymon-sys 0.3.0 (git+https://github.com/energymon/energymon-sys.git)" = "" "checksum enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "be4551092f4d519593039259a9ed8daedf0da12e5109c5280338073eaeb81180" "checksum env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3ddf21e73e016298f5cb37d6ef8e8da8e39f91f9ec8b0df44b7deb16a9f8cd5b" -"checksum error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9435d864e017c3c6afeac1654189b06cdb491cf2ff73dbf0d73b0f292f42ff8" +"checksum error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff511d5dc435d703f4971bc399647c9bc38e20cb41452e3b9feb4765419ed3f3" "checksum euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)" = "adfe67a9343519c1449d208da5998c6de582de698f7a39c4ac82ffba23d131a5" "checksum expat-sys 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c470ccb972f2088549b023db8029ed9da9426f5affbf9b62efff7009ab8ed5b1" "checksum flate2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9fac2277e84e5e858483756647a9d0aa8d9a2b7cba517fd84325a0aaa69a0909" @@ -3990,9 +3990,9 @@ dependencies = [ "checksum ws 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "04614a58714f3fd4a8b1da4bcae9f031c532d35988c3d39627619248113f8be8" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" "checksum x11 2.17.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e5c4ac579b5d324dc4add02312b5d0e3e0218521e2d5779d526ac39ee4bb171" -"checksum x11-clipboard 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "78a35cd979d17b95e0706ab1f3425ecc98565d3873902bd5944b9f5f388327d1" +"checksum x11-clipboard 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2e7374c7699210cca7084ca61d57e09640fc744d1391808cb9ae2fe4ca9bd1df" "checksum x11-dl 2.17.3 (registry+https://github.com/rust-lang/crates.io-index)" = "29e78a65a3239e5511ffe2c832edb9224982ebf67bcaabc218ef1b07d8494b3e" -"checksum xcb 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "400cebeaedeca931825f11606874080f18aa51370dd3d7e11bc08d5aac8b3142" +"checksum xcb 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5e917a3f24142e9ff8be2414e36c649d47d6cc2ba81f16201cdef96e533e02de" "checksum xdg 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a66b7c2281ebde13cf4391d70d4c7e5946c3c25e72a7b859ca8f677dcd0b0c61" "checksum xi-unicode 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "12ea8eda4b1eb72f02d148402e23832d56a33f55d8c1b2d5bcdde91d79d47cb1" "checksum xml-rs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c1cb601d29fe2c2ac60a2b2e5e293994d87a1f6fa9687a31a15270f909be9c2"