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); }