From 27a2bb1582ad2fe11ab7b14f2ac75e6f6f223c84 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Thu, 2 Nov 2017 15:01:08 +0100 Subject: [PATCH 1/2] Make script enable the "style/servo" Cargo feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This enables it to be compiled without libservo: ``` cargo build --manifest-path components/script/Cargo.toml ``` … and then to be added to http://perf.rust-lang.org/ --- components/script/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index 299a25f88f6..c87f0085687 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -85,7 +85,7 @@ servo_geometry = {path = "../geometry" } servo_rand = {path = "../rand"} servo_url = {path = "../url"} smallvec = "0.4" -style = {path = "../style"} +style = {path = "../style", features = ["servo"]} style_traits = {path = "../style_traits"} swapper = "0.1" time = "0.1.12" From a5d9d0b32d28be603d14dcfc7ea3e5fdb87e25df Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Thu, 2 Nov 2017 15:08:04 +0100 Subject: [PATCH 2/2] Make the unrooted_must_root conditional on a default Cargo feature. Only http://perf.rust-lang.org/ will disable it, in order to be less subject to changes to rustc internal APIs. --- components/script/Cargo.toml | 2 ++ components/script/lib.rs | 1 + components/script_plugins/Cargo.toml | 3 +++ components/script_plugins/lib.rs | 8 ++++++++ 4 files changed, 14 insertions(+) diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index c87f0085687..9523dc628c2 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -14,6 +14,8 @@ path = "lib.rs" [features] debugmozjs = ['js/debugmozjs'] unstable = ["servo_allocator/unstable"] +unrooted_must_root_lint = ["script_plugins/unrooted_must_root_lint"] +default = ["unrooted_must_root_lint"] [build-dependencies] cmake = "0.1" diff --git a/components/script/lib.rs b/components/script/lib.rs index f56e2c3dcaa..719275dc3ec 100644 --- a/components/script/lib.rs +++ b/components/script/lib.rs @@ -16,6 +16,7 @@ #![doc = "The script crate contains all matters DOM."] #![plugin(script_plugins)] +#![cfg_attr(not(feature = "unrooted_must_root_lint"), allow(unknown_lints))] extern crate angle; extern crate app_units; diff --git a/components/script_plugins/Cargo.toml b/components/script_plugins/Cargo.toml index 6b200e3ef0f..c6bc3eb2250 100644 --- a/components/script_plugins/Cargo.toml +++ b/components/script_plugins/Cargo.toml @@ -8,3 +8,6 @@ publish = false [lib] path = "lib.rs" plugin = true + +[features] +unrooted_must_root_lint = [] diff --git a/components/script_plugins/lib.rs b/components/script_plugins/lib.rs index a929f394c21..3f256fdf11c 100644 --- a/components/script_plugins/lib.rs +++ b/components/script_plugins/lib.rs @@ -14,27 +14,35 @@ //! Use this for structs that correspond to a DOM type + #![deny(unsafe_code)] #![feature(macro_vis_matcher)] #![feature(plugin)] #![feature(plugin_registrar)] #![feature(rustc_private)] +#[cfg(feature = "unrooted_must_root_lint")] #[macro_use] extern crate rustc; + extern crate rustc_plugin; extern crate syntax; use rustc_plugin::Registry; use syntax::feature_gate::AttributeType::Whitelisted; +#[cfg(feature = "unrooted_must_root_lint")] mod unrooted_must_root; + /// Utilities for writing plugins +#[cfg(feature = "unrooted_must_root_lint")] mod utils; #[plugin_registrar] pub fn plugin_registrar(reg: &mut Registry) { + #[cfg(feature = "unrooted_must_root_lint")] reg.register_late_lint_pass(Box::new(unrooted_must_root::UnrootedPass::new())); + reg.register_attribute("allow_unrooted_interior".to_string(), Whitelisted); reg.register_attribute("must_root".to_string(), Whitelisted); }