Bug 1607697 - Miscellaneous clippy lint fixes. r=Gankro
☠☠ backed out by c2dd65b196d3 ☠ ☠
authorNicolas Silva <nsilva@mozilla.com>
Wed, 08 Jan 2020 15:41:42 +0000
changeset 509369 a3942fa2644c5881a4d92770f0850229c3996fc8
parent 509368 6bf3305bb6893affecdbde816a7bf856a7ed13f1
child 509370 fb4b94f0ff6c69f4875bcd496171cf3a1b3847a9
push id36995
push userapavel@mozilla.com
push dateWed, 08 Jan 2020 21:56:06 +0000
treeherdermozilla-central@374a48ce8690 [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 - Miscellaneous clippy lint fixes. r=Gankro Differential Revision: https://phabricator.services.mozilla.com/D59118
gfx/wr/webrender/src/filterdata.rs
gfx/wr/webrender/src/picture.rs
gfx/wr/webrender/src/platform/unix/font.rs
gfx/wr/webrender/src/platform/windows/font.rs
gfx/wr/webrender/src/profiler.rs
gfx/wr/webrender/src/renderer.rs
gfx/wr/webrender/src/scene_builder_thread.rs
gfx/wr/webrender/src/scene_building.rs
gfx/wr/webrender/src/spatial_node.rs
--- a/gfx/wr/webrender/src/filterdata.rs
+++ b/gfx/wr/webrender/src/filterdata.rs
@@ -160,17 +160,17 @@ impl intern::Internable for FilterDataIn
     type InternData = ();
 }
 
 fn push_component_transfer_data(
     func_comp: &SFilterDataComponent,
     request: &mut GpuDataRequest,
 ) {
     match func_comp {
-        SFilterDataComponent::Identity => { return; }
+        SFilterDataComponent::Identity => {}
         SFilterDataComponent::Table(values) |
         SFilterDataComponent::Discrete(values) => {
             // Push a 256 entry lookup table.
             assert!(values.len() > 0);
             for i in 0 .. 64 {
                 let mut arr = [0.0 ; 4];
                 for j in 0 .. 4 {
                     if (values.len() == 1) || (i == 63 && j == 3) {
--- a/gfx/wr/webrender/src/picture.rs
+++ b/gfx/wr/webrender/src/picture.rs
@@ -1345,17 +1345,17 @@ impl DirtyRegion {
             dirty_rects,
             combined,
         }
     }
 
     /// Creates a record of this dirty region for exporting to test infrastructure.
     pub fn record(&self) -> RecordedDirtyRegion {
         let mut rects: Vec<WorldRect> =
-            self.dirty_rects.iter().map(|r| r.world_rect.clone()).collect();
+            self.dirty_rects.iter().map(|r| r.world_rect).collect();
         rects.sort_unstable_by_key(|r| (r.origin.y as usize, r.origin.x as usize));
         RecordedDirtyRegion { rects }
     }
 }
 
 /// A recorded copy of the dirty region for exporting to test infrastructure.
 #[cfg_attr(feature = "capture", derive(Serialize))]
 pub struct RecordedDirtyRegion {
@@ -5100,17 +5100,17 @@ impl TileNode {
 
                 // Create the child nodes and switch from leaf -> node.
                 let children = child_indices
                     .iter_mut()
                     .map(|i| TileNode::new_leaf(mem::replace(i, Vec::new())))
                     .collect();
 
                 self.kind = TileNodeKind::Node {
-                    children: children,
+                    children,
                 };
             }
             Some(TileModification::Merge) => {
                 // Construct a merged index buffer by collecting the dependency index buffers
                 // from each child, and merging them into a de-duplicated index buffer.
                 let merged_indices = match self.kind {
                     TileNodeKind::Node { ref mut children, .. } => {
                         let mut merged_indices = Vec::new();
--- a/gfx/wr/webrender/src/platform/unix/font.rs
+++ b/gfx/wr/webrender/src/platform/unix/font.rs
@@ -360,17 +360,17 @@ impl FontContext {
             let index = native_font_handle.index;
             if let Some(face) = new_ft_face(font_key, self.lib, &file, index) {
                 self.faces.insert(*font_key, FontFace { file, index, face, mm_var: ptr::null_mut() });
             }
         }
     }
 
     pub fn delete_font(&mut self, font_key: &FontKey) {
-        if let Some(_) = self.faces.remove(font_key) {
+        if self.faces.remove(font_key).is_some() {
             self.variations.retain(|k, _| k.0 != *font_key);
         }
     }
 
     pub fn delete_font_instance(&mut self, instance: &FontInstance) {
         // Ensure we don't keep around excessive amounts of stale variations.
         if !instance.variations.is_empty() {
             self.variations.remove(&(instance.font_key, instance.variations.clone()));
--- a/gfx/wr/webrender/src/platform/windows/font.rs
+++ b/gfx/wr/webrender/src/platform/windows/font.rs
@@ -248,17 +248,17 @@ impl FontContext {
             let current_height = i * width * 3;
 
             for pixel in data[current_height .. current_height + (width * 3)].chunks(3) {
                 let r = pixel[0];
                 let g = pixel[1];
                 let b = pixel[2];
                 print!("({}, {}, {}) ", r, g, b,);
             }
-            println!("");
+            println!();
         }
     }
 
     fn get_font_face(
         &mut self,
         font: &FontInstance,
     ) -> &dwrote::FontFace {
         if !font.flags.contains(FontInstanceFlags::SYNTHETIC_BOLD) &&
--- a/gfx/wr/webrender/src/profiler.rs
+++ b/gfx/wr/webrender/src/profiler.rs
@@ -953,22 +953,22 @@ impl ProfileGraph {
         let mut stats = GraphStats {
             min_value: f32::MAX,
             mean_value: 0.0,
             max_value: -f32::MAX,
         };
 
         for value in &self.values {
             stats.min_value = stats.min_value.min(*value);
-            stats.mean_value = stats.mean_value + *value;
+            stats.mean_value += *value;
             stats.max_value = stats.max_value.max(*value);
         }
 
         if !self.values.is_empty() {
-            stats.mean_value = stats.mean_value / self.values.len() as f32;
+            stats.mean_value /= self.values.len() as f32;
         }
 
         stats
     }
 
     fn draw_graph(
         &self,
         x: f32,
--- a/gfx/wr/webrender/src/renderer.rs
+++ b/gfx/wr/webrender/src/renderer.rs
@@ -3361,17 +3361,17 @@ impl Renderer {
                 self.gpu_cache_frame_id = update_list.frame_id
             }
             self.gpu_cache_texture
                 .update(&mut self.device, &update_list);
         }
 
         let mut upload_time = TimeProfileCounter::new("GPU cache upload time", false, Some(0.0..2.0));
         let updated_rows = upload_time.profile(|| {
-            return self.gpu_cache_texture.flush(&mut self.device);
+            self.gpu_cache_texture.flush(&mut self.device)
         });
         self.gpu_cache_upload_time += upload_time.get();
 
         let counters = &mut self.backend_profile_counters.resources.gpu_cache;
         counters.updated_rows.set(updated_rows);
         counters.updated_blocks.set(updated_blocks);
     }
 
@@ -4561,17 +4561,17 @@ impl Renderer {
                 stats,
             );
         }
         // draw box-shadow clips
         for (mask_texture_id, items) in list.box_shadows.iter() {
             let _gm2 = self.gpu_profile.start_marker("box-shadows");
             let textures = BatchTextures {
                 colors: [
-                    mask_texture_id.clone(),
+                    *mask_texture_id,
                     TextureSource::Invalid,
                     TextureSource::Invalid,
                 ],
             };
             self.shaders.borrow_mut().cs_clip_box_shadow
                 .bind(&mut self.device, projection, &mut self.renderer_errors);
             self.draw_instanced_batch(
                 items,
@@ -4581,17 +4581,17 @@ impl Renderer {
             );
         }
 
         // draw image masks
         for (mask_texture_id, items) in list.images.iter() {
             let _gm2 = self.gpu_profile.start_marker("clip images");
             let textures = BatchTextures {
                 colors: [
-                    mask_texture_id.clone(),
+                    *mask_texture_id,
                     TextureSource::Invalid,
                     TextureSource::Invalid,
                 ],
             };
             self.shaders.borrow_mut().cs_clip_image
                 .bind(&mut self.device, projection, &mut self.renderer_errors);
             self.draw_instanced_batch(
                 items,
@@ -5491,17 +5491,17 @@ impl Renderer {
             VertexArrayKind::Resolve,
             &BatchTextures::no_texture(),
             stats,
         );
 
         self.device.enable_pixel_local_storage(false);
     }
 
-    pub fn debug_renderer<'b>(&'b mut self) -> Option<&'b mut DebugRenderer> {
+    pub fn debug_renderer(&mut self) -> Option<&mut DebugRenderer> {
         self.debug.get_mut(&mut self.device)
     }
 
     pub fn get_debug_flags(&self) -> DebugFlags {
         self.debug_flags
     }
 
     pub fn set_debug_flags(&mut self, flags: DebugFlags) {
@@ -5833,17 +5833,17 @@ impl Renderer {
                 ColorU::new(255, 255, 0, 255),
                 None,
             ).size.width;
             text_width = f32::max(text_width, w);
         }
 
         let margin = 10.0;
         debug_renderer.add_quad(
-            &x0 - margin,
+            x0 - margin,
             y0 - margin,
             x0 + text_width + margin,
             y + margin,
             ColorU::new(25, 25, 25, 200),
             ColorU::new(51, 51, 51, 200),
         );
     }
 
@@ -6756,19 +6756,17 @@ impl Renderer {
         }
 
         self.output_image_handler = Some(Box::new(VoidHandler) as Box<_>);
         self.external_image_handler = Some(Box::new(image_handler) as Box<_>);
         info!("done.");
     }
 }
 
-fn get_vao<'a>(vertex_array_kind: VertexArrayKind,
-               vaos: &'a RendererVAOs)
-               -> &'a VAO {
+fn get_vao(vertex_array_kind: VertexArrayKind, vaos: &RendererVAOs) -> &VAO {
     match vertex_array_kind {
         VertexArrayKind::Primitive => &vaos.prim_vao,
         VertexArrayKind::Clip => &vaos.clip_vao,
         VertexArrayKind::Blur => &vaos.blur_vao,
         VertexArrayKind::VectorStencil | VertexArrayKind::VectorCover => unreachable!(),
         VertexArrayKind::Border => &vaos.border_vao,
         VertexArrayKind::Scale => &vaos.scale_vao,
         VertexArrayKind::LineDecoration => &vaos.line_vao,
--- a/gfx/wr/webrender/src/scene_builder_thread.rs
+++ b/gfx/wr/webrender/src/scene_builder_thread.rs
@@ -513,17 +513,17 @@ impl SceneBuilderThread {
             docs.add(debug_doc);
         }
 
         serde_json::to_string(&docs).unwrap()
     }
 
     /// Do the bulk of the work of the scene builder thread.
     fn process_transaction(&mut self, txn: &mut Transaction) -> Box<BuiltTransaction> {
-        if let &Some(ref hooks) = &self.hooks {
+        if let Some(ref hooks) = self.hooks {
             hooks.pre_scene_build();
         }
 
         let scene_build_start_time = precise_time_ns();
 
         let doc = self.documents
                       .entry(txn.document_id)
                       .or_insert_with(|| Document::new(Scene::new()));
@@ -607,18 +607,18 @@ impl SceneBuilderThread {
             interner_updates,
             scene_build_start_time,
             scene_build_end_time,
         })
     }
 
     /// Send the results of process_transaction back to the render backend.
     fn forward_built_transactions(&mut self, txns: Vec<Box<BuiltTransaction>>) {
-        let (pipeline_info, result_tx, result_rx) = match &self.hooks {
-            &Some(ref hooks) => {
+        let (pipeline_info, result_tx, result_rx) = match self.hooks {
+            Some(ref hooks) => {
                 if txns.iter().any(|txn| txn.built_scene.is_some()) {
                     let info = PipelineInfo {
                         epochs: txns.iter()
                             .filter(|txn| txn.built_scene.is_some())
                             .map(|txn| {
                                 txn.built_scene.as_ref().unwrap()
                                     .pipeline_epochs.iter()
                                     .zip(iter::repeat(txn.document_id))
@@ -641,41 +641,38 @@ impl SceneBuilderThread {
             _ => (None, None, None)
         };
 
         let scene_swap_start_time = precise_time_ns();
         let document_ids = txns.iter().map(|txn| txn.document_id).collect();
         let have_resources_updates : Vec<DocumentId> = if pipeline_info.is_none() {
             txns.iter()
                 .filter(|txn| !txn.resource_updates.is_empty() || txn.invalidate_rendered_frame)
-                .map(|txn| txn.document_id.clone())
+                .map(|txn| txn.document_id)
                 .collect()
         } else {
             Vec::new()
         };
 
         self.tx.send(SceneBuilderResult::Transactions(txns, result_tx)).unwrap();
 
         let _ = self.api_tx.send(ApiMsg::WakeUp);
 
         if let Some(pipeline_info) = pipeline_info {
             // Block until the swap is done, then invoke the hook.
             let swap_result = result_rx.unwrap().recv();
             let scene_swap_time = precise_time_ns() - scene_swap_start_time;
             self.hooks.as_ref().unwrap().post_scene_swap(&document_ids,
                                                          pipeline_info, scene_swap_time);
             // Once the hook is done, allow the RB thread to resume
-            match swap_result {
-                Ok(SceneSwapResult::Complete(resume_tx)) => {
-                    resume_tx.send(()).ok();
-                },
-                _ => (),
-            };
+            if let Ok(SceneSwapResult::Complete(resume_tx)) = swap_result {
+                resume_tx.send(()).ok();
+            }
         } else if !have_resources_updates.is_empty() {
-            if let &Some(ref hooks) = &self.hooks {
+            if let Some(ref hooks) = self.hooks {
                 hooks.post_resource_update(&have_resources_updates);
             }
         } else if let Some(ref hooks) = self.hooks {
             hooks.post_empty_scene_build();
         }
     }
 
     /// Reports CPU heap memory used by the SceneBuilder.
--- a/gfx/wr/webrender/src/scene_building.rs
+++ b/gfx/wr/webrender/src/scene_building.rs
@@ -722,17 +722,17 @@ impl<'a> SceneBuilder<'a> {
             for (label, stats) in stats {
                 println!("{}, {}, {}kb, {}%, {}",
                     label,
                     stats.total_count,
                     stats.num_bytes / 1000,
                     ((stats.num_bytes as f32 / total_bytes.max(1) as f32) * 100.0) as usize,
                     stats.num_bytes / stats.total_count.max(1));
             }
-            println!("");
+            println!();
         }
     }
 
     fn build_sticky_frame(
         &mut self,
         info: &StickyFrameDisplayItem,
         parent_node_index: SpatialNodeIndex,
     ) {
@@ -3735,17 +3735,17 @@ impl FlattenedStackingContext {
 
         // If there are svg filters
         if !self.composite_ops.filter_primitives.is_empty() {
             return false;
         }
 
         // We can skip mix-blend modes if they are the first primitive in a stacking context,
         // see pop_stacking_context for a full explanation.
-        if !self.composite_ops.mix_blend_mode.is_none() &&
+        if self.composite_ops.mix_blend_mode.is_some() &&
             !parent.prim_list.is_empty() {
             return false;
         }
 
         // If backface visibility is explicitly set.
         if !self.prim_flags.contains(PrimitiveFlags::IS_BACKFACE_VISIBLE) {
             return false;
         }
@@ -3948,17 +3948,17 @@ fn filter_datas_for_compositing(
 
 fn filter_primitives_for_compositing(
     input_filter_primitives: ItemRange<FilterPrimitive>,
 ) -> Vec<FilterPrimitive> {
     // Resolve these in the flattener?
     // TODO(gw): Now that we resolve these later on,
     //           we could probably make it a bit
     //           more efficient than cloning these here.
-    input_filter_primitives.iter().map(|primitive| primitive.into()).collect()
+    input_filter_primitives.iter().map(|primitive| primitive).collect()
 }
 
 fn process_repeat_size(
     snapped_rect: &LayoutRect,
     unsnapped_rect: &LayoutRect,
     repeat_size: LayoutSize,
 ) -> LayoutSize {
     LayoutSize::new(
--- a/gfx/wr/webrender/src/spatial_node.rs
+++ b/gfx/wr/webrender/src/spatial_node.rs
@@ -295,17 +295,16 @@ impl SpatialNode {
         self.is_ancestor_or_self_zooming = self.is_async_zooming | is_parent_zooming;
 
         // If this node is a reference frame, we check if it has a non-invertible matrix.
         // For non-reference-frames we assume that they will produce only additional
         // translations which should be invertible.
         match self.node_type {
             SpatialNodeType::ReferenceFrame(info) if !info.invertible => {
                 self.mark_uninvertible(state);
-                return;
             }
             _ => self.invertible = true,
         }
     }
 
     pub fn update_transform(
         &mut self,
         state: &mut TransformUpdateState,