mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Fix a lot of Clippy warnings (#1808)
* fix a lot of clippy warnings * fix more clippy warnings * fix yet more clippy warnings * bump msrv to 1.70.0 to silence warnings * fix a lot of clippy warnings * fix more clippy warnings * fix yet more clippy warnings * fix a few more warnings * fix a clippy warning * remove a commented out line * silense too many arguments error * fix more clippy warnings * prefix underscore to unused vars/functions to fix warnings * use filter instead of map * move raw-rs-tests feature flat to module level to fix unused imports warnings * fix a couple of unused result warnings --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
@@ -47,7 +47,7 @@ mod uuid_generation {
|
||||
|
||||
static RNG: Mutex<Option<ChaCha20Rng>> = Mutex::new(None);
|
||||
thread_local! {
|
||||
pub static UUID_SEED: Cell<Option<u64>> = Cell::new(None);
|
||||
pub static UUID_SEED: Cell<Option<u64>> = const { Cell::new(None) };
|
||||
}
|
||||
|
||||
pub fn set_uuid_seed(random_seed: u64) {
|
||||
|
||||
@@ -149,8 +149,7 @@ fn solidify_stroke(vector_data: VectorData) -> VectorData {
|
||||
// Perform operation on all subpaths in this shape.
|
||||
for mut subpath in subpaths {
|
||||
let stroke = style.stroke().unwrap();
|
||||
let transform = transform.clone();
|
||||
subpath.apply_transform(transform);
|
||||
subpath.apply_transform(*transform);
|
||||
|
||||
// Taking the existing stroke data and passing it to Bezier-rs to generate new paths.
|
||||
let subpath_out = subpath.outline(
|
||||
|
||||
@@ -827,7 +827,7 @@ impl NodeNetwork {
|
||||
}
|
||||
|
||||
/// Get the network the selected nodes are part of, which is either self or the nested network from nested_path. Used to get nodes selected in the layer panel when viewing a nested network.
|
||||
pub fn nested_network_for_selected_nodes<'a>(&self, nested_path: &Vec<NodeId>, mut selected_nodes: impl Iterator<Item = &'a NodeId>) -> Option<&Self> {
|
||||
pub fn nested_network_for_selected_nodes<'a>(&self, nested_path: &[NodeId], mut selected_nodes: impl Iterator<Item = &'a NodeId>) -> Option<&Self> {
|
||||
if selected_nodes.any(|node_id| self.nodes.contains_key(node_id) || self.exports_metadata.0 == *node_id || self.imports_metadata.0 == *node_id) {
|
||||
Some(self)
|
||||
} else {
|
||||
@@ -836,7 +836,7 @@ impl NodeNetwork {
|
||||
}
|
||||
|
||||
/// Get the mutable network the selected nodes are part of, which is either self or the nested network from nested_path. Used to modify nodes selected in the layer panel when viewing a nested network.
|
||||
pub fn nested_network_for_selected_nodes_mut<'a>(&mut self, nested_path: &Vec<NodeId>, mut selected_nodes: impl Iterator<Item = &'a NodeId>) -> Option<&mut Self> {
|
||||
pub fn nested_network_for_selected_nodes_mut<'a>(&mut self, nested_path: &[NodeId], mut selected_nodes: impl Iterator<Item = &'a NodeId>) -> Option<&mut Self> {
|
||||
if selected_nodes.any(|node_id| self.nodes.contains_key(node_id)) {
|
||||
Some(self)
|
||||
} else {
|
||||
@@ -1215,7 +1215,7 @@ impl NodeNetwork {
|
||||
|
||||
for (nested_input_index, nested_input) in nested_node.clone().inputs.iter().enumerate() {
|
||||
if let NodeInput::Network { import_index, .. } = nested_input {
|
||||
let parent_input = node.inputs.get(*import_index).expect(&format!("Import index {} should always exist", import_index));
|
||||
let parent_input = node.inputs.get(*import_index).unwrap_or_else(|| panic!("Import index {} should always exist", import_index));
|
||||
match *parent_input {
|
||||
// If the input to self is a node, connect the corresponding output of the inner network to it
|
||||
NodeInput::Node { node_id, output_index, lambda } => {
|
||||
|
||||
@@ -10,6 +10,7 @@ use graphene_core::{Color, Node, Type};
|
||||
use dyn_any::DynAny;
|
||||
pub use dyn_any::StaticType;
|
||||
pub use glam::{DAffine2, DVec2, IVec2, UVec2};
|
||||
use std::fmt::Display;
|
||||
use std::hash::Hash;
|
||||
pub use std::sync::Arc;
|
||||
|
||||
@@ -173,17 +174,7 @@ tagged_value! {
|
||||
BooleanOperation(graphene_core::vector::misc::BooleanOperation),
|
||||
}
|
||||
|
||||
impl<'a> TaggedValue {
|
||||
pub fn to_string(&self) -> String {
|
||||
match self {
|
||||
TaggedValue::String(x) => x.to_string(),
|
||||
TaggedValue::U32(x) => x.to_string(),
|
||||
TaggedValue::U64(x) => x.to_string(),
|
||||
TaggedValue::F64(x) => x.to_string(),
|
||||
TaggedValue::Bool(x) => x.to_string(),
|
||||
_ => panic!("Cannot convert to string"),
|
||||
}
|
||||
}
|
||||
impl TaggedValue {
|
||||
pub fn to_primitive_string(&self) -> String {
|
||||
match self {
|
||||
TaggedValue::None => "()".to_string(),
|
||||
@@ -199,6 +190,19 @@ impl<'a> TaggedValue {
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for TaggedValue {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
TaggedValue::String(x) => f.write_str(x),
|
||||
TaggedValue::U32(x) => f.write_fmt(format_args!("{x}")),
|
||||
TaggedValue::U64(x) => f.write_fmt(format_args!("{x}")),
|
||||
TaggedValue::F64(x) => f.write_fmt(format_args!("{x}")),
|
||||
TaggedValue::Bool(x) => f.write_fmt(format_args!("{x}")),
|
||||
_ => panic!("Cannot convert to string"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct UpcastNode {
|
||||
value: TaggedValue,
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ fn create_executor(_document_string: String) -> Result<DynamicExecutor, Box<dyn
|
||||
// Ok(executor)
|
||||
}
|
||||
|
||||
fn begin_scope() -> DocumentNode {
|
||||
fn _begin_scope() -> DocumentNode {
|
||||
DocumentNode {
|
||||
name: "Begin Scope".to_string(),
|
||||
implementation: DocumentNodeImplementation::Network(NodeNetwork {
|
||||
|
||||
@@ -276,6 +276,12 @@ impl<I, O> PanicNode<I, O> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<I, O> Default for PanicNode<I, O> {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
@@ -293,8 +293,8 @@ async fn brush(image: ImageFrame<Color>, bounds: ImageFrame<Color>, strokes: Vec
|
||||
let image_bbox = Bbox::from_transform(image.transform).to_axis_aligned_bbox();
|
||||
let bbox = if image_bbox.size().length() < 0.1 { stroke_bbox } else { stroke_bbox.union(&image_bbox) };
|
||||
|
||||
let mut draw_strokes: Vec<_> = strokes.iter().cloned().filter(|s| !matches!(s.style.blend_mode, BlendMode::Erase | BlendMode::Restore)).collect();
|
||||
let erase_restore_strokes: Vec<_> = strokes.iter().cloned().filter(|s| matches!(s.style.blend_mode, BlendMode::Erase | BlendMode::Restore)).collect();
|
||||
let mut draw_strokes: Vec<_> = strokes.iter().filter(|&s| !matches!(s.style.blend_mode, BlendMode::Erase | BlendMode::Restore)).cloned().collect();
|
||||
let erase_restore_strokes: Vec<_> = strokes.iter().filter(|&s| matches!(s.style.blend_mode, BlendMode::Erase | BlendMode::Restore)).cloned().collect();
|
||||
|
||||
let mut brush_plan = cache.compute_brush_plan(image, &draw_strokes);
|
||||
|
||||
|
||||
@@ -590,8 +590,8 @@ pub struct NoisePatternNode<
|
||||
cellular_jitter: CellularJitter,
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
#[node_macro::node_fn(NoisePatternNode)]
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn noise_pattern(
|
||||
_no_primary_input: (),
|
||||
dimensions: UVec2,
|
||||
|
||||
@@ -31,7 +31,7 @@ use web_sys::window;
|
||||
use web_sys::{CanvasRenderingContext2d, HtmlCanvasElement};
|
||||
|
||||
#[cfg(any(feature = "resvg", feature = "vello"))]
|
||||
pub struct Canvas(CanvasRenderingContext2d);
|
||||
pub struct Canvas(());
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct WasmApplicationIo {
|
||||
@@ -316,7 +316,7 @@ fn render_svg(data: impl GraphicElementRendered, mut render: SvgRender, render_p
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "resvg", feature = "vello"))]
|
||||
fn render_canvas(
|
||||
fn _render_canvas(
|
||||
data: impl GraphicElementRendered,
|
||||
mut render: SvgRender,
|
||||
render_params: RenderParams,
|
||||
@@ -331,13 +331,13 @@ fn render_canvas(
|
||||
let max = footprint.transform.inverse().transform_point2(resolution.as_dvec2());
|
||||
render.format_svg(min, max);
|
||||
let string = render.svg.to_svg_string();
|
||||
let array = string.as_bytes();
|
||||
let _array = string.as_bytes();
|
||||
let canvas = &surface_handle.surface;
|
||||
canvas.set_width(resolution.x);
|
||||
canvas.set_height(resolution.y);
|
||||
let usvg_tree = data.to_usvg_tree(resolution, [min, max]);
|
||||
|
||||
if let Some(exec) = editor.application_io.gpu_executor() {
|
||||
if let Some(_exec) = editor.application_io.gpu_executor() {
|
||||
todo!()
|
||||
} else {
|
||||
let pixmap_size = usvg_tree.size.to_int_size();
|
||||
|
||||
@@ -141,11 +141,14 @@ fn node_new_impl(attr: TokenStream, item: TokenStream) -> TokenStream {
|
||||
args.push(Type::Verbatim(quote::quote!(#ident)));
|
||||
}
|
||||
|
||||
let function_attributes = &function.attrs;
|
||||
|
||||
let struct_generics_iter = struct_generics.iter();
|
||||
quote::quote! {
|
||||
#[automatically_derived]
|
||||
impl <#(#args),*> #node_name<#(#args),*>
|
||||
{
|
||||
#(#function_attributes)*
|
||||
pub const fn new(#(#parameter_idents: #struct_generics_iter),*) -> Self{
|
||||
Self {
|
||||
#(#parameter_idents,)*
|
||||
|
||||
@@ -71,7 +71,7 @@ fn execute_shader<I: Pod + Send + Sync, O: Pod + Send + Sync>(
|
||||
let dest_buffer = create_buffer(dest_data, alloc).expect("failed to create buffer");
|
||||
|
||||
let compute_pipeline = ComputePipeline::new(device.clone(), entry_point, &(), None, |_| {}).expect("failed to create compute pipeline");
|
||||
let layout = compute_pipeline.layout().set_layouts().get(0).unwrap();
|
||||
let layout = compute_pipeline.layout().set_layouts().first().unwrap();
|
||||
let dalloc = StandardDescriptorSetAllocator::new(device.clone());
|
||||
let set = PersistentDescriptorSet::new(
|
||||
&dalloc,
|
||||
|
||||
Reference in New Issue
Block a user