Remove warnings from build and satisfied clippy (#1288)

* Prefixed unused functions with underscore

* Applied clippy lints

* Fixed some warnings and removed some `allow` statements
This commit is contained in:
Prikshit Gautam
2023-06-07 14:46:47 +05:30
committed by Keavon Chambers
parent 054acd3cc9
commit 70fcb35444
33 changed files with 54 additions and 60 deletions

View File

@@ -70,6 +70,5 @@ fn add_network() -> NodeNetwork {
.enumerate()
.map(|(i, n)| (i as u64, n))
.collect(),
..Default::default()
}
}

View File

@@ -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<SRGBA8>, 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,
}
}

View File

@@ -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)]

View File

@@ -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

View File

@@ -13,7 +13,7 @@ mod base64_serde {
use super::super::Pixel;
use serde::{Deserialize, Deserializer, Serializer};
pub fn as_base64<S, P: Pixel>(key: &Vec<P>, serializer: S) -> Result<S::Ok, S::Error>
pub fn as_base64<S, P: Pixel>(key: &[P], serializer: S) -> Result<S::Ok, S::Error>
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<u8>| bytes.chunks_exact(P::byte_size()).map(color_from_chunk).collect();

View File

@@ -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) {

View File

@@ -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)

View File

@@ -115,8 +115,8 @@ impl<'i, T: Clone + 'i> Node<'i, ()> for DebugClonedNode<T> {
}
impl<T: Clone> DebugClonedNode<T> {
pub const fn new(value: T) -> ClonedNode<T> {
ClonedNode(value)
pub const fn new(value: T) -> DebugClonedNode<T> {
DebugClonedNode(value)
}
}

View File

@@ -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;
}
}
}

View File

@@ -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));
}

View File

@@ -117,7 +117,7 @@ where
}
}
impl<'i, N> FutureWrapperNode<N> {
impl<N> FutureWrapperNode<N> {
pub const fn new(node: N) -> Self {
Self { node }
}

View File

@@ -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;
}

View File

@@ -402,11 +402,7 @@ async fn blend_gpu_image(foreground: ImageFrame<Color>, background: ImageFrame<C
};
log::debug!("created pipeline");
let compute_pass = executor
.create_compute_pass(
&pipeline,
Some(readback_buffer.clone()),
ComputePassDimensions::XY(background.image.width as u32, background.image.height as u32),
)
.create_compute_pass(&pipeline, Some(readback_buffer.clone()), ComputePassDimensions::XY(background.image.width, background.image.height))
.unwrap();
executor.execute_compute_pipeline(compute_pass).unwrap();
log::debug!("executed pipeline");

View File

@@ -156,7 +156,7 @@ impl BorrowTree {
let upcasted = UpcastNode::new(value);
let node = Box::new(upcasted) as TypeErasedBox<'_>;
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(())

View File

@@ -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();
}
}

View File

@@ -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<ShaderInput<Self::BufferHandle>>) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>>>> {
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 _
}
}