From 46ea7a70439b29b81cef40283f580d492a8b350e Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Fri, 31 Jul 2026 10:55:29 +0000 Subject: [PATCH] Fix the clippy lints introduced by the refactor --- editor/src/node_graph_executor/runtime.rs | 11 +++++++-- node-graph/graph-craft/src/document/value.rs | 1 - node-graph/graph-craft/src/proto.rs | 2 +- node-graph/graphene-cli/src/export.rs | 3 ++- node-graph/graphene-cli/src/main.rs | 1 - .../interpreted-executor/src/node_registry.rs | 2 +- .../libraries/core-types/src/registry.rs | 23 +++++++++++-------- .../libraries/wgpu-executor/src/pipeline.rs | 2 +- .../wgpu-executor/src/texture_conversion.rs | 1 - node-graph/node-macro/src/codegen.rs | 17 +++++++------- node-graph/node-macro/src/parsing.rs | 6 ++--- .../src/shader_nodes/per_pixel_adjust.rs | 2 +- node-graph/nodes/gcore/src/memo.rs | 18 +++++++-------- node-graph/nodes/gcore/src/ops.rs | 2 +- node-graph/nodes/gstd/src/render_cache.rs | 3 +-- node-graph/nodes/gstd/src/render_node.rs | 2 +- .../nodes/gstd/src/render_pixel_preview.rs | 2 +- node-graph/nodes/vector/src/vector_nodes.rs | 4 ++-- 18 files changed, 54 insertions(+), 48 deletions(-) diff --git a/editor/src/node_graph_executor/runtime.rs b/editor/src/node_graph_executor/runtime.rs index bf8158d839..9d2ba4d1b0 100644 --- a/editor/src/node_graph_executor/runtime.rs +++ b/editor/src/node_graph_executor/runtime.rs @@ -12,7 +12,7 @@ use graphene_std::bounds::RenderBoundingBox; use graphene_std::core_types::gpoll::GPoll; use graphene_std::list::List; use graphene_std::memo::IORecord; -use graphene_std::ops::{Convert, ConvertAsync}; +use graphene_std::ops::ConvertAsync; #[cfg(all(target_family = "wasm", feature = "gpu", feature = "wasm"))] use graphene_std::platform_application_io::canvas_utils::{Canvas, CanvasSurface, CanvasSurfaceHandle}; use graphene_std::raster_types::Raster; @@ -22,7 +22,7 @@ use graphene_std::transform::RenderQuality; use graphene_std::vector::Vector; use graphene_std::vector::style::RenderMode; use graphene_std::{Artboard, CtxSnapshot, Graphic}; -use interpreted_executor::dynamic_executor::{DynamicExecutor, IntrospectError, ResolvedDocumentNodeTypesDelta}; +use interpreted_executor::dynamic_executor::{DynamicExecutor, ResolvedDocumentNodeTypesDelta}; use interpreted_executor::util::wrap_network_in_scope; use spin::Mutex; use std::sync::Arc; @@ -133,6 +133,13 @@ impl TokioSpawner { } } +#[cfg(not(target_family = "wasm"))] +impl Default for TokioSpawner { + fn default() -> Self { + Self::new() + } +} + #[cfg(not(target_family = "wasm"))] impl Spawner for TokioSpawner { fn spawn(&self, task: SourceFuture) { diff --git a/node-graph/graph-craft/src/document/value.rs b/node-graph/graph-craft/src/document/value.rs index 499e7a1142..30d30f5507 100644 --- a/node-graph/graph-craft/src/document/value.rs +++ b/node-graph/graph-craft/src/document/value.rs @@ -24,7 +24,6 @@ use graphic_types::{Artboard, Graphic, Vector}; use rendering::RenderMetadata; use std::fmt::Display; use std::hash::Hash; -use std::marker::PhantomData; use std::str::FromStr; pub use std::sync::Arc; use text_nodes::Font; diff --git a/node-graph/graph-craft/src/proto.rs b/node-graph/graph-craft/src/proto.rs index 0631fcdcc1..db77f2385d 100644 --- a/node-graph/graph-craft/src/proto.rs +++ b/node-graph/graph-craft/src/proto.rs @@ -405,7 +405,7 @@ impl ProtoNetwork { let we_introduce_new_deps = !combined_deps.contains(&new_deps); // For diverging branches, we can add a cache node for all branches which don't reqire all dependencies - for (child_node, (deps, new_id)) in inputs.iter_mut().zip(branch_dependencies.into_iter()) { + for (child_node, (deps, new_id)) in inputs.iter_mut().zip(branch_dependencies) { if let Some(new_id) = new_id { *child_node = new_id; } else if we_introduce_new_deps || deps != combined_deps { diff --git a/node-graph/graphene-cli/src/export.rs b/node-graph/graphene-cli/src/export.rs index ecec073ee9..81dbba7594 100644 --- a/node-graph/graphene-cli/src/export.rs +++ b/node-graph/graphene-cli/src/export.rs @@ -18,7 +18,7 @@ const SOURCE_COMPLETION_TIMEOUT: Duration = Duration::from_secs(30); fn execute_until_final(executor: &DynamicExecutor, render_config: RenderConfig, completion: &Receiver<()>) -> Result> { loop { while completion.try_recv().is_ok() {} - match executor.execute(render_config.clone())? { + match executor.execute(render_config)? { GPoll::Final(value) => return Ok(value), GPoll::Fallback(boxed) => { let (value, error) = *boxed; @@ -53,6 +53,7 @@ pub fn detect_file_type(path: &Path) -> Result { } } +#[allow(clippy::too_many_arguments)] pub fn export_document( executor: &DynamicExecutor, wgpu_executor: wgpu_executor::WgpuExecutorHandle, diff --git a/node-graph/graphene-cli/src/main.rs b/node-graph/graphene-cli/src/main.rs index 61a4a66068..77203880f7 100644 --- a/node-graph/graphene-cli/src/main.rs +++ b/node-graph/graphene-cli/src/main.rs @@ -7,7 +7,6 @@ use document_format::{GddV1, GddV1Layout}; use fern::colors::{Color, ColoredLevelConfig}; use futures::executor::block_on; use graph_craft::application_io::EditorPreferences; -use graph_craft::application_io::resource::ResourceRegistry; use graph_craft::application_io::{PlatformApplicationIo, PlatformEditorApi}; use graph_craft::document::*; use graph_craft::graphene_compiler::Compiler; diff --git a/node-graph/interpreted-executor/src/node_registry.rs b/node-graph/interpreted-executor/src/node_registry.rs index 81c772d55f..172b822394 100644 --- a/node-graph/interpreted-executor/src/node_registry.rs +++ b/node-graph/interpreted-executor/src/node_registry.rs @@ -347,7 +347,7 @@ fn node_registry() -> HashMap> { } // TODO: Replace with `core::cell::LazyCell` () or similar -pub static NODE_REGISTRY: once_cell::sync::Lazy>> = once_cell::sync::Lazy::new(|| node_registry()); +pub static NODE_REGISTRY: once_cell::sync::Lazy>> = once_cell::sync::Lazy::new(node_registry); mod node_registry_macros { macro_rules! async_node { diff --git a/node-graph/libraries/core-types/src/registry.rs b/node-graph/libraries/core-types/src/registry.rs index 5151737631..6c6abdad63 100644 --- a/node-graph/libraries/core-types/src/registry.rs +++ b/node-graph/libraries/core-types/src/registry.rs @@ -99,7 +99,7 @@ pub fn cache_key(ctx: &C) -> u64 { #[derive(Debug, PartialEq)] pub enum ConstructionError { Arity { expected: usize, got: usize }, - Type { expected: Type, found: Type }, + Type { expected: Box, found: Box }, } pub struct SharedEdge { @@ -186,9 +186,9 @@ impl EdgeHandle { Self::new_erased(node, lend_edge_type::()) } - pub fn new_erased(node: std::sync::Arc, ty: Type) -> Self + pub fn new_erased(node: std::sync::Arc, ty: Type) -> Self where - N: for<'c> Node>, + N: ?Sized + 'static + for<'c> Node>, SharedEdge: WasmNotSend + WasmNotSync, { Self { @@ -226,7 +226,10 @@ impl EdgeHandle { pub fn downcast_erased(self, expected: Type) -> Result, ConstructionError> { let found = self.ty; - self.node.downcast::>().map(|edge| *edge).map_err(|_| ConstructionError::Type { expected, found }) + self.node.downcast::>().map(|edge| *edge).map_err(|_| ConstructionError::Type { + expected: Box::new(expected), + found: Box::new(found), + }) } } @@ -248,8 +251,8 @@ pub fn construct(entry: &RegistryEntry, inputs: Vec) -> Result(), - found: edge_type::(), + expected: Box::new(edge_type::()), + found: Box::new(edge_type::()), } ); @@ -482,8 +485,8 @@ mod tests { assert_eq!( construct(&entry, vec![lent]).unwrap_err(), ConstructionError::Type { - expected: edge_type::(), - found: lend_edge_type::(), + expected: Box::new(edge_type::()), + found: Box::new(lend_edge_type::()), } ); } diff --git a/node-graph/libraries/wgpu-executor/src/pipeline.rs b/node-graph/libraries/wgpu-executor/src/pipeline.rs index 199826c535..2b79447ed7 100644 --- a/node-graph/libraries/wgpu-executor/src/pipeline.rs +++ b/node-graph/libraries/wgpu-executor/src/pipeline.rs @@ -28,7 +28,7 @@ impl PipelineCache { pub fn run(&self, args: &P::Args<'_>) -> P::Out { let executor = self.executor.get().expect("PipelineCache not initialized"); let entry = self.pipeline.get().expect("PipelineCache not initialized"); - let pipeline = (&**entry) + let pipeline = (**entry) .downcast_ref::

() .unwrap_or_else(|| panic!("PipelineCache type mismatch: run::<{}>() but init used a different pipeline type", std::any::type_name::

(),)); pipeline.run(executor, args) diff --git a/node-graph/libraries/wgpu-executor/src/texture_conversion.rs b/node-graph/libraries/wgpu-executor/src/texture_conversion.rs index 65853dc2d6..c4e8eefca0 100644 --- a/node-graph/libraries/wgpu-executor/src/texture_conversion.rs +++ b/node-graph/libraries/wgpu-executor/src/texture_conversion.rs @@ -1,4 +1,3 @@ -use crate::WgpuExecutor; use crate::WgpuExecutorHandle; use core_types::Color; use core_types::Ctx; diff --git a/node-graph/node-macro/src/codegen.rs b/node-graph/node-macro/src/codegen.rs index 751b3ac7bb..22a50d4353 100644 --- a/node-graph/node-macro/src/codegen.rs +++ b/node-graph/node-macro/src/codegen.rs @@ -145,7 +145,7 @@ pub(crate) fn generate_node_code(crate_ident: &CrateIdent, parsed: &ParsedNodeFn } } ParsedValueSource::Scope(data) => { - if let syn::Expr::Lit(syn::ExprLit { lit: syn::Lit::Str(_), .. }) = data { + if let syn::Expr::Lit(syn::ExprLit { lit: syn::Lit::Str(_), .. }) = &**data { quote!(RegistryValueSource::Scope(#data)) } else { quote!(RegistryValueSource::Scope(#data.as_static_str())) @@ -1104,15 +1104,14 @@ fn kernel_kind(output: &Type) -> KernelKind { let (Some(inner), Some(Type::Path(error_path))) = (types.next(), types.next()) else { return plain(); }; - if !error_path.path.segments.last().is_some_and(|segment| segment.ident == "Interrupt") { + if error_path.path.segments.last().is_none_or(|segment| segment.ident != "Interrupt") { return plain(); } - if let Type::Path(inner_path) = inner { - if let Some(inner_segment) = inner_path.path.segments.last() { - if inner_segment.ident == "SourceFuture" { - return KernelKind::FutureInterrupt(source_future_payload(inner_segment)); - } - } + if let Type::Path(inner_path) = inner + && let Some(inner_segment) = inner_path.path.segments.last() + && inner_segment.ident == "SourceFuture" + { + return KernelKind::FutureInterrupt(source_future_payload(inner_segment)); } KernelKind::Interrupt(inner.clone()) } @@ -1120,7 +1119,7 @@ fn kernel_kind(output: &Type) -> KernelKind { } } -fn context_param<'a>(parsed: &'a ParsedNodeFn) -> Option<&'a TypeParam> { +fn context_param(parsed: &ParsedNodeFn) -> Option<&TypeParam> { let Type::Path(path) = &parsed.input.ty else { return None; }; diff --git a/node-graph/node-macro/src/parsing.rs b/node-graph/node-macro/src/parsing.rs index 6b49f5bd87..e752dd91cc 100644 --- a/node-graph/node-macro/src/parsing.rs +++ b/node-graph/node-macro/src/parsing.rs @@ -71,7 +71,7 @@ pub enum ParsedValueSource { #[default] None, Default(TokenStream2), - Scope(Expr), + Scope(Box), SourceId, } @@ -790,7 +790,7 @@ fn parse_field(pat_ident: PatIdent, ty: Type, attrs: &[Attribute]) -> syn::Resul let value_source = match (default_value, scope) { (Some(_), Some(_)) => return Err(Error::new_spanned(&pat_ident, "Cannot have both `default` and `scope` attributes")), (Some(default_value), _) => ParsedValueSource::Default(default_value), - (_, Some(scope)) => ParsedValueSource::Scope(scope), + (_, Some(scope)) => ParsedValueSource::Scope(Box::new(scope)), _ => ParsedValueSource::None, }; @@ -1062,7 +1062,7 @@ impl ParsedNodeFn { self.fields.push(hidden_field( "_runtime", parse_quote!(#core_types::runtime::RuntimeHandle), - ParsedValueSource::Scope(parse_quote!("graphene_std::runtime::RuntimeNode")), + ParsedValueSource::Scope(Box::new(parse_quote!("graphene_std::runtime::RuntimeNode"))), )); self.fields.push(hidden_field("_source", parse_quote!(#core_types::SourceId), ParsedValueSource::SourceId)); } diff --git a/node-graph/node-macro/src/shader_nodes/per_pixel_adjust.rs b/node-graph/node-macro/src/shader_nodes/per_pixel_adjust.rs index 6a59db5cb5..30b3a7817a 100644 --- a/node-graph/node-macro/src/shader_nodes/per_pixel_adjust.rs +++ b/node-graph/node-macro/src/shader_nodes/per_pixel_adjust.rs @@ -233,7 +233,7 @@ impl PerPixelAdjustCodegen<'_> { ty: ParsedFieldType::Regular(RegularParsedField { ty: parse_quote!(std::sync::Arc), exposed: true, - value_source: ParsedValueSource::Scope(parse_quote!("graphene_std::platform_application_io::WgpuExecutorArcNode")), + value_source: ParsedValueSource::Scope(Box::new(parse_quote!("graphene_std::platform_application_io::WgpuExecutorArcNode"))), number_soft_min: None, number_soft_max: None, number_hard_min: None, diff --git a/node-graph/nodes/gcore/src/memo.rs b/node-graph/nodes/gcore/src/memo.rs index 6adc8da50c..3b2efebd25 100644 --- a/node-graph/nodes/gcore/src/memo.rs +++ b/node-graph/nodes/gcore/src/memo.rs @@ -15,15 +15,15 @@ use std::sync::Mutex; #[node_macro::node(category("General"), path(graphene_core::memo), skip_impl, extent(memoize_extent))] fn memoize(input: I, #[data] cache: Arc>>, content: impl Node) -> GPoll { let key = cache_key(&input); - if let Some((hash, value, finality)) = cache.lock().unwrap().as_ref() { - if *hash == key { - return match finality { - Finality::AllFinal => GPoll::Final(value.clone()), - Finality::Partial => GPoll::Partial(value.clone()), - }; - } + if let Some((hash, value, finality)) = cache.lock().unwrap().as_ref() + && *hash == key + { + return match finality { + Finality::AllFinal => GPoll::Final(value.clone()), + Finality::Partial => GPoll::Partial(value.clone()), + }; } - let result = content.eval(&input); + let result = content.eval(input); match &result { GPoll::Final(value) => *cache.lock().unwrap() = Some((key, value.clone(), Finality::AllFinal)), GPoll::Partial(value) => *cache.lock().unwrap() = Some((key, value.clone(), Finality::Partial)), @@ -76,7 +76,7 @@ where node.content.extent(ctx) } -pub fn park<'e, T>(arena: &'e Arena, result: GPoll) -> GPoll<&'e T> { +pub fn park(arena: &Arena, result: GPoll) -> GPoll<&T> { match result { GPoll::Final(value) => match arena.alloc(value) { Some((parked, _)) => GPoll::Final(parked), diff --git a/node-graph/nodes/gcore/src/ops.rs b/node-graph/nodes/gcore/src/ops.rs index d09739cda5..f864dd41ad 100644 --- a/node-graph/nodes/gcore/src/ops.rs +++ b/node-graph/nodes/gcore/src/ops.rs @@ -1,6 +1,6 @@ use core_types::ExtractAll; use core_types::runtime::SourceFuture; -use core_types::{Ctx, ExtractFootprint, ops::Convert, ops::ConvertAsync, transform::Footprint}; +use core_types::{Ctx, ops::Convert, ops::ConvertAsync, transform::Footprint}; use std::marker::PhantomData; /// Passes-through the input value without changing it. This is useful for rerouting wires for organization purposes. diff --git a/node-graph/nodes/gstd/src/render_cache.rs b/node-graph/nodes/gstd/src/render_cache.rs index 8e58eae8e0..304c570e98 100644 --- a/node-graph/nodes/gstd/src/render_cache.rs +++ b/node-graph/nodes/gstd/src/render_cache.rs @@ -3,7 +3,7 @@ use core_types::gpoll::Interrupt; use core_types::math::bbox::AxisAlignedBbox; use core_types::transform::{Footprint, RenderQuality, Transform}; -use core_types::{Context, Ctx, DeriveCtx, ExtractAll}; +use core_types::{Ctx, DeriveCtx, ExtractAll}; use glam::{DAffine2, DVec2, IVec2, UVec2}; use graph_craft::application_io::PlatformEditorApi; use graph_craft::document::value::{RenderOutput, RenderOutputType}; @@ -12,7 +12,6 @@ use rendering::{RenderOutputType as RenderOutputTypeRequest, RenderParams}; use std::collections::HashSet; use std::hash::Hash; use std::sync::{Arc, Mutex}; -use wgpu_executor::WgpuExecutor; pub const TILE_SIZE: u32 = 256; pub const MAX_CACHE_MEMORY_BYTES: usize = 512 * 1024 * 1024; diff --git a/node-graph/nodes/gstd/src/render_node.rs b/node-graph/nodes/gstd/src/render_node.rs index c08d7e058d..0afcb626a5 100644 --- a/node-graph/nodes/gstd/src/render_node.rs +++ b/node-graph/nodes/gstd/src/render_node.rs @@ -9,7 +9,7 @@ use graphic_types::{Artboard, Graphic, Vector}; use rendering::{Render, RenderMetadata, RenderOutputType as RenderOutputTypeRequest, RenderParams, SvgRender, SvgRenderOutput}; use std::sync::Arc; use vector_types::GradientStops; -use wgpu_executor::{RenderContext, WgpuExecutor}; +use wgpu_executor::RenderContext; #[derive(Clone, dyn_any::DynAny)] pub enum RenderIntermediateType { diff --git a/node-graph/nodes/gstd/src/render_pixel_preview.rs b/node-graph/nodes/gstd/src/render_pixel_preview.rs index 3f9cc1c6ea..4cd0910675 100644 --- a/node-graph/nodes/gstd/src/render_pixel_preview.rs +++ b/node-graph/nodes/gstd/src/render_pixel_preview.rs @@ -1,6 +1,6 @@ use core_types::gpoll::Interrupt; use core_types::transform::{Footprint, Transform}; -use core_types::{Context, Ctx, DeriveCtx, ExtractAll}; +use core_types::{Ctx, DeriveCtx, ExtractAll}; use glam::{DAffine2, DVec2, UVec2, Vec2}; use graph_craft::document::value::{RenderOutput, RenderOutputType}; use graphic_types::raster_types::Texture; diff --git a/node-graph/nodes/vector/src/vector_nodes.rs b/node-graph/nodes/vector/src/vector_nodes.rs index 4562f9b98a..98e2b1c537 100644 --- a/node-graph/nodes/vector/src/vector_nodes.rs +++ b/node-graph/nodes/vector/src/vector_nodes.rs @@ -9,8 +9,8 @@ use core_types::registry::types::{Angle, Length, Multiplier, Percentage, PixelLe use core_types::transform::{Footprint, Transform}; use core_types::uuid::NodeId; use core_types::{ - ATTR_BLEND_MODE, ATTR_CLIPPING_MASK, ATTR_EDITOR_LAYER_PATH, ATTR_EDITOR_MERGED_LAYERS, ATTR_GRADIENT_TYPE, ATTR_OPACITY, ATTR_OPACITY_FILL, ATTR_SPREAD_METHOD, ATTR_TRANSFORM, Color, Context, - Ctx, DeriveCtx, + ATTR_BLEND_MODE, ATTR_CLIPPING_MASK, ATTR_EDITOR_LAYER_PATH, ATTR_EDITOR_MERGED_LAYERS, ATTR_GRADIENT_TYPE, ATTR_OPACITY, ATTR_OPACITY_FILL, ATTR_SPREAD_METHOD, ATTR_TRANSFORM, Color, Ctx, + DeriveCtx, }; use glam::{DAffine2, DMat2, DVec2}; use graphic_types::Vector;