From 70fcb354447404e2495bc0d8427f8bee3f83658a Mon Sep 17 00:00:00 2001 From: Prikshit Gautam Date: Wed, 7 Jun 2023 14:46:47 +0530 Subject: [PATCH] Remove warnings from build and satisfied clippy (#1288) * Prefixed unused functions with underscore * Applied clippy lints * Fixed some warnings and removed some `allow` statements --- .../document/node_graph/node_graph_message_handler.rs | 4 ++-- .../node_graph_message_handler/node_properties.rs | 6 ++++-- .../common_functionality/graph_modification_utils.rs | 4 ++-- .../tool/common_functionality/overlay_renderer.rs | 2 +- editor/src/messages/tool/tool_messages/brush_tool.rs | 2 +- editor/src/messages/tool/tool_messages/ellipse_tool.rs | 2 +- editor/src/messages/tool/tool_messages/freehand_tool.rs | 2 +- editor/src/messages/tool/tool_messages/pen_tool.rs | 2 +- editor/src/messages/tool/tool_messages/rectangle_tool.rs | 2 +- editor/src/messages/tool/tool_messages/select_tool.rs | 3 ++- editor/src/messages/tool/tool_messages/shape_tool.rs | 2 +- editor/src/messages/tool/tool_messages/spline_tool.rs | 2 +- editor/src/messages/tool/tool_messages/text_tool.rs | 3 ++- editor/src/messages/tool/utility_types.rs | 1 + editor/src/node_graph_executor.rs | 5 ----- libraries/dyn-any/src/lib.rs | 2 +- node-graph/compilation-client/src/main.rs | 1 - .../gcore/src/application_io/wasm_application_io.rs | 6 +++--- node-graph/gcore/src/raster/adjustments.rs | 4 ++-- node-graph/gcore/src/raster/discrete_srgb.rs | 1 + node-graph/gcore/src/raster/image.rs | 4 ++-- node-graph/gcore/src/text/to_path.rs | 9 +++++---- node-graph/gcore/src/uuid.rs | 2 +- node-graph/gcore/src/value.rs | 4 ++-- node-graph/graph-craft/src/document.rs | 2 +- node-graph/graph-craft/src/proto.rs | 6 +++--- node-graph/gstd/src/any.rs | 2 +- node-graph/gstd/src/brush.rs | 2 +- node-graph/gstd/src/executor.rs | 6 +----- node-graph/interpreted-executor/src/dynamic_executor.rs | 4 ++-- node-graph/interpreted-executor/src/lib.rs | 4 ++-- node-graph/wgpu-executor/src/lib.rs | 7 +++---- website/other/bezier-rs-demos/wasm/src/subpath.rs | 6 ++---- 33 files changed, 54 insertions(+), 60 deletions(-) diff --git a/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs b/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs index 4ba1500d..a0bbb565 100644 --- a/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs +++ b/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs @@ -168,8 +168,8 @@ impl NodeGraphMessageHandler { fn collect_nested_addresses(&mut self, document: &Document, responses: &mut VecDeque) { // // Build path list let mut path = vec![]; - if let Some(layer) = self.layer_path.as_ref().and_then(|path| document.layer(&path).ok()) { - path.push(format!("Layer: {}", layer.name.as_ref().map(|name| name.as_str()).unwrap_or("Untitled Layer"))); + if let Some(layer) = self.layer_path.as_ref().and_then(|path| document.layer(path).ok()) { + path.push(format!("Layer: {}", layer.name.as_deref().unwrap_or("Untitled Layer"))); } else { path.push("Document Network".to_string()); } diff --git a/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler/node_properties.rs b/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler/node_properties.rs index 6454112f..138e64ff 100644 --- a/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler/node_properties.rs +++ b/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler/node_properties.rs @@ -1,3 +1,5 @@ +#![allow(clippy::too_many_arguments)] + use super::document_node_types::NodePropertiesContext; use super::FrontendGraphDataType; use crate::messages::layout::utility_types::widget_prelude::*; @@ -699,7 +701,7 @@ pub fn brightness_contrast_properties(document_node: &DocumentNode, node_id: Nod ] } -pub fn blur_image_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec { +pub fn _blur_image_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec { let radius = number_widget(document_node, node_id, 1, "Radius", NumberInput::default().min(0.).max(20.).int(), true); let sigma = number_widget(document_node, node_id, 2, "Sigma", NumberInput::default().min(0.).max(10000.), true); @@ -869,7 +871,7 @@ pub fn adjust_selective_color_properties(document_node: &DocumentNode, node_id: } #[cfg(feature = "gpu")] -pub fn gpu_map_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec { +pub fn _gpu_map_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec { let map = text_widget(document_node, node_id, 1, "Map", true); vec![LayoutGroup::Row { widgets: map }] diff --git a/editor/src/messages/tool/common_functionality/graph_modification_utils.rs b/editor/src/messages/tool/common_functionality/graph_modification_utils.rs index 841bf6fa..7bef3c62 100644 --- a/editor/src/messages/tool/common_functionality/graph_modification_utils.rs +++ b/editor/src/messages/tool/common_functionality/graph_modification_utils.rs @@ -27,10 +27,10 @@ pub fn new_custom_layer(network: NodeNetwork, layer_path: Vec, response responses.add(DocumentMessage::InputFrameRasterizeRegionBelowLayer { layer_path }); } -pub fn set_manipulator_mirror_angle(manipulator_groups: &Vec>, layer_path: &Vec, mirror_angle: bool, responses: &mut VecDeque) { +pub fn set_manipulator_mirror_angle(manipulator_groups: &Vec>, layer_path: &[u64], mirror_angle: bool, responses: &mut VecDeque) { for manipulator_group in manipulator_groups { responses.add(GraphOperationMessage::Vector { - layer: layer_path.clone(), + layer: layer_path.to_owned(), modification: VectorDataModification::SetManipulatorHandleMirroring { id: manipulator_group.id, mirror_angle, diff --git a/editor/src/messages/tool/common_functionality/overlay_renderer.rs b/editor/src/messages/tool/common_functionality/overlay_renderer.rs index 8486babe..28a185e0 100644 --- a/editor/src/messages/tool/common_functionality/overlay_renderer.rs +++ b/editor/src/messages/tool/common_functionality/overlay_renderer.rs @@ -123,7 +123,7 @@ impl OverlayRenderer { responses.add(OverlaysMessage::Rerender); } - pub fn clear_subpath_overlays(&mut self, document: &Document, layer_path: Vec, responses: &mut VecDeque) { + pub fn clear_subpath_overlays(&mut self, _document: &Document, layer_path: Vec, responses: &mut VecDeque) { let layer_id = layer_path.last().unwrap(); // Remove the shape outline overlays diff --git a/editor/src/messages/tool/tool_messages/brush_tool.rs b/editor/src/messages/tool/tool_messages/brush_tool.rs index 6c88bcb9..00459268 100644 --- a/editor/src/messages/tool/tool_messages/brush_tool.rs +++ b/editor/src/messages/tool/tool_messages/brush_tool.rs @@ -22,7 +22,7 @@ use graphene_core::Color; use glam::DAffine2; use serde::{Deserialize, Serialize}; -const EXPOSED_BLEND_MODES: &'static [&'static [BlendMode]] = { +const EXPOSED_BLEND_MODES: &[&[BlendMode]] = { use BlendMode::*; &[ // Basic group diff --git a/editor/src/messages/tool/tool_messages/ellipse_tool.rs b/editor/src/messages/tool/tool_messages/ellipse_tool.rs index 6f5ada2d..69c33df9 100644 --- a/editor/src/messages/tool/tool_messages/ellipse_tool.rs +++ b/editor/src/messages/tool/tool_messages/ellipse_tool.rs @@ -231,7 +231,7 @@ impl Fsm for EllipseToolFsmState { let fill_color = tool_options.fill.active_color(); responses.add(GraphOperationMessage::FillSet { layer: layer_path.clone(), - fill: if fill_color.is_some() { Fill::Solid(fill_color.unwrap()) } else { Fill::None }, + fill: if let Some(color) = fill_color { Fill::Solid(color) } else { Fill::None }, }); responses.add(GraphOperationMessage::StrokeSet { diff --git a/editor/src/messages/tool/tool_messages/freehand_tool.rs b/editor/src/messages/tool/tool_messages/freehand_tool.rs index 72a03174..cd7bd056 100644 --- a/editor/src/messages/tool/tool_messages/freehand_tool.rs +++ b/editor/src/messages/tool/tool_messages/freehand_tool.rs @@ -293,7 +293,7 @@ fn add_polyline(data: &FreehandToolData, stroke_color: Option, fill_color responses.add(GraphOperationMessage::FillSet { layer: layer_path.clone(), - fill: if fill_color.is_some() { Fill::Solid(fill_color.unwrap()) } else { Fill::None }, + fill: if let Some(color) = fill_color { Fill::Solid(color) } else { Fill::None }, }); responses.add(GraphOperationMessage::StrokeSet { diff --git a/editor/src/messages/tool/tool_messages/pen_tool.rs b/editor/src/messages/tool/tool_messages/pen_tool.rs index ccd3d0ae..1dc84cf1 100644 --- a/editor/src/messages/tool/tool_messages/pen_tool.rs +++ b/editor/src/messages/tool/tool_messages/pen_tool.rs @@ -269,7 +269,7 @@ impl PenToolData { responses.add(GraphOperationMessage::FillSet { layer: layer_path.clone(), - fill: if fill_color.is_some() { Fill::Solid(fill_color.unwrap()) } else { Fill::None }, + fill: if let Some(color) = fill_color { Fill::Solid(color) } else { Fill::None }, }); responses.add(GraphOperationMessage::StrokeSet { diff --git a/editor/src/messages/tool/tool_messages/rectangle_tool.rs b/editor/src/messages/tool/tool_messages/rectangle_tool.rs index b68823a6..8168647f 100644 --- a/editor/src/messages/tool/tool_messages/rectangle_tool.rs +++ b/editor/src/messages/tool/tool_messages/rectangle_tool.rs @@ -226,7 +226,7 @@ impl Fsm for RectangleToolFsmState { let fill_color = tool_options.fill.active_color(); responses.add(GraphOperationMessage::FillSet { layer: layer_path.clone(), - fill: if fill_color.is_some() { Fill::Solid(fill_color.unwrap()) } else { Fill::None }, + fill: if let Some(color) = fill_color { Fill::Solid(color) } else { Fill::None }, }); responses.add(GraphOperationMessage::StrokeSet { diff --git a/editor/src/messages/tool/tool_messages/select_tool.rs b/editor/src/messages/tool/tool_messages/select_tool.rs index 27c750e0..bd562082 100644 --- a/editor/src/messages/tool/tool_messages/select_tool.rs +++ b/editor/src/messages/tool/tool_messages/select_tool.rs @@ -1,3 +1,4 @@ +#![allow(clippy::too_many_arguments)] use crate::application::generate_uuid; use crate::consts::{ROTATE_SNAP_ANGLE, SELECTION_TOLERANCE}; use crate::messages::frontend::utility_types::MouseCursorIcon; @@ -1219,7 +1220,7 @@ fn edit_layer_deepest_manipulation(intersect: &Layer, responses: &mut VecDeque, incoming_layer_path_vector: &Vec) -> bool { +fn recursive_search(document: &DocumentMessageHandler, layer_path: &[u64], incoming_layer_path_vector: &Vec) -> bool { let layer_paths = document.document_legacy.folder_children_paths(layer_path); for path in layer_paths { if path == *incoming_layer_path_vector || document.document_legacy.is_folder(path.clone()) && recursive_search(document, &path, incoming_layer_path_vector) { diff --git a/editor/src/messages/tool/tool_messages/shape_tool.rs b/editor/src/messages/tool/tool_messages/shape_tool.rs index 8fcb8a94..6e3d601f 100644 --- a/editor/src/messages/tool/tool_messages/shape_tool.rs +++ b/editor/src/messages/tool/tool_messages/shape_tool.rs @@ -244,7 +244,7 @@ impl Fsm for ShapeToolFsmState { let fill_color = tool_options.fill.active_color(); responses.add(GraphOperationMessage::FillSet { layer: layer_path.clone(), - fill: if fill_color.is_some() { Fill::Solid(fill_color.unwrap()) } else { Fill::None }, + fill: if let Some(color) = fill_color { Fill::Solid(color) } else { Fill::None }, }); responses.add(GraphOperationMessage::StrokeSet { diff --git a/editor/src/messages/tool/tool_messages/spline_tool.rs b/editor/src/messages/tool/tool_messages/spline_tool.rs index 2fef8517..603bc336 100644 --- a/editor/src/messages/tool/tool_messages/spline_tool.rs +++ b/editor/src/messages/tool/tool_messages/spline_tool.rs @@ -339,7 +339,7 @@ fn add_spline(tool_data: &SplineToolData, show_preview: bool, fill_color: Option responses.add(GraphOperationMessage::FillSet { layer: layer_path.clone(), - fill: if fill_color.is_some() { Fill::Solid(fill_color.unwrap()) } else { Fill::None }, + fill: if let Some(color) = fill_color { Fill::Solid(color) } else { Fill::None }, }); responses.add(GraphOperationMessage::StrokeSet { diff --git a/editor/src/messages/tool/tool_messages/text_tool.rs b/editor/src/messages/tool/tool_messages/text_tool.rs index d4738e11..42a46678 100644 --- a/editor/src/messages/tool/tool_messages/text_tool.rs +++ b/editor/src/messages/tool/tool_messages/text_tool.rs @@ -1,3 +1,5 @@ +#![allow(clippy::too_many_arguments)] + use crate::application::generate_uuid; use crate::consts::{COLOR_ACCENT, SELECTION_TOLERANCE}; use crate::messages::frontend::utility_types::MouseCursorIcon; @@ -209,7 +211,6 @@ impl ToolTransition for TextTool { tool_abort: Some(TextToolMessage::Abort.into()), selection_changed: Some(TextToolMessage::DocumentIsDirty.into()), working_color_changed: Some(TextToolMessage::WorkingColorChanged.into()), - ..Default::default() } } } diff --git a/editor/src/messages/tool/utility_types.rs b/editor/src/messages/tool/utility_types.rs index d664d200..fafc8f56 100644 --- a/editor/src/messages/tool/utility_types.rs +++ b/editor/src/messages/tool/utility_types.rs @@ -1,3 +1,4 @@ +#![allow(clippy::too_many_arguments)] use super::common_functionality::overlay_renderer::OverlayRenderer; use super::common_functionality::shape_editor::ShapeState; use super::tool_messages::*; diff --git a/editor/src/node_graph_executor.rs b/editor/src/node_graph_executor.rs index 8054d0a3..83f8243f 100644 --- a/editor/src/node_graph_executor.rs +++ b/editor/src/node_graph_executor.rs @@ -38,11 +38,6 @@ pub struct NodeRuntime { canvas_cache: HashMap, SurfaceId>, } -fn get_imaginate_index(name: &str) -> usize { - use crate::messages::portfolio::document::node_graph::IMAGINATE_NODE; - IMAGINATE_NODE.inputs.iter().position(|input| input.name == name).unwrap_or_else(|| panic!("Input {name} not found")) -} - enum NodeRuntimeMessage { GenerationRequest(GenerationRequest), FontCacheUpdate(FontCache), diff --git a/libraries/dyn-any/src/lib.rs b/libraries/dyn-any/src/lib.rs index cedf45c3..c85198c8 100644 --- a/libraries/dyn-any/src/lib.rs +++ b/libraries/dyn-any/src/lib.rs @@ -1,7 +1,7 @@ #![doc(html_root_url = "http://docs.rs/const-default/1.0.0")] #![cfg_attr(feature = "unstable-docs", feature(doc_cfg))] #![cfg_attr(not(feature = "std"), no_std)] - +#![allow(clippy::missing_safety_doc)] #[cfg(feature = "alloc")] extern crate alloc; diff --git a/node-graph/compilation-client/src/main.rs b/node-graph/compilation-client/src/main.rs index 87207e60..4adb6a81 100644 --- a/node-graph/compilation-client/src/main.rs +++ b/node-graph/compilation-client/src/main.rs @@ -70,6 +70,5 @@ fn add_network() -> NodeNetwork { .enumerate() .map(|(i, n)| (i as u64, n)) .collect(), - ..Default::default() } } diff --git a/node-graph/gcore/src/application_io/wasm_application_io.rs b/node-graph/gcore/src/application_io/wasm_application_io.rs index b16ea643..767d652b 100644 --- a/node-graph/gcore/src/application_io/wasm_application_io.rs +++ b/node-graph/gcore/src/application_io/wasm_application_io.rs @@ -53,7 +53,7 @@ impl ApplicationIo for WasmApplicationIo { let image_canvases_key = JsValue::from_str("imageCanvases"); let mut canvases = Reflect::get(&window, &image_canvases_key); - if let Err(_) = canvases { + if canvases.is_err() { Reflect::set(&JsValue::from(web_sys::window().unwrap()), &image_canvases_key, &Object::new()).unwrap(); canvases = Reflect::get(&window, &image_canvases_key); } @@ -117,11 +117,11 @@ async fn draw_image_frame_node<'a: 'input>(image: ImageFrame, surface_ha let canvas = surface_handle.surface.canvas().expect("Failed to get canvas"); canvas.set_width(image.image.width); canvas.set_height(image.image.height); - let image_data = web_sys::ImageData::new_with_u8_clamped_array_and_sh(array, image.image.width as u32, image.image.height as u32).expect("Failed to construct ImageData"); + let image_data = web_sys::ImageData::new_with_u8_clamped_array_and_sh(array, image.image.width, image.image.height).expect("Failed to construct ImageData"); surface_handle.surface.put_image_data(&image_data, 0.0, 0.0).unwrap(); } SurfaceHandleFrame { - surface_handle: surface_handle.into(), + surface_handle, transform: image.transform, } } diff --git a/node-graph/gcore/src/raster/adjustments.rs b/node-graph/gcore/src/raster/adjustments.rs index 021f8556..a91da0ca 100644 --- a/node-graph/gcore/src/raster/adjustments.rs +++ b/node-graph/gcore/src/raster/adjustments.rs @@ -1,6 +1,6 @@ +#![allow(clippy::too_many_arguments)] use super::Color; use crate::Node; - use core::fmt::Debug; use dyn_any::{DynAny, StaticType}; #[cfg(feature = "serde")] @@ -195,7 +195,7 @@ fn extract_channel_node(color: Color, channel: RedGreenBlue) -> Color { RedGreenBlue::Green => color.g(), RedGreenBlue::Blue => color.b(), }; - return color.map_rgb(|_| extracted_value); + color.map_rgb(|_| extracted_value) } #[derive(Debug, Clone, Copy, Default)] diff --git a/node-graph/gcore/src/raster/discrete_srgb.rs b/node-graph/gcore/src/raster/discrete_srgb.rs index e0749b03..f7ee28b2 100644 --- a/node-graph/gcore/src/raster/discrete_srgb.rs +++ b/node-graph/gcore/src/raster/discrete_srgb.rs @@ -1,3 +1,4 @@ +#![allow(clippy::neg_cmp_op_on_partial_ord)] //! Fast conversions between u8 sRGB and linear float. // Inspired by https://gist.github.com/rygorous/2203834, but with a slightly diff --git a/node-graph/gcore/src/raster/image.rs b/node-graph/gcore/src/raster/image.rs index bc35f4ec..8a72bb3b 100644 --- a/node-graph/gcore/src/raster/image.rs +++ b/node-graph/gcore/src/raster/image.rs @@ -13,7 +13,7 @@ mod base64_serde { use super::super::Pixel; use serde::{Deserialize, Deserializer, Serializer}; - pub fn as_base64(key: &Vec

, serializer: S) -> Result + pub fn as_base64(key: &[P], serializer: S) -> Result where S: Serializer, { @@ -27,7 +27,7 @@ mod base64_serde { { use serde::de::Error; - let color_from_chunk = |chunk: &[u8]| P::from_bytes(chunk.try_into().unwrap()); + let color_from_chunk = |chunk: &[u8]| P::from_bytes(chunk); let colors_from_bytes = |bytes: Vec| bytes.chunks_exact(P::byte_size()).map(color_from_chunk).collect(); diff --git a/node-graph/gcore/src/text/to_path.rs b/node-graph/gcore/src/text/to_path.rs index efc43042..66e22ab7 100644 --- a/node-graph/gcore/src/text/to_path.rs +++ b/node-graph/gcore/src/text/to_path.rs @@ -26,23 +26,24 @@ impl OutlineBuilder for Builder { if !self.current_subpath.is_empty() { self.other_subpaths.push(core::mem::replace(&mut self.current_subpath, Subpath::new(Vec::new(), false))); } - self.current_subpath.push_manipulator_group(ManipulatorGroup::new_anchor_with_id(self.point(x, y), self.id.next())); + self.current_subpath.push_manipulator_group(ManipulatorGroup::new_anchor_with_id(self.point(x, y), self.id.next_id())); } fn line_to(&mut self, x: f32, y: f32) { - self.current_subpath.push_manipulator_group(ManipulatorGroup::new_anchor_with_id(self.point(x, y), self.id.next())); + self.current_subpath.push_manipulator_group(ManipulatorGroup::new_anchor_with_id(self.point(x, y), self.id.next_id())); } fn quad_to(&mut self, x1: f32, y1: f32, x2: f32, y2: f32) { let [handle, anchor] = [self.point(x1, y1), self.point(x2, y2)]; self.current_subpath.last_manipulator_group_mut().unwrap().out_handle = Some(handle); - self.current_subpath.push_manipulator_group(ManipulatorGroup::new_anchor_with_id(anchor, self.id.next())); + self.current_subpath.push_manipulator_group(ManipulatorGroup::new_anchor_with_id(anchor, self.id.next_id())); } fn curve_to(&mut self, x1: f32, y1: f32, x2: f32, y2: f32, x3: f32, y3: f32) { let [handle1, handle2, anchor] = [self.point(x1, y1), self.point(x2, y2), self.point(x3, y3)]; self.current_subpath.last_manipulator_group_mut().unwrap().out_handle = Some(handle1); - self.current_subpath.push_manipulator_group(ManipulatorGroup::new_with_id(anchor, Some(handle2), None, self.id.next())); + self.current_subpath + .push_manipulator_group(ManipulatorGroup::new_with_id(anchor, Some(handle2), None, self.id.next_id())); } fn close(&mut self) { diff --git a/node-graph/gcore/src/uuid.rs b/node-graph/gcore/src/uuid.rs index b8d9b041..682098ac 100644 --- a/node-graph/gcore/src/uuid.rs +++ b/node-graph/gcore/src/uuid.rs @@ -84,7 +84,7 @@ impl bezier_rs::Identifier for ManipulatorGroupId { impl ManipulatorGroupId { pub const ZERO: ManipulatorGroupId = ManipulatorGroupId(0); - pub fn next(&mut self) -> Self { + pub fn next_id(&mut self) -> Self { let old = self.0; self.0 += 1; Self(old) diff --git a/node-graph/gcore/src/value.rs b/node-graph/gcore/src/value.rs index 6a492aa7..9e5fcd82 100644 --- a/node-graph/gcore/src/value.rs +++ b/node-graph/gcore/src/value.rs @@ -115,8 +115,8 @@ impl<'i, T: Clone + 'i> Node<'i, ()> for DebugClonedNode { } impl DebugClonedNode { - pub const fn new(value: T) -> ClonedNode { - ClonedNode(value) + pub const fn new(value: T) -> DebugClonedNode { + DebugClonedNode(value) } } diff --git a/node-graph/graph-craft/src/document.rs b/node-graph/graph-craft/src/document.rs index c4a079c2..9279d974 100644 --- a/node-graph/graph-craft/src/document.rs +++ b/node-graph/graph-craft/src/document.rs @@ -614,7 +614,7 @@ impl NodeNetwork { fn replace_network_outputs(&mut self, old_output: NodeOutput, new_output: NodeOutput) { for output in self.outputs.iter_mut() { if *output == old_output { - *output = new_output.clone(); + *output = new_output; } } } diff --git a/node-graph/graph-craft/src/proto.rs b/node-graph/graph-craft/src/proto.rs index 00270d93..5fd8b4d6 100644 --- a/node-graph/graph-craft/src/proto.rs +++ b/node-graph/graph-craft/src/proto.rs @@ -544,9 +544,9 @@ impl TypingContext { if matches!(input, Type::Generic(_)) { return Err(format!("Generic types are not supported as inputs yet {:?} occured in {:?}", &input, node.identifier)); } - if parameters.iter().any(|p| match p { - Type::Fn(_, b) if matches!(b.as_ref(), Type::Generic(_)) => true, - _ => false, + if parameters.iter().any(|p| { + matches!(p, + Type::Fn(_, b) if matches!(b.as_ref(), Type::Generic(_))) }) { return Err(format!("Generic types are not supported in parameters: {:?} occured in {:?}", parameters, node.identifier)); } diff --git a/node-graph/gstd/src/any.rs b/node-graph/gstd/src/any.rs index 2b20b224..823d6716 100644 --- a/node-graph/gstd/src/any.rs +++ b/node-graph/gstd/src/any.rs @@ -117,7 +117,7 @@ where } } -impl<'i, N> FutureWrapperNode { +impl FutureWrapperNode { pub const fn new(node: N) -> Self { Self { node } } diff --git a/node-graph/gstd/src/brush.rs b/node-graph/gstd/src/brush.rs index 7903cd92..6d84040c 100644 --- a/node-graph/gstd/src/brush.rs +++ b/node-graph/gstd/src/brush.rs @@ -170,7 +170,7 @@ fn blit_node<_P: Alpha + Pixel + std::fmt::Debug, BlendFn>(mut target: ImageFram where BlendFn: for<'any_input> Node<'any_input, (_P, _P), Output = _P>, { - if positions.len() == 0 { + if positions.is_empty() { return target; } diff --git a/node-graph/gstd/src/executor.rs b/node-graph/gstd/src/executor.rs index f6d250b6..764faba7 100644 --- a/node-graph/gstd/src/executor.rs +++ b/node-graph/gstd/src/executor.rs @@ -402,11 +402,7 @@ async fn blend_gpu_image(foreground: ImageFrame, background: ImageFrame; let node = NodeContainer::new(node); - self.store_node(node.into(), id); + self.store_node(node, id); } ConstructionArgs::Inline(_) => unimplemented!("Inline nodes are not supported yet"), ConstructionArgs::Nodes(ids) => { @@ -165,7 +165,7 @@ impl BorrowTree { let constructor = typing_context.constructor(id).ok_or(format!("No constructor found for node {:?}", identifier))?; let node = constructor(construction_nodes).await; let node = NodeContainer::new(node); - self.store_node(node.into(), id); + self.store_node(node, id); } }; Ok(()) diff --git a/node-graph/interpreted-executor/src/lib.rs b/node-graph/interpreted-executor/src/lib.rs index c1b85079..51dc646b 100644 --- a/node-graph/interpreted-executor/src/lib.rs +++ b/node-graph/interpreted-executor/src/lib.rs @@ -3,7 +3,7 @@ pub mod node_registry; #[cfg(test)] mod tests { - use dyn_any::IntoDynAny; + use graph_craft::document::value::TaggedValue; use graphene_core::*; use std::borrow::Cow; @@ -123,6 +123,6 @@ mod tests { let compiler = Compiler {}; let protograph = compiler.compile_single(network, true).expect("Graph should be generated"); - let _exec = block_on(DynamicExecutor::new(protograph)).map(|e| panic!("The network should not type check ")).unwrap_err(); + let _exec = block_on(DynamicExecutor::new(protograph)).map(|_e| panic!("The network should not type check ")).unwrap_err(); } } diff --git a/node-graph/wgpu-executor/src/lib.rs b/node-graph/wgpu-executor/src/lib.rs index 11745fae..020f5888 100644 --- a/node-graph/wgpu-executor/src/lib.rs +++ b/node-graph/wgpu-executor/src/lib.rs @@ -132,7 +132,7 @@ impl gpu_executor::GpuExecutor for NewExecutor { encoder.copy_buffer_to_buffer( layout.output_buffer.buffer().ok_or_else(|| anyhow::anyhow!("Tried to use an non buffer as the shader output"))?, 0, - &output, + output, 0, size, ); @@ -153,7 +153,7 @@ impl gpu_executor::GpuExecutor for NewExecutor { } fn read_output_buffer(&self, buffer: Arc>) -> Pin>>>> { - let future = Box::pin(async move { + Box::pin(async move { if let ShaderInput::ReadBackBuffer(buffer, _) = buffer.as_ref() { let buffer_slice = buffer.slice(..); @@ -187,8 +187,7 @@ impl gpu_executor::GpuExecutor for NewExecutor { } else { bail!("Tried to read a non readback buffer") } - }); - future + }) as _ } } diff --git a/website/other/bezier-rs-demos/wasm/src/subpath.rs b/website/other/bezier-rs-demos/wasm/src/subpath.rs index 05add934..0ff3359b 100644 --- a/website/other/bezier-rs-demos/wasm/src/subpath.rs +++ b/website/other/bezier-rs-demos/wasm/src/subpath.rs @@ -460,10 +460,8 @@ impl WasmSubpath { outline_piece1.to_svg(&mut outline_piece1_svg, CURVE_ATTRIBUTES.to_string().replace(BLACK, RED), String::new(), String::new(), String::new()); let mut outline_piece2_svg = String::new(); - if outline_piece2.is_some() { - outline_piece2 - .unwrap() - .to_svg(&mut outline_piece2_svg, CURVE_ATTRIBUTES.to_string().replace(BLACK, RED), String::new(), String::new(), String::new()); + if let Some(outline) = outline_piece2 { + outline.to_svg(&mut outline_piece2_svg, CURVE_ATTRIBUTES.to_string().replace(BLACK, RED), String::new(), String::new(), String::new()); } wrap_svg_tag(format!("{}{outline_piece1_svg}{outline_piece2_svg}", self.to_default_svg()))