Bug 1607697 - Address some clippy lints in WebRender API. r=Gankro
authorNicolas Silva <nsilva@mozilla.com>
Fri, 10 Jan 2020 10:11:36 +0000
changeset 509680 ac0dde67360ed26299378a2a895b60552bbce71e
parent 509679 f8b5627432c6917f3ebba3692177821d27da364a
child 509681 ffff3331e696c5f6c8ae458a4e50b5a5b184cbcb
push id37002
push userccoroiu@mozilla.com
push dateFri, 10 Jan 2020 21:49:10 +0000
treeherdermozilla-central@7fa78b1baf59 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGankro
bugs1607697
milestone74.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1607697 - Address some clippy lints in WebRender API. r=Gankro Differential Revision: https://phabricator.services.mozilla.com/D59101
gfx/wr/webrender_api/src/api.rs
gfx/wr/webrender_api/src/color.rs
gfx/wr/webrender_api/src/display_item.rs
gfx/wr/webrender_api/src/display_list.rs
gfx/wr/webrender_api/src/font.rs
gfx/wr/webrender_api/src/image.rs
gfx/wr/webrender_api/src/lib.rs
--- a/gfx/wr/webrender_api/src/api.rs
+++ b/gfx/wr/webrender_api/src/api.rs
@@ -1631,17 +1631,17 @@ impl RenderApi {
                     let (msg, payloads) = transaction.finalize();
                     msgs.push(msg);
                     document_payloads.push(payloads);
                     (msgs, document_payloads)
                 });
         for payload in document_payloads.drain(..).flatten() {
             self.payload_sender.send_payload(payload).unwrap();
         }
-        self.api_sender.send(ApiMsg::UpdateDocuments(document_ids.clone(), msgs)).unwrap();
+        self.api_sender.send(ApiMsg::UpdateDocuments(document_ids, msgs)).unwrap();
     }
 
     /// Does a hit test on display items in the specified document, at the given
     /// point. If a pipeline_id is specified, it is used to further restrict the
     /// hit results so that only items inside that pipeline are matched. If the
     /// HitTestFlags argument contains the FIND_ALL flag, then the vector of hit
     /// results will contain all display items that match, ordered from front
     /// to back.
@@ -1774,17 +1774,17 @@ pub struct ZoomFactor(f32);
 
 impl ZoomFactor {
     /// Construct a new zoom factor.
     pub fn new(scale: f32) -> Self {
         ZoomFactor(scale)
     }
 
     /// Get the zoom factor as an untyped float.
-    pub fn get(&self) -> f32 {
+    pub fn get(self) -> f32 {
         self.0
     }
 }
 
 /// A key to identify an animated property binding.
 #[repr(C)]
 #[derive(Clone, Copy, Debug, Default, Deserialize, MallocSizeOf, PartialEq, Serialize, Eq, Hash, PeekPoke)]
 pub struct PropertyBindingId {
@@ -1810,18 +1810,18 @@ pub struct PropertyBindingKey<T> {
     ///
     pub id: PropertyBindingId,
     _phantom: PhantomData<T>,
 }
 
 /// Construct a property value from a given key and value.
 impl<T: Copy> PropertyBindingKey<T> {
     ///
-    pub fn with(&self, value: T) -> PropertyValue<T> {
-        PropertyValue { key: *self, value }
+    pub fn with(self, value: T) -> PropertyValue<T> {
+        PropertyValue { key: self, value }
     }
 }
 
 impl<T> PropertyBindingKey<T> {
     /// Constructor.
     pub fn new(value: u64) -> Self {
         PropertyBindingKey {
             id: PropertyBindingId::new(value),
--- a/gfx/wr/webrender_api/src/color.rs
+++ b/gfx/wr/webrender_api/src/color.rs
@@ -90,16 +90,18 @@ impl ColorF {
 
 // Floats don't impl Hash/Eq/Ord...
 impl Eq for PremultipliedColorF {}
 impl Ord for PremultipliedColorF {
     fn cmp(&self, other: &Self) -> cmp::Ordering {
         self.partial_cmp(other).unwrap_or(cmp::Ordering::Equal)
     }
 }
+
+#[cfg_attr(feature = "cargo-clippy", allow(clippy::derive_hash_xor_eq))]
 impl Hash for PremultipliedColorF {
     fn hash<H: Hasher>(&self, state: &mut H) {
         // Note: this is inconsistent with the Eq impl for -0.0 (don't care).
         self.r.to_bits().hash(state);
         self.g.to_bits().hash(state);
         self.b.to_bits().hash(state);
         self.a.to_bits().hash(state);
     }
--- a/gfx/wr/webrender_api/src/display_item.rs
+++ b/gfx/wr/webrender_api/src/display_item.rs
@@ -528,18 +528,18 @@ pub enum BorderStyle {
     Hidden = 5,
     Groove = 6,
     Ridge = 7,
     Inset = 8,
     Outset = 9,
 }
 
 impl BorderStyle {
-    pub fn is_hidden(&self) -> bool {
-        *self == BorderStyle::Hidden || *self == BorderStyle::None
+    pub fn is_hidden(self) -> bool {
+        self == BorderStyle::Hidden || self == BorderStyle::None
     }
 }
 
 #[repr(u8)]
 #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize, PeekPoke)]
 pub enum BoxShadowClipMode {
     Outset = 0,
     Inset = 1,
@@ -713,18 +713,18 @@ pub enum RasterSpace {
     // Rasterize the picture in screen-space, including rotation / skew etc in
     // the rasterized element. Best quality, but slower performance. Note that
     // any stacking context with a perspective transform will be rasterized
     // in local-space, even if this is set.
     Screen,
 }
 
 impl RasterSpace {
-    pub fn local_scale(&self) -> Option<f32> {
-        match *self {
+    pub fn local_scale(self) -> Option<f32> {
+        match self {
             RasterSpace::Local(scale) => Some(scale),
             RasterSpace::Screen => None,
         }
     }
 }
 
 #[repr(u8)]
 #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize, PeekPoke)]
@@ -1193,18 +1193,18 @@ impl YuvData {
 #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize, PeekPoke)]
 pub enum YuvFormat {
     NV12 = 0,
     PlanarYCbCr = 1,
     InterleavedYCbCr = 2,
 }
 
 impl YuvFormat {
-    pub fn get_plane_num(&self) -> usize {
-        match *self {
+    pub fn get_plane_num(self) -> usize {
+        match self {
             YuvFormat::NV12 => 2,
             YuvFormat::PlanarYCbCr => 3,
             YuvFormat::InterleavedYCbCr => 1,
         }
     }
 }
 
 #[repr(C)]
--- a/gfx/wr/webrender_api/src/display_list.rs
+++ b/gfx/wr/webrender_api/src/display_list.rs
@@ -1355,17 +1355,17 @@ impl DisplayListBuilder {
     }
 
     pub fn push_filters(
         &mut self,
         filters: &[di::FilterOp],
         filter_datas: &[di::FilterData],
         filter_primitives: &[di::FilterPrimitive],
     ) {
-        if filters.len() > 0 {
+        if !filters.is_empty() {
             self.push_item(&di::DisplayItem::SetFilterOps);
             self.push_iter(filters);
         }
 
         for filter_data in filter_datas {
             let func_types = [
                 filter_data.func_r_type, filter_data.func_g_type,
                 filter_data.func_b_type, filter_data.func_a_type];
--- a/gfx/wr/webrender_api/src/font.rs
+++ b/gfx/wr/webrender_api/src/font.rs
@@ -397,16 +397,17 @@ impl Default for GlyphInstance {
             index: 0,
             point: LayoutPoint::zero(),
         }
     }
 }
 
 impl Eq for GlyphInstance {}
 
+#[cfg_attr(feature = "cargo-clippy", allow(clippy::derive_hash_xor_eq))]
 impl Hash for GlyphInstance {
     fn hash<H: Hasher>(&self, state: &mut H) {
         // Note: this is inconsistent with the Eq impl for -0.0 (don't care).
         self.index.hash(state);
         self.point.x.to_bits().hash(state);
         self.point.y.to_bits().hash(state);
     }
 }
--- a/gfx/wr/webrender_api/src/image.rs
+++ b/gfx/wr/webrender_api/src/image.rs
@@ -41,17 +41,17 @@ impl ImageKey {
 /// This is used as a handle to reference blob images, and can be used as an
 /// image in display items.
 #[repr(C)]
 #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
 pub struct BlobImageKey(pub ImageKey);
 
 impl BlobImageKey {
     /// Interpret this blob image as an image for a display item.
-    pub fn as_image(&self) -> ImageKey {
+    pub fn as_image(self) -> ImageKey {
         self.0
     }
 }
 
 /// An arbitrary identifier for an external image provided by the
 /// application. It must be a unique identifier for each external
 /// image.
 #[repr(C)]
--- a/gfx/wr/webrender_api/src/lib.rs
+++ b/gfx/wr/webrender_api/src/lib.rs
@@ -7,17 +7,17 @@
 //!
 //! This separation allows Servo to parallelize compilation across `webrender`
 //! and other crates that depend on `webrender_api`. So in practice, we put
 //! things in this crate when Servo needs to use them. Firefox depends on the
 //! `webrender` crate directly, and so this distinction is not really relevant
 //! there.
 
 #![cfg_attr(feature = "nightly", feature(nonzero))]
-#![cfg_attr(feature = "cargo-clippy", allow(float_cmp, too_many_arguments, unreadable_literal))]
+#![cfg_attr(feature = "cargo-clippy", allow(clippy::float_cmp, clippy::too_many_arguments, clippy::unreadable_literal, clippy::new_without_default))]
 
 extern crate app_units;
 #[macro_use]
 extern crate bitflags;
 extern crate byteorder;
 #[cfg(feature = "nightly")]
 extern crate core;
 #[cfg(target_os = "macos")]