From adfe9d249ec872c5d95e806ee4d4e9694699c472 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 14 Aug 2015 00:06:11 +0530 Subject: [PATCH] Integrate clippy into Servo --- components/plugins/Cargo.toml | 7 +++++++ components/plugins/lib.rs | 13 ++++++++++++- components/servo/Cargo.lock | 6 ++++++ ports/cef/Cargo.lock | 6 ++++++ ports/gonk/Cargo.lock | 6 ++++++ 5 files changed, 37 insertions(+), 1 deletion(-) diff --git a/components/plugins/Cargo.toml b/components/plugins/Cargo.toml index 138ce7f9baf..0162a1f5516 100644 --- a/components/plugins/Cargo.toml +++ b/components/plugins/Cargo.toml @@ -11,3 +11,10 @@ plugin = true [dependencies.tenacious] git = "https://github.com/servo/rust-tenacious" +[dependencies.clippy] +git = "https://github.com/Manishearth/rust-clippy" +branch = "servo" +optional = true + +[features] +default = [] diff --git a/components/plugins/lib.rs b/components/plugins/lib.rs index ba64164f9f6..88f702c1c0c 100644 --- a/components/plugins/lib.rs +++ b/components/plugins/lib.rs @@ -21,6 +21,8 @@ extern crate syntax; extern crate rustc; extern crate tenacious; +#[cfg(feature = "clippy")] +extern crate clippy; use rustc::lint::LintPassObject; use rustc::plugin::Registry; @@ -53,10 +55,19 @@ pub fn plugin_registrar(reg: &mut Registry) { reg.register_lint_pass(box lints::unrooted_must_root::UnrootedPass::new() as LintPassObject); reg.register_lint_pass(box lints::privatize::PrivatizePass as LintPassObject); reg.register_lint_pass(box lints::inheritance_integrity::InheritancePass as LintPassObject); - reg.register_lint_pass(box lints::str_to_string::StrToStringPass as LintPassObject); reg.register_lint_pass(box lints::ban::BanPass as LintPassObject); reg.register_lint_pass(box tenacious::TenaciousPass as LintPassObject); reg.register_attribute("must_root".to_string(), Whitelisted); reg.register_attribute("servo_lang".to_string(), Whitelisted); reg.register_attribute("allow_unrooted_interior".to_string(), Whitelisted); + register_clippy(reg); } + +#[cfg(feature = "clippy")] +fn register_clippy(reg: &mut Registry) { + ::clippy::plugin_registrar(reg); +} +#[cfg(not(feature = "clippy"))] +fn register_clippy(reg: &mut Registry) { + reg.register_lint_pass(box lints::str_to_string::StrToStringPass as LintPassObject); +} \ No newline at end of file diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock index 02a96a64acd..91a40d13482 100644 --- a/components/servo/Cargo.lock +++ b/components/servo/Cargo.lock @@ -166,6 +166,11 @@ dependencies = [ "winapi 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "clippy" +version = "0.0.11" +source = "git+https://github.com/Manishearth/rust-clippy?branch=servo#4d5e15ee6e1061ed7da0a91df3510728cabc0a21" + [[package]] name = "clock_ticks" version = "0.0.6" @@ -1104,6 +1109,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "plugins" version = "0.0.1" dependencies = [ + "clippy 0.0.11 (git+https://github.com/Manishearth/rust-clippy?branch=servo)", "tenacious 0.0.9 (git+https://github.com/servo/rust-tenacious)", ] diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock index 04470eea902..fd9edc59963 100644 --- a/ports/cef/Cargo.lock +++ b/ports/cef/Cargo.lock @@ -165,6 +165,11 @@ dependencies = [ "winapi 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "clippy" +version = "0.0.11" +source = "git+https://github.com/Manishearth/rust-clippy?branch=servo#4d5e15ee6e1061ed7da0a91df3510728cabc0a21" + [[package]] name = "clock_ticks" version = "0.0.6" @@ -1082,6 +1087,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "plugins" version = "0.0.1" dependencies = [ + "clippy 0.0.11 (git+https://github.com/Manishearth/rust-clippy?branch=servo)", "tenacious 0.0.9 (git+https://github.com/servo/rust-tenacious)", ] diff --git a/ports/gonk/Cargo.lock b/ports/gonk/Cargo.lock index 9e5f5c4d1d8..5f4f0d1493b 100644 --- a/ports/gonk/Cargo.lock +++ b/ports/gonk/Cargo.lock @@ -151,6 +151,11 @@ dependencies = [ "winapi 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "clippy" +version = "0.0.11" +source = "git+https://github.com/Manishearth/rust-clippy?branch=servo#4d5e15ee6e1061ed7da0a91df3510728cabc0a21" + [[package]] name = "clock_ticks" version = "0.0.6" @@ -988,6 +993,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "plugins" version = "0.0.1" dependencies = [ + "clippy 0.0.11 (git+https://github.com/Manishearth/rust-clippy?branch=servo)", "tenacious 0.0.9 (git+https://github.com/servo/rust-tenacious)", ]