From 9f0e0ebc967f9876a7e9eb74f9050dd747489da6 Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Sun, 6 Sep 2026 16:25:17 +0000 Subject: [PATCH] Clear the remaining clippy warnings on the diff surface --- editor/src/node_graph_executor/runtime.rs | 4 ++-- .../src/dynamic_executor.rs | 2 +- node-graph/libraries/core-types/src/arena.rs | 2 +- .../libraries/core-types/src/record/frames.rs | 1 - .../libraries/core-types/src/record/layout.rs | 4 ++-- .../libraries/core-types/src/record/route.rs | 2 +- .../libraries/core-types/src/record/run.rs | 2 +- .../libraries/graphic-types/src/graphic/walk.rs | 6 +++--- node-graph/node-macro/src/codegen.rs | 16 ++++++++-------- node-graph/node-macro/src/codegen/classify.rs | 4 ++-- node-graph/node-macro/src/codegen/entries.rs | 2 +- node-graph/node-macro/src/codegen/ir.rs | 17 +++++++++-------- node-graph/nodes/brush/src/brush.rs | 5 +---- node-graph/nodes/gcore/src/context.rs | 2 +- node-graph/nodes/gcore/src/memo.rs | 10 +++++----- node-graph/nodes/gcore/src/record.rs | 4 ++-- node-graph/nodes/graphic/src/graphic.rs | 2 +- node-graph/nodes/graphic/src/record.rs | 3 +-- node-graph/nodes/path-bool/src/lib.rs | 2 +- node-graph/nodes/vector/src/generator_nodes.rs | 4 ++-- node-graph/nodes/vector/src/vector_nodes.rs | 2 +- 21 files changed, 46 insertions(+), 50 deletions(-) diff --git a/editor/src/node_graph_executor/runtime.rs b/editor/src/node_graph_executor/runtime.rs index f9c86d313f..e4cbec7c90 100644 --- a/editor/src/node_graph_executor/runtime.rs +++ b/editor/src/node_graph_executor/runtime.rs @@ -546,10 +546,10 @@ impl NodeRuntime { Some(()) } }); - if result.is_err() { + if let Err(_error) = result { // TODO: Fix the root of the issue causing the spam of this warning (this at least temporarily disables it in release builds) #[cfg(debug_assertions)] - warn!("Failed to introspect monitor node {}", result.unwrap_err()); + warn!("Failed to introspect monitor node {}", _error); } } } diff --git a/node-graph/interpreted-executor/src/dynamic_executor.rs b/node-graph/interpreted-executor/src/dynamic_executor.rs index 8b4e886f60..8d12b93108 100644 --- a/node-graph/interpreted-executor/src/dynamic_executor.rs +++ b/node-graph/interpreted-executor/src/dynamic_executor.rs @@ -178,7 +178,7 @@ impl DynamicExecutor { let result = self.tree.introspect(node_path)?; if result.downcast_ref::().is_some() { return self - .introspect_with(node_path, |layout, batch, arena| graphic_types::boundary::batch_to_legacy(layout, batch, arena)) + .introspect_with(node_path, graphic_types::boundary::batch_to_legacy) .map(Arc::from); } Ok(result) diff --git a/node-graph/libraries/core-types/src/arena.rs b/node-graph/libraries/core-types/src/arena.rs index 5d9769b7f8..f4d261301e 100644 --- a/node-graph/libraries/core-types/src/arena.rs +++ b/node-graph/libraries/core-types/src/arena.rs @@ -196,7 +196,7 @@ impl Arena { let count = COUNT.fetch_add(1, Ordering::Relaxed); if reserved.is_none() { eprintln!("arena> EXHAUSTED after {count} allocations, wanted {size} bytes\n{}", std::backtrace::Backtrace::force_capture()); - } else if count % 20000 == 0 { + } else if count.is_multiple_of(20000) { eprintln!("arena> {count} allocations, offset {}, this {size} bytes", self.offset.load(Ordering::Relaxed)); } } diff --git a/node-graph/libraries/core-types/src/record/frames.rs b/node-graph/libraries/core-types/src/record/frames.rs index 0aac188aa8..60754b75c6 100644 --- a/node-graph/libraries/core-types/src/record/frames.rs +++ b/node-graph/libraries/core-types/src/record/frames.rs @@ -176,7 +176,6 @@ mod tests { let scope = frames.scope(); let mut claim = scope.claim(&layout); addresses.push(claim.dst() as usize); - drop(claim); drop(scope); assert_eq!(frames.free_words(), free, "the scope returns its claims"); } diff --git a/node-graph/libraries/core-types/src/record/layout.rs b/node-graph/libraries/core-types/src/record/layout.rs index 721f70e643..dfa2c7327c 100644 --- a/node-graph/libraries/core-types/src/record/layout.rs +++ b/node-graph/libraries/core-types/src/record/layout.rs @@ -33,7 +33,7 @@ impl FieldWrite { unsafe { &*ptr.cast::() }.cache_hash(&mut state); } unsafe fn content_eq(a: *const u8, b: *const u8) -> bool { - unsafe { &*a.cast::() == &*b.cast::() } + unsafe { *a.cast::() == *b.cast::() } } Self { name: A::NAME, @@ -656,7 +656,7 @@ mod tests { #[derive(Clone, dyn_any::DynAny)] struct Opaque; - let hashed = (&ElementWritePick::(std::marker::PhantomData)).element_write(); + let hashed = ElementWritePick::(std::marker::PhantomData).element_write(); assert!(hashed.content_hash.is_some() && hashed.content_eq.is_some()); let plain = (&ElementWritePick::(std::marker::PhantomData)).element_write(); assert!(plain.content_hash.is_none() && plain.content_eq.is_none()); diff --git a/node-graph/libraries/core-types/src/record/route.rs b/node-graph/libraries/core-types/src/record/route.rs index 44f417fc59..3a67e16a33 100644 --- a/node-graph/libraries/core-types/src/record/route.rs +++ b/node-graph/libraries/core-types/src/record/route.rs @@ -97,7 +97,7 @@ where let Some(plan) = &self.plan else { return self.edge.serve(input, slot); }; - match serve_input(&self.edge, input, &mut slot.frames().reborrow()) { + match serve_input(&self.edge, input, &slot.frames().reborrow()) { GPoll::Final(value) => { // SAFETY: the value came from this source, so it carries the // plan's source layout. diff --git a/node-graph/libraries/core-types/src/record/run.rs b/node-graph/libraries/core-types/src/record/run.rs index 8e848c5d7f..5636d9c723 100644 --- a/node-graph/libraries/core-types/src/record/run.rs +++ b/node-graph/libraries/core-types/src/record/run.rs @@ -171,7 +171,7 @@ impl<'e> GroupItem<'e> { // A run already living in the target region needs no copy: the arena is // insert-only within a generation, so the lanes cannot move or change // while the adopting item borrows them. - if batch.len() > 0 && arena.contains(batch.frames_ptr()) { + if !batch.is_empty() && arena.contains(batch.frames_ptr()) { return Some(Self { layout, storage: ItemStorage::Resident(batch.frames_ptr()), diff --git a/node-graph/libraries/graphic-types/src/graphic/walk.rs b/node-graph/libraries/graphic-types/src/graphic/walk.rs index 75dd901b4c..b28436fb13 100644 --- a/node-graph/libraries/graphic-types/src/graphic/walk.rs +++ b/node-graph/libraries/graphic-types/src/graphic/walk.rs @@ -553,9 +553,9 @@ mod run_tests { let arena = core_types::arena::Arena::new(1 << 16).unwrap(); let mut builder = RunBuilder::new(&arena, element_write_hashed::(), &[FieldWrite::of::(0)], 2).unwrap(); - for lane in 0..2 { - let lane = builder.push(vectors[lane].clone()).unwrap(); - builder.attr::(lane, transforms[lane]); + for (vector, transform) in vectors.iter().zip(transforms) { + let lane = builder.push(vector.clone()).unwrap(); + builder.attr::(lane, transform); } let item = builder.finish(); let run = RunView::::new(&item).expect("the run holds vector elements"); diff --git a/node-graph/node-macro/src/codegen.rs b/node-graph/node-macro/src/codegen.rs index b8e8d5a3f4..b0636a25c9 100644 --- a/node-graph/node-macro/src/codegen.rs +++ b/node-graph/node-macro/src/codegen.rs @@ -197,7 +197,7 @@ pub(crate) fn generate_node_code(crate_ident: &CrateIdent, parsed: &ParsedNodeFn let field_pushed_levels: Vec = regular_fields .iter() .map(|field| match &field.ty { - ParsedFieldType::Regular(RegularParsedField { list_levels, .. }) if *list_levels > 0 => *list_levels as u8, + ParsedFieldType::Regular(RegularParsedField { list_levels, .. }) if *list_levels > 0 => *list_levels, ParsedFieldType::Node(_) => pushed_levels, _ => 0, }) @@ -2433,20 +2433,20 @@ pub(crate) fn generate_node_impl(crate_ident: &CrateIdent, parsed: &ParsedNodeFn .iter() .enumerate() .filter(|(index, _)| ir::materialized_levels(&node, *index) == 0) - .filter_map(|(_, field)| match &field.ty { + .map(|(_, field)| match &field.ty { // The conditional arena-park moves a lend element once. - ParsedFieldType::Regular(RegularParsedField { ty, lend: Some(_), .. }) => Some({ + ParsedFieldType::Regular(RegularParsedField { ty, lend: Some(_), .. }) => { let ty = &crate::codegen::classify::substitute_lifetimes(ty, "'static"); quote!(#ty: ::core::marker::Send + ::core::marker::Sync + 'static) - }), - ParsedFieldType::Regular(RegularParsedField { ty, .. }) => Some({ + } + ParsedFieldType::Regular(RegularParsedField { ty, .. }) => { let ty = &crate::codegen::classify::substitute_lifetimes(ty, "'static"); quote!(#ty: ::core::clone::Clone) - }), - ParsedFieldType::Node(NodeParsedField { output_type, .. }) => Some({ + } + ParsedFieldType::Node(NodeParsedField { output_type, .. }) => { let output_type = &crate::codegen::classify::substitute_lifetimes(output_type, "'static"); quote!(#output_type: ::core::clone::Clone) - }), + } }) .collect(); let out = crate::codegen::classify::substitute_lifetimes(&slot_value_type(&parsed.output_type), "'static"); diff --git a/node-graph/node-macro/src/codegen/classify.rs b/node-graph/node-macro/src/codegen/classify.rs index cf7d820fa8..43a83e4c8d 100644 --- a/node-graph/node-macro/src/codegen/classify.rs +++ b/node-graph/node-macro/src/codegen/classify.rs @@ -312,7 +312,7 @@ pub(crate) fn record_shape(parsed: &ParsedNodeFn) -> Option { ParsedFieldType::Node(NodeParsedField { output_type, .. }) => is_served(output_type) || crate::codegen::ir::strip_ilist(output_type).1 > 0 || !field.attribute_reads.is_empty(), ParsedFieldType::Regular(_) => false, }; - if parsed.fields.iter().skip(lazy_carrier as usize).any(|field| unsupported_lazy_secondary(field)) { + if parsed.fields.iter().skip(lazy_carrier as usize).any(unsupported_lazy_secondary) { return None; } let reads_well_placed = parsed.fields.iter().enumerate().all(|(index, field)| { @@ -575,7 +575,7 @@ pub(crate) fn routing_io(parsed: &ParsedNodeFn) -> Option { } } } - (sources > 0).then(|| RoutingIo { generic: ident }) + (sources > 0).then_some(RoutingIo { generic: ident }) } pub(crate) fn bare_ident(ty: &Type) -> Option<&Ident> { diff --git a/node-graph/node-macro/src/codegen/entries.rs b/node-graph/node-macro/src/codegen/entries.rs index 20a7a2fa36..f3c52d3f51 100644 --- a/node-graph/node-macro/src/codegen/entries.rs +++ b/node-graph/node-macro/src/codegen/entries.rs @@ -100,7 +100,7 @@ fn flip_entries_tokens(parsed: &ParsedNodeFn, struct_name: &Ident, regular_field } } let alias_params: Vec<&GenericParam> = candidate_params.iter().zip(&kept).filter(|(_, kept)| **kept).map(|(param, _)| *param).collect(); - let alias_param_idents: Vec = alias_params.iter().map(|param| param_ident(param)).collect(); + let alias_param_idents: Vec = alias_params.iter().map(param_ident).collect(); let alias_param_tokens: Vec = alias_params.iter().map(|param| quote!(#param)).collect(); let output_alias = format_ident!("__{}_output", fn_name); let alias_def = match alias_param_tokens.is_empty() { diff --git a/node-graph/node-macro/src/codegen/ir.rs b/node-graph/node-macro/src/codegen/ir.rs index e6478fa872..5db2418450 100644 --- a/node-graph/node-macro/src/codegen/ir.rs +++ b/node-graph/node-macro/src/codegen/ir.rs @@ -48,7 +48,7 @@ fn generics(parsed: &ParsedNodeFn) -> Vec { fn inputs(parsed: &ParsedNodeFn, fields: &[&ParsedField], generics: &[Ident]) -> Vec { let routing = routing_io(parsed); - let carrier_subject = flip_carrier(parsed) || record_shape(parsed).map_or(false, |shape| !shape.skips_carrier()); + let carrier_subject = flip_carrier(parsed) || record_shape(parsed).is_some_and(|shape| !shape.skips_carrier()); fields .iter() .enumerate() @@ -263,13 +263,16 @@ fn ilist_inner(ty: &Type) -> Option { /// caller since it is the one row-dependent facet; the rest folds from the node. pub(crate) fn layout_meta_tokens(node: &Node, element_spec: TokenStream2, core_types: &TokenStream2) -> TokenStream2 { let sources = layout_sources(node).into_iter().map(|index| index as u8); - let reads = node.inputs.iter().enumerate().filter_map(|(index, input)| { - (matches!(input.evaluation, Evaluation::Eager) && !input.shape.attrs.is_empty()).then(|| { + let reads = node + .inputs + .iter() + .enumerate() + .filter(|(_, input)| matches!(input.evaluation, Evaluation::Eager) && !input.shape.attrs.is_empty()) + .map(|(index, input)| { let descs = field_writes(&input.shape.attrs, core_types); let index = index as u8; quote!(#core_types::record::InputReads { input: #index, reads: ::std::vec![#(#descs),*] }) - }) - }); + }); let writes = field_writes(&node.output.shape.attrs, core_types); let removes = node.output.removes.iter().map(|attr| { let marker = &attr.marker; @@ -859,9 +862,7 @@ mod tests { let routing_source = |ty: &Type| generic.as_ref().is_some_and(|generic| crate::codegen::classify::routing_source_output(ty, generic)); match &field.ty { ParsedFieldType::Regular(RegularParsedField { ty, lend, .. }) => { - if record && !skips_carrier && index == 0 { - "carrier" - } else if carrier_flip && index == 0 { + if index == 0 && ((record && !skips_carrier) || carrier_flip) { "carrier" } else if flip && lend.is_some() { "lend" diff --git a/node-graph/nodes/brush/src/brush.rs b/node-graph/nodes/brush/src/brush.rs index d1292285d9..01f6fe9338 100644 --- a/node-graph/nodes/brush/src/brush.rs +++ b/node-graph/nodes/brush/src/brush.rs @@ -83,10 +83,7 @@ fn brush_stamp_generator(_: impl Ctx, #[unit(" px")] diameter: f64, color: Color /// Used to efficiently paint brush strokes. Applies the same texture repeatedly at different positions with proper blending and boundary handling. #[node_macro::node(category(""), skip_impl)] -fn blit(_: impl Ctx, mut target: List>, texture: Raster, positions: Vec, blend_mode: BlendFn) -> List> -where - BlendFn: Fn(Color, Color) -> Color, -{ +fn blit Color>(_: impl Ctx, mut target: List>, texture: Raster, positions: Vec, blend_mode: BlendFn) -> List> { if positions.is_empty() { return target; } diff --git a/node-graph/nodes/gcore/src/context.rs b/node-graph/nodes/gcore/src/context.rs index 6308b7cd36..ee60d26490 100644 --- a/node-graph/nodes/gcore/src/context.rs +++ b/node-graph/nodes/gcore/src/context.rs @@ -48,7 +48,7 @@ fn read_gradient(ctx: impl Ctx + ExtractVarArgs) -> List { } /// The mapped row riding as vararg 0, in the production single-item shape. -fn vararg_list<'a, T: 'static>(ctx: &'a impl ExtractVarArgs) -> Option<&'a List> { +fn vararg_list(ctx: &impl ExtractVarArgs) -> Option<&List> { let arg = ctx.vararg(0).ok()?; (arg as &dyn std::any::Any).downcast_ref::>() } diff --git a/node-graph/nodes/gcore/src/memo.rs b/node-graph/nodes/gcore/src/memo.rs index 7d55b3425b..ee3744e8ae 100644 --- a/node-graph/nodes/gcore/src/memo.rs +++ b/node-graph/nodes/gcore/src/memo.rs @@ -86,7 +86,7 @@ fn memoize<'e, 'l>( return serve(entry, slot); } if leveled { - return match content.materialize_level(&ctx, ctx.arena()) { + return match content.materialize_level(ctx, ctx.arena()) { LevelStatus::Batch(batch, finality) => { let layout = content.layout(); // SAFETY: the batch came from this input, so it carries the input's layout. @@ -107,7 +107,7 @@ fn memoize<'e, 'l>( }; } // The output layout is the content's, so the claim is the content's frame. - let result = content.serve(&ctx, slot); + let result = content.serve(ctx, slot); let publishable = match &result { GPoll::Final(served) => Some((served.record(), Finality::AllFinal)), GPoll::Partial(served) => Some((served.record(), Finality::Partial)), @@ -196,7 +196,7 @@ fn frame_memo<'e, 'l>( return serve(published.get(lane).rec().ptr(), finality, slot); } if leveled { - return match content.materialize_level(&ctx, ctx.arena()) { + return match content.materialize_level(ctx, ctx.arena()) { LevelStatus::Batch(batch, finality) => { // SAFETY: the batch came from this input, so it carries the input's layout. let span = unsafe { MaterializedSpan::to_persistent(&batch, &promotion) }; @@ -212,7 +212,7 @@ fn frame_memo<'e, 'l>( }; } // The output layout is the content's, so the claim is the content's frame. - let result = content.serve(&ctx, slot); + let result = content.serve(ctx, slot); let publishable = match &result { GPoll::Final(served) => Some((served.record(), Finality::AllFinal)), GPoll::Partial(served) => Some((served.record(), Finality::Partial)), @@ -246,7 +246,7 @@ fn monitor<'e, 'l>( if ctx.index() == 0 { *io.lock().unwrap() = Some(CtxSnapshot::capture(ctx)); } - content.serve(&ctx, slot) + content.serve(ctx, slot) } fn serialize_monitor(io: &MonitorValue) -> Option> { diff --git a/node-graph/nodes/gcore/src/record.rs b/node-graph/nodes/gcore/src/record.rs index 2425e5ca65..7e0a20e702 100644 --- a/node-graph/nodes/gcore/src/record.rs +++ b/node-graph/nodes/gcore/src/record.rs @@ -2983,8 +2983,8 @@ mod tests { { let scope = scope_fixture(&generations, &first_arena).with_persistent(&persistent); let ctx = ContextImpl::root(&scope); - let mut first = frames.reborrow(); - let GPoll::Final(_) = core_types::record::serve_input(&memo, &ctx, &mut first) else { + let first = frames.reborrow(); + let GPoll::Final(_) = core_types::record::serve_input(&memo, &ctx, &first) else { panic!("expected a final record"); }; } diff --git a/node-graph/nodes/graphic/src/graphic.rs b/node-graph/nodes/graphic/src/graphic.rs index fb28b86146..2f73661051 100644 --- a/node-graph/nodes/graphic/src/graphic.rs +++ b/node-graph/nodes/graphic/src/graphic.rs @@ -226,7 +226,7 @@ where } let fill = park_paint(legacy.attribute::>>(graphic_types::ATTR_FILL, source).cloned().flatten())?; let stroke = park_paint(legacy.attribute::>>(graphic_types::ATTR_STROKE, source).cloned().flatten())?; - let layer_path: Vec = legacy.attribute::>(ATTR_EDITOR_LAYER_PATH, source).map(|path| path.clone()).unwrap_or_default(); + let layer_path: Vec = legacy.attribute::>(ATTR_EDITOR_LAYER_PATH, source).cloned().unwrap_or_default(); let layer_path = arena.alloc(layer_path).ok_or_else(exhausted)?.0; Ok(( diff --git a/node-graph/nodes/graphic/src/record.rs b/node-graph/nodes/graphic/src/record.rs index 4fbadec6f0..2f33a22d41 100644 --- a/node-graph/nodes/graphic/src/record.rs +++ b/node-graph/nodes/graphic/src/record.rs @@ -885,8 +885,7 @@ mod tests { let GPoll::Final(value) = record::serve_input(&wrapped, &ctx.promoted(&head, 0), &scope) else { panic!("expected a final record"); }; - let group = unsafe { record::borrow_element::(wrap_out.rec(&value)) }.clone(); - group + unsafe { record::borrow_element::(wrap_out.rec(&value)) }.clone() }; // One row holding the wrapped group flattens back to the lanes, the diff --git a/node-graph/nodes/path-bool/src/lib.rs b/node-graph/nodes/path-bool/src/lib.rs index 1f94c8a989..70cfef21c1 100644 --- a/node-graph/nodes/path-bool/src/lib.rs +++ b/node-graph/nodes/path-bool/src/lib.rs @@ -78,7 +78,7 @@ fn boolean_core<'e>( use core_types::lane::LaneSource; let fill = park_paint(result_vector_list.attr::(0).filter(|paint| is_paint_present(paint)).cloned())?; let stroke = park_paint(result_vector_list.attr::(0).filter(|paint| is_paint_present(paint)).cloned())?; - let layer_path: Vec = result_vector_list.attribute::>(ATTR_EDITOR_LAYER_PATH, 0).map(|path| path.clone()).unwrap_or_default(); + let layer_path: Vec = result_vector_list.attribute::>(ATTR_EDITOR_LAYER_PATH, 0).cloned().unwrap_or_default(); let layer_path = arena.alloc(layer_path).ok_or_else(exhausted)?.0; // Snapshot the input layers so the renderer can recurse into them for // editor click-target preservation. diff --git a/node-graph/nodes/vector/src/generator_nodes.rs b/node-graph/nodes/vector/src/generator_nodes.rs index 0e80ed6ce1..6de2a06b20 100644 --- a/node-graph/nodes/vector/src/generator_nodes.rs +++ b/node-graph/nodes/vector/src/generator_nodes.rs @@ -433,7 +433,7 @@ mod tests { #[test] fn qr_code_test() { let qr = qr_code(&(), (), "https://graphite.art".to_string(), false, 1., QRCodeErrorCorrectionLevel::Low, true); - assert!(qr.point_domain.ids().len() > 0); - assert!(qr.segment_domain.ids().len() > 0); + assert!(!qr.point_domain.ids().is_empty()); + assert!(!qr.segment_domain.ids().is_empty()); } } diff --git a/node-graph/nodes/vector/src/vector_nodes.rs b/node-graph/nodes/vector/src/vector_nodes.rs index d9cecc6171..fdbe5d8ed0 100644 --- a/node-graph/nodes/vector/src/vector_nodes.rs +++ b/node-graph/nodes/vector/src/vector_nodes.rs @@ -1577,7 +1577,7 @@ fn emit_legacy_lane<'e>( /// one group lane, lane 0's layer path stamped on the wrapper. fn wrap_vector_level(content: core_types::node::List<'_, Vector>) -> List> { let item = content.as_group_item(); - let layer_path: Vec = match content.len() > 0 { + let layer_path: Vec = match !content.is_empty() { true => content.lane(0).attr::().to_vec(), false => Vec::new(), };