From e397ca06d84ee2b0c9167a466c199d72e23abc48 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Wed, 18 Jul 2018 11:25:08 +0200 Subject: [PATCH 1/2] Avoid use of deprecated (and buggy) std::env::home_dir --- Cargo.lock | 18 +++++++++++------- components/config/Cargo.toml | 4 ++-- components/config/basedir.rs | 26 ++++++++------------------ components/config/lib.rs | 4 ++-- 4 files changed, 23 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 33b30266953..b723dabbc40 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -708,6 +708,15 @@ dependencies = [ "time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "dirs" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "dlib" version = "0.4.1" @@ -2860,6 +2869,7 @@ name = "servo_config" version = "0.0.1" dependencies = [ "android_injected_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "dirs 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "embedder_traits 0.0.1", "env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2872,7 +2882,6 @@ dependencies = [ "servo_geometry 0.0.1", "servo_url 0.0.1", "url 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "xdg 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3735,11 +3744,6 @@ dependencies = [ "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "xdg" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "xi-unicode" version = "0.1.0" @@ -3826,6 +3830,7 @@ dependencies = [ "checksum dbus 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "acd824d45fad5ff0e178fcb3c040f13780e73f63a0a6d5cde59e7894f251ab0e" "checksum deflate 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ebb02aaf4b775afc96684b8402510a338086974e38570a1f65bea8c202eb77a7" "checksum device 0.0.1 (git+https://github.com/servo/devices)" = "" +"checksum dirs 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "37a76dd8b997af7107d0bb69d43903cf37153a18266f8b3fdb9911f28efb5444" "checksum dlib 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "77e51249a9d823a4cb79e3eca6dcd756153e8ed0157b6c04775d04bf1b13b76a" "checksum downcast-rs 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "18df8ce4470c189d18aa926022da57544f31e154631eb4cfe796aea97051fe6c" "checksum dtoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "80c8b71fd71146990a9742fc06dcbbde19161a267e0ad4e572c35162f4578c90" @@ -4071,7 +4076,6 @@ dependencies = [ "checksum x11-clipboard 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2e7374c7699210cca7084ca61d57e09640fc744d1391808cb9ae2fe4ca9bd1df" "checksum x11-dl 2.18.0 (registry+https://github.com/rust-lang/crates.io-index)" = "931d8584b49771143af0c422f372d8aef4280afd5920dad39b0a95a8e51df1e9" "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" "checksum xml5ever 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ead952cf8bab253fb5cb56e1fff780747bbf7a7258fb0451afe645a166050b1f" diff --git a/components/config/Cargo.toml b/components/config/Cargo.toml index 9dcd4c627e3..61cbf9df593 100644 --- a/components/config/Cargo.toml +++ b/components/config/Cargo.toml @@ -28,8 +28,8 @@ url = "1.2" env_logger = "0.5" embedder_traits = { path = "../embedder_traits", features = ["tests"] } -[target.'cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android")))'.dependencies] -xdg = "2.0" +[target.'cfg(not(target_os = "android"))'.dependencies] +dirs = "1.0" [target.'cfg(target_os = "android")'.dependencies] android_injected_glue = "0.2" diff --git a/components/config/basedir.rs b/components/config/basedir.rs index 2f634448b34..f3dd0ca7f67 100644 --- a/components/config/basedir.rs +++ b/components/config/basedir.rs @@ -8,18 +8,16 @@ #[cfg(target_os = "android")] use android_injected_glue; -#[cfg(any(target_os = "macos", target_os = "windows"))] -use std::env; #[cfg(target_os = "android")] use std::ffi::CStr; use std::path::PathBuf; -#[cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android")))] -use xdg; #[cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android")))] pub fn default_config_dir() -> PathBuf { - let xdg_dirs = xdg::BaseDirectories::with_profile("servo", "default").unwrap(); - xdg_dirs.get_config_home() + let mut config_dir = ::dirs::config_dir().unwrap(); + config_dir.push("servo"); + config_dir.push("default"); + config_dir } #[cfg(target_os = "android")] @@ -33,24 +31,16 @@ pub fn default_config_dir() -> PathBuf { #[cfg(target_os = "macos")] pub fn default_config_dir() -> PathBuf { - let mut config_dir = env::home_dir().unwrap(); - config_dir.push("Library"); - config_dir.push("Application Support"); + // FIXME: use `config_dir()` ($HOME/Library/Preferences) + // instead of `data_dir()` ($HOME/Library/Application Support) ? + let mut config_dir = ::dirs::data_dir().unwrap(); config_dir.push("Servo"); config_dir } #[cfg(target_os = "windows")] pub fn default_config_dir() -> PathBuf { - let mut config_dir = match env::var_os("APPDATA") { - Some(appdata_path) => PathBuf::from(appdata_path), - None => { - let mut dir = env::home_dir().unwrap(); - dir.push("Appdata"); - dir.push("Roaming"); - dir - } - }; + let mut config_dir = ::dirs::config_dir().unwrap(); config_dir.push("Servo"); config_dir } diff --git a/components/config/lib.rs b/components/config/lib.rs index 89604c5883b..7c094bd2d26 100644 --- a/components/config/lib.rs +++ b/components/config/lib.rs @@ -6,6 +6,8 @@ #[cfg(target_os = "android")] extern crate android_injected_glue; +#[cfg(not(target_os = "android"))] +extern crate dirs; extern crate embedder_traits; extern crate euclid; extern crate getopts; @@ -17,8 +19,6 @@ extern crate rustc_serialize; extern crate servo_geometry; extern crate servo_url; extern crate url; -#[cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android")))] -extern crate xdg; pub mod basedir; #[allow(unsafe_code)] pub mod opts; From 3509bcb5319fca02dc9c40ab5feeee9014534263 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Tue, 17 Jul 2018 20:23:32 +0200 Subject: [PATCH 2/2] Upgrade to rustc 1.29.0-nightly (1ecf6929d 2018-07-16) --- components/dom_struct/lib.rs | 3 --- components/script/lib.rs | 2 +- components/script_plugins/unrooted_must_root.rs | 4 ++-- rust-toolchain | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/components/dom_struct/lib.rs b/components/dom_struct/lib.rs index a9d9204c534..0fa5f4f8163 100644 --- a/components/dom_struct/lib.rs +++ b/components/dom_struct/lib.rs @@ -2,9 +2,6 @@ * 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/. */ -#![feature(proc_macro)] -#![feature(proc_macro_non_items)] - extern crate proc_macro; #[macro_use] diff --git a/components/script/lib.rs b/components/script/lib.rs index 837b744424c..d151734da80 100644 --- a/components/script/lib.rs +++ b/components/script/lib.rs @@ -7,8 +7,8 @@ #![feature(const_fn)] #![feature(mpsc_select)] #![feature(plugin)] -#![feature(proc_macro)] #![feature(string_retain)] +#![feature(use_extern_macros)] #![deny(unsafe_code)] #![allow(non_snake_case)] diff --git a/components/script_plugins/unrooted_must_root.rs b/components/script_plugins/unrooted_must_root.rs index 29e74940536..86825808f2c 100644 --- a/components/script_plugins/unrooted_must_root.rs +++ b/components/script_plugins/unrooted_must_root.rs @@ -2,7 +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/. */ -use rustc::hir; +use rustc::hir::{self, ExprKind}; use rustc::hir::intravisit as visit; use rustc::hir::map as ast_map; use rustc::lint::{LateContext, LintPass, LintArray, LateLintPass, LintContext}; @@ -185,7 +185,7 @@ impl<'a, 'b, 'tcx> visit::Visitor<'tcx> for FnDefVisitor<'a, 'b, 'tcx> { match expr.node { // Trait casts from #[must_root] types are not allowed - hir::ExprCast(ref subexpr, _) => require_rooted(cx, self.in_new_function, &*subexpr), + ExprKind::Cast(ref subexpr, _) => require_rooted(cx, self.in_new_function, &*subexpr), // This catches assignments... the main point of this would be to catch mutable // references to `JS`. // FIXME: Enable this? Triggers on certain kinds of uses of DomRefCell. diff --git a/rust-toolchain b/rust-toolchain index 7888624d5e7..c4773552808 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2018-07-07 +nightly-2018-07-17