servo: Merge #12409 - Update clippy, improve clippy integration (from Manishearth:clippy); r=nox
authorManish Goregaokar <manishsmail@gmail.com>
Tue, 12 Jul 2016 07:29:25 -0700
changeset 339274 008f21a1af9b8837d429dc97c4fca9b0d03294dc
parent 339273 13c229252cb232ad681bf137932e8e981e5ed7a2
child 339275 b3c359d819abbd4ad662fbdc67406224851509aa
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnox
servo: Merge #12409 - Update clippy, improve clippy integration (from Manishearth:clippy); r=nox This makes it much easier to run rustfix on servo (rustfix is still pretty buggy though) Source-Repo: https://github.com/servo/servo Source-Revision: 74925460952ac070ff5e365b6fe6b886fd81861b
servo/components/plugins/Cargo.toml
servo/components/plugins/lib.rs
servo/components/servo/Cargo.lock
servo/components/style/Cargo.toml
servo/components/style/attr.rs
servo/components/style/custom_properties.rs
servo/components/style/lib.rs
servo/components/style/matching.rs
servo/components/util/Cargo.toml
servo/components/util/lib.rs
servo/ports/cef/Cargo.lock
servo/python/servo/devenv_commands.py
--- a/servo/components/plugins/Cargo.toml
+++ b/servo/components/plugins/Cargo.toml
@@ -7,15 +7,15 @@ publish = false
 [lib]
 name = "plugins"
 path = "lib.rs"
 plugin = true
 
 [dependencies]
 tenacious = "0.2.0"
 
-[dependencies.clippy]
-git = "https://github.com/Manishearth/rust-clippy"
-rev = "9dca15de3e8ea266d3e7e868c0f358ed4fa5f195"
+[dependencies.clippy_lints]
+version = "0.0.77"
 optional = true
 
 [features]
 default = []
+clippy = ["clippy_lints"]
--- a/servo/components/plugins/lib.rs
+++ b/servo/components/plugins/lib.rs
@@ -13,17 +13,17 @@
 //!  - `#[dom_struct]` : Implies `#[privatize]`,`#[derive(JSTraceable)]`, and `#[must_root]`.
 //!                       Use this for structs that correspond to a DOM type
 
 #![feature(plugin_registrar, quote, plugin, box_syntax, rustc_private, slice_patterns)]
 
 #![deny(unsafe_code)]
 
 #[cfg(feature = "clippy")]
-extern crate clippy;
+extern crate clippy_lints;
 #[macro_use]
 extern crate rustc;
 extern crate rustc_plugin;
 #[macro_use]
 extern crate syntax;
 extern crate syntax_ext;
 extern crate tenacious;
 
@@ -39,29 +39,31 @@ pub mod lints;
 /// Autogenerates implementations of Reflectable on DOM structs
 pub mod reflector;
 /// Utilities for writing plugins
 mod utils;
 
 #[plugin_registrar]
 pub fn plugin_registrar(reg: &mut Registry) {
     reg.register_syntax_extension(intern("dom_struct"), MultiModifier(box jstraceable::expand_dom_struct));
-    reg.register_syntax_extension(intern("derive_JSTraceable"), MultiDecorator(box jstraceable::expand_jstraceable));
-    reg.register_syntax_extension(intern("_generate_reflector"), MultiDecorator(box reflector::expand_reflector));
-    reg.register_late_lint_pass(box lints::transmute_type::TransmutePass);
+    reg.register_syntax_extension(intern("derive_JSTraceable"),
+                                  MultiDecorator(box jstraceable::expand_jstraceable));
+    reg.register_syntax_extension(intern("_generate_reflector"),
+                                  MultiDecorator(box reflector::expand_reflector));
     reg.register_late_lint_pass(box lints::unrooted_must_root::UnrootedPass::new());
     reg.register_late_lint_pass(box lints::privatize::PrivatizePass);
     reg.register_late_lint_pass(box lints::inheritance_integrity::InheritancePass);
+    reg.register_late_lint_pass(box lints::transmute_type::TransmutePass);
     reg.register_early_lint_pass(box lints::ban::BanPass);
     reg.register_late_lint_pass(box tenacious::TenaciousPass);
     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);
+    ::clippy_lints::register_plugins(reg);
 }
 #[cfg(not(feature = "clippy"))]
 fn register_clippy(_reg: &mut Registry) {
 }
--- a/servo/components/servo/Cargo.lock
+++ b/servo/components/servo/Cargo.lock
@@ -2235,16 +2235,17 @@ dependencies = [
  "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "heapsize_plugin 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
+ "plugins 0.0.1",
  "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
  "selectors 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_macros 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)",
  "smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "string_cache 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
  "style_traits 0.0.1",
@@ -2459,16 +2460,17 @@ dependencies = [
  "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "euclid 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
  "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "ipc-channel 0.4.0 (git+https://github.com/servo/ipc-channel)",
  "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "num_cpus 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
+ "plugins 0.0.1",
  "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_macros 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)",
  "url 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "xdg 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
--- a/servo/components/style/Cargo.toml
+++ b/servo/components/style/Cargo.toml
@@ -11,17 +11,17 @@ name = "style"
 path = "lib.rs"
 
 [features]
 gecko = ["gecko_bindings", "selectors/gecko"]
 servo = ["serde", "serde/nightly", "serde_macros", "heapsize", "heapsize_plugin",
          "style_traits/servo", "app_units/plugins", "euclid/plugins",
          "cssparser/heap_size", "cssparser/serde-serialization",
          "selectors/heap_size", "selectors/unstable", "string_cache/heap_size",
-         "url/heap_size"]
+         "url/heap_size", "plugins"]
 
 [dependencies]
 app_units = "0.2.5"
 bitflags = "0.7"
 cssparser = "0.5.5"
 deque = "0.3.1"
 encoding = "0.2"
 euclid = "0.7.1"
@@ -40,14 +40,15 @@ selectors = "0.7"
 serde = {version = "0.7.11", optional = true}
 serde_macros = {version = "0.7.11", optional = true}
 smallvec = "0.1"
 string_cache = "0.2.20"
 style_traits = {path = "../style_traits"}
 time = "0.1"
 url = "1.0.0"
 util = {path = "../util"}
+plugins = {path = "../plugins", optional = true}
 
 [target.'cfg(windows)'.dependencies]
 kernel32-sys = "0.2"
 
 [build-dependencies]
 walkdir = "0.1"
--- a/servo/components/style/attr.rs
+++ b/servo/components/style/attr.rs
@@ -485,17 +485,17 @@ pub fn parse_length(mut value: &str) -> 
     value = value.trim_left_matches(HTML_SPACE_CHARACTERS);
 
     // Step 4
     if value.is_empty() {
         return LengthOrPercentageOrAuto::Auto
     }
 
     // Step 5
-    if value.starts_with("+") {
+    if value.starts_with('+') {
         value = &value[1..]
     }
 
     // Steps 6 & 7
     match value.chars().nth(0) {
         Some('0'...'9') => {},
         _ => return LengthOrPercentageOrAuto::Auto,
     }
--- a/servo/components/style/custom_properties.rs
+++ b/servo/components/style/custom_properties.rs
@@ -189,17 +189,17 @@ fn parse_declaration_value_block(input: 
                 }
             }
         }
         let last_token_type = match token {
             Token::Comment(_) => {
                 let token_slice = input.slice_from(token_start);
                 if !token_slice.ends_with("*/") {
                     missing_closing_characters.push_str(
-                        if token_slice.ends_with("*") { "/" } else { "*/" })
+                        if token_slice.ends_with('*') { "/" } else { "*/" })
                 }
                 token.serialization_type()
             }
             Token::BadUrl |
             Token::BadString |
             Token::CloseParenthesis |
             Token::CloseSquareBracket |
             Token::CloseCurlyBracket => {
--- a/servo/components/style/lib.rs
+++ b/servo/components/style/lib.rs
@@ -22,16 +22,17 @@
 //!
 //! [cssparser]: ../cssparser/index.html
 //! [selectors]: ../selectors/index.html
 
 #![cfg_attr(feature = "servo", feature(custom_attribute))]
 #![cfg_attr(feature = "servo", feature(custom_derive))]
 #![cfg_attr(feature = "servo", feature(plugin))]
 #![cfg_attr(feature = "servo", plugin(heapsize_plugin))]
+#![cfg_attr(feature = "servo", plugin(plugins))]
 #![cfg_attr(feature = "servo", plugin(serde_macros))]
 
 #![deny(unsafe_code)]
 
 #![recursion_limit = "500"]  // For match_ignore_ascii_case in PropertyDeclaration::parse
 
 extern crate app_units;
 #[allow(unused_extern_crates)]
--- a/servo/components/style/matching.rs
+++ b/servo/components/style/matching.rs
@@ -597,27 +597,24 @@ pub trait ElementMatchMethods : TElement
         if self.style_attribute().is_some() {
             return StyleSharingResult::CannotShare
         }
         if self.has_attr(&ns!(), &atom!("id")) {
             return StyleSharingResult::CannotShare
         }
 
         for (i, &(ref candidate, ())) in style_sharing_candidate_cache.iter().enumerate() {
-            match self.share_style_with_candidate_if_possible(parent.clone(), candidate) {
-                Some(shared_style) => {
-                    // Yay, cache hit. Share the style.
-                    let node = self.as_node();
-                    let style = &mut node.mutate_data().unwrap().style;
-                    let damage = <<Self as TElement>::ConcreteNode as TNode>
-                                     ::ConcreteRestyleDamage::compute((*style).as_ref(), &*shared_style);
-                    *style = Some(shared_style);
-                    return StyleSharingResult::StyleWasShared(i, damage)
-                }
-                None => {}
+            if let Some(shared_style) = self.share_style_with_candidate_if_possible(parent.clone(), candidate) {
+                // Yay, cache hit. Share the style.
+                let node = self.as_node();
+                let style = &mut node.mutate_data().unwrap().style;
+                let damage = <<Self as TElement>::ConcreteNode as TNode>
+                                 ::ConcreteRestyleDamage::compute((*style).as_ref(), &*shared_style);
+                *style = Some(shared_style);
+                return StyleSharingResult::StyleWasShared(i, damage)
             }
         }
 
         StyleSharingResult::CannotShare
     }
 }
 
 impl<E: TElement> ElementMatchMethods for E
--- a/servo/components/util/Cargo.toml
+++ b/servo/components/util/Cargo.toml
@@ -6,28 +6,29 @@ publish = false
 
 [lib]
 name = "util"
 path = "lib.rs"
 
 [features]
 # servo as opposed to geckolib
 servo = ["serde", "serde_macros", "backtrace", "ipc-channel", "app_units/plugins",
-         "euclid/plugins", "euclid/unstable", "url/heap_size", "url/serde"]
+         "euclid/plugins", "euclid/unstable", "url/heap_size", "url/serde", "plugins"]
 
 [dependencies]
 app_units = "0.2.5"
 backtrace = {version = "0.2.1", optional = true}
 bitflags = "0.7"
 euclid = "0.7.1"
 getopts = "0.2.11"
 heapsize = "0.3.0"
 ipc-channel = {git = "https://github.com/servo/ipc-channel", optional = true}
 lazy_static = "0.2"
 log = "0.3.5"
 num_cpus = "0.2.2"
 rustc-serialize = "0.3"
 serde = {version = "0.7.11", optional = true}
 serde_macros = {version = "0.7.11", optional = true}
 url = "1.0.0"
+plugins = {path = "../plugins", optional = true}
 
 [target.'cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android")))'.dependencies]
 xdg = "2.0"
--- a/servo/components/util/lib.rs
+++ b/servo/components/util/lib.rs
@@ -2,16 +2,17 @@
  * 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/. */
 
 #![cfg_attr(feature = "servo", feature(custom_derive))]
 #![cfg_attr(feature = "servo", feature(fnbox))]
 #![cfg_attr(feature = "servo", feature(plugin))]
 #![cfg_attr(feature = "servo", feature(reflect_marker))]
 #![cfg_attr(feature = "servo", plugin(serde_macros))]
+#![cfg_attr(feature = "servo", plugin(plugins))]
 
 #![deny(unsafe_code)]
 
 extern crate app_units;
 #[cfg(feature = "servo")] extern crate backtrace;
 #[allow(unused_extern_crates)] #[macro_use] extern crate bitflags;
 extern crate euclid;
 extern crate getopts;
--- a/servo/ports/cef/Cargo.lock
+++ b/servo/ports/cef/Cargo.lock
@@ -2120,16 +2120,17 @@ dependencies = [
  "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "heapsize_plugin 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
+ "plugins 0.0.1",
  "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
  "selectors 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_macros 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)",
  "smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "string_cache 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
  "style_traits 0.0.1",
@@ -2328,16 +2329,17 @@ dependencies = [
  "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "euclid 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
  "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "ipc-channel 0.4.0 (git+https://github.com/servo/ipc-channel)",
  "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "num_cpus 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
+ "plugins 0.0.1",
  "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_macros 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)",
  "url 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "xdg 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
--- a/servo/python/servo/devenv_commands.py
+++ b/servo/python/servo/devenv_commands.py
@@ -89,21 +89,31 @@ class MachCommands(CommandBase):
             with cd(cargo_path):
                 print(cargo_path)
                 call(["cargo", "update"] + params,
                      env=self.build_env())
 
     @Command('clippy',
              description='Run Clippy',
              category='devenv')
-    def clippy(self):
-        features = "--features=script/plugins/clippy"
+    @CommandArgument(
+        '--package', '-p', default=None,
+        help='Updates the selected package')
+    @CommandArgument(
+        '--json', '-j', action="store_true",
+        help='Outputs')
+    def clippy(self, package=None, json=False):
+        params = ["--features=script/plugins/clippy"]
+        if package:
+            params += ["-p", package]
+        if json:
+            params += ["--", "-Zunstable-options", "--error-format", "json"]
 
         with cd(path.join(self.context.topdir, "components", "servo")):
-            return subprocess.call(["cargo", "build", features],
+            return subprocess.call(["cargo", "rustc", "-v"] + params,
                                    env=self.build_env())
 
     @Command('rustc',
              description='Run the Rust compiler',
              category='devenv')
     @CommandArgument(
         'params', default=None, nargs='...',
         help="Command-line arguments to be passed through to rustc")