Box big enum variants to satisfy Clippy's lint warnings (#4292)

* Box the `value` field of `NodeGraphMessage::SetInputValue`

* Box the `ExecutionResponse` variant of `NodeGraphUpdate`

* Box the `Layer` variant of `NodeTypeClickTargets`

* Box the `Scope` variant of `ParsedValueSource`
This commit is contained in:
Keavon Chambers
2026-07-26 11:50:23 -07:00
committed by GitHub
parent 0bce26c54e
commit 9332c7f775
14 changed files with 54 additions and 38 deletions
@@ -157,7 +157,7 @@ pub enum NodeGraphMessage {
SetInputValue { SetInputValue {
node_id: NodeId, node_id: NodeId,
input_index: usize, input_index: usize,
value: TaggedValue, value: Box<TaggedValue>,
}, },
SetInput { SetInput {
input_connector: InputConnector, input_connector: InputConnector,
@@ -1762,7 +1762,7 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
.any(|id| *r == DefinitionIdentifier::ProtoNode(id)) .any(|id| *r == DefinitionIdentifier::ProtoNode(id))
}); });
let input = NodeInput::value(value, false); let input = NodeInput::value(*value, false);
responses.add(NodeGraphMessage::SetInput { responses.add(NodeGraphMessage::SetInput {
input_connector: InputConnector::node(node_id, input_index), input_connector: InputConnector::node(node_id, input_index),
input, input,
@@ -47,7 +47,12 @@ pub(crate) fn string_properties(text: &str) -> Vec<LayoutGroup> {
fn optionally_update_value<T>(value: impl Fn(&T) -> Option<TaggedValue> + 'static + Send + Sync, node_id: NodeId, input_index: usize) -> impl Fn(&T) -> Message + 'static + Send + Sync { fn optionally_update_value<T>(value: impl Fn(&T) -> Option<TaggedValue> + 'static + Send + Sync, node_id: NodeId, input_index: usize) -> impl Fn(&T) -> Message + 'static + Send + Sync {
move |input_value: &T| match value(input_value) { move |input_value: &T| match value(input_value) {
Some(value) => NodeGraphMessage::SetInputValue { node_id, input_index, value }.into(), Some(value) => NodeGraphMessage::SetInputValue {
node_id,
input_index,
value: value.into(),
}
.into(),
None => Message::NoOp, None => Message::NoOp,
} }
} }
@@ -901,7 +906,7 @@ pub fn font_inputs(parameter_widgets_info: ParameterWidgetsInfo) -> (Vec<WidgetI
NodeGraphMessage::SetInputValue { NodeGraphMessage::SetInputValue {
node_id, node_id,
input_index: graphene_std::text::text::FontInput::INDEX, input_index: graphene_std::text::text::FontInput::INDEX,
value: TaggedValue::Resource(resource_id), value: TaggedValue::Resource(resource_id).into(),
} }
.into(), .into(),
]), ]),
@@ -1478,7 +1483,7 @@ fn build_shared_spectrum_section(node_id: NodeId, context: &mut NodePropertiesCo
NodeGraphMessage::SetInputValue { NodeGraphMessage::SetInputValue {
node_id, node_id,
input_index, input_index,
value: TaggedValue::F32(percent.clamp(0., 100.) as f32), value: TaggedValue::F32(percent.clamp(0., 100.) as f32).into(),
} }
.into() .into()
} }
@@ -1635,7 +1640,7 @@ fn spectrum_slider_row(
NodeGraphMessage::SetInputValue { NodeGraphMessage::SetInputValue {
node_id, node_id,
input_index, input_index,
value: TaggedValue::F32(position_to_value(new_position).clamp(value_min, value_max) as f32), value: TaggedValue::F32(position_to_value(new_position).clamp(value_min, value_max) as f32).into(),
} }
.into() .into()
}) })
@@ -2189,13 +2194,13 @@ pub(crate) fn string_capitalization_properties(node_id: NodeId, context: &mut No
NodeGraphMessage::SetInputValue { NodeGraphMessage::SetInputValue {
node_id, node_id,
input_index: UseJoinerInput::INDEX, input_index: UseJoinerInput::INDEX,
value: TaggedValue::Bool(true), value: TaggedValue::Bool(true).into(),
} }
.into(), .into(),
NodeGraphMessage::SetInputValue { NodeGraphMessage::SetInputValue {
node_id, node_id,
input_index: JoinerInput::INDEX, input_index: JoinerInput::INDEX,
value: TaggedValue::String(value.clone()), value: TaggedValue::String(value.clone()).into(),
} }
.into(), .into(),
]), ]),
@@ -2250,13 +2255,13 @@ pub(crate) fn rectangle_properties(node_id: NodeId, context: &mut NodeProperties
NodeGraphMessage::SetInputValue { NodeGraphMessage::SetInputValue {
node_id, node_id,
input_index: IndividualCornerRadiiInput::INDEX, input_index: IndividualCornerRadiiInput::INDEX,
value: TaggedValue::Bool(false), value: TaggedValue::Bool(false).into(),
} }
.into(), .into(),
NodeGraphMessage::SetInputValue { NodeGraphMessage::SetInputValue {
node_id, node_id,
input_index: CornerRadiusInput::INDEX, input_index: CornerRadiusInput::INDEX,
value: TaggedValue::BoxCorners(BoxCorners::from(uniform_val)), value: TaggedValue::BoxCorners(BoxCorners::from(uniform_val)).into(),
} }
.into(), .into(),
]), ]),
@@ -2269,13 +2274,13 @@ pub(crate) fn rectangle_properties(node_id: NodeId, context: &mut NodeProperties
NodeGraphMessage::SetInputValue { NodeGraphMessage::SetInputValue {
node_id, node_id,
input_index: IndividualCornerRadiiInput::INDEX, input_index: IndividualCornerRadiiInput::INDEX,
value: TaggedValue::Bool(true), value: TaggedValue::Bool(true).into(),
} }
.into(), .into(),
NodeGraphMessage::SetInputValue { NodeGraphMessage::SetInputValue {
node_id, node_id,
input_index: CornerRadiusInput::INDEX, input_index: CornerRadiusInput::INDEX,
value: TaggedValue::BoxCorners(BoxCorners::from(corner_values.to_vec())), value: TaggedValue::BoxCorners(BoxCorners::from(corner_values.to_vec())).into(),
} }
.into(), .into(),
]), ]),
@@ -2577,7 +2582,7 @@ pub(crate) fn fill_properties(node_id: NodeId, context: &mut NodePropertiesConte
NodeGraphMessage::SetInputValue { NodeGraphMessage::SetInputValue {
node_id, node_id,
input_index: FillInput::<List<Graphic>>::INDEX, input_index: FillInput::<List<Graphic>>::INDEX,
value: color.map_or_else(TaggedValue::no_paint, TaggedValue::Color), value: color.map_or_else(TaggedValue::no_paint, TaggedValue::Color).into(),
} }
.into(), .into(),
]; ];
@@ -2586,7 +2591,7 @@ pub(crate) fn fill_properties(node_id: NodeId, context: &mut NodePropertiesConte
NodeGraphMessage::SetInputValue { NodeGraphMessage::SetInputValue {
node_id, node_id,
input_index: BackupColorInput::INDEX, input_index: BackupColorInput::INDEX,
value: TaggedValue::Color(color), value: TaggedValue::Color(color).into(),
} }
.into(), .into(),
); );
@@ -2599,13 +2604,13 @@ pub(crate) fn fill_properties(node_id: NodeId, context: &mut NodePropertiesConte
NodeGraphMessage::SetInputValue { NodeGraphMessage::SetInputValue {
node_id, node_id,
input_index: FillInput::<List<Graphic>>::INDEX, input_index: FillInput::<List<Graphic>>::INDEX,
value: TaggedValue::Gradient(gradient.clone()), value: TaggedValue::Gradient(gradient.clone()).into(),
} }
.into(), .into(),
NodeGraphMessage::SetInputValue { NodeGraphMessage::SetInputValue {
node_id, node_id,
input_index: BackupGradientInput::INDEX, input_index: BackupGradientInput::INDEX,
value: TaggedValue::Gradient(gradient), value: TaggedValue::Gradient(gradient).into(),
} }
.into(), .into(),
]), ]),
@@ -2714,13 +2719,13 @@ pub(crate) fn fill_properties(node_id: NodeId, context: &mut NodePropertiesConte
NodeGraphMessage::SetInputValue { NodeGraphMessage::SetInputValue {
node_id, node_id,
input_index: HasTransformInput::INDEX, input_index: HasTransformInput::INDEX,
value: TaggedValue::Bool(true), value: TaggedValue::Bool(true).into(),
} }
.into(), .into(),
NodeGraphMessage::SetInputValue { NodeGraphMessage::SetInputValue {
node_id, node_id,
input_index: TransformInput::INDEX, input_index: TransformInput::INDEX,
value: TaggedValue::DAffine2(new_transform), value: TaggedValue::DAffine2(new_transform).into(),
} }
.into(), .into(),
]), ]),
@@ -747,7 +747,7 @@ async fn none_fill_survives_document_reopen() {
.handle_message(NodeGraphMessage::SetInputValue { .handle_message(NodeGraphMessage::SetInputValue {
node_id: fill_node_id, node_id: fill_node_id,
input_index: graphene_std::vector::fill::FillInput::<graphene_std::list::List<graphene_std::Graphic>>::INDEX, input_index: graphene_std::vector::fill::FillInput::<graphene_std::list::List<graphene_std::Graphic>>::INDEX,
value: graph_craft::document::value::TaggedValue::no_paint(), value: graph_craft::document::value::TaggedValue::no_paint().into(),
}) })
.await; .await;
assert!(fill_paint_value(editor.active_document()).is_no_paint(), "the None pick should store as no_paint"); assert!(fill_paint_value(editor.active_document()).is_no_paint(), "the None pick should store as no_paint");
@@ -1106,12 +1106,12 @@ impl NodeNetworkInterface {
DocumentNodeClickTargets { DocumentNodeClickTargets {
node_click_target, node_click_target,
port_click_targets, port_click_targets,
node_type_metadata: NodeTypeClickTargets::Layer(LayerClickTargets { node_type_metadata: NodeTypeClickTargets::Layer(Box::new(LayerClickTargets {
visibility_click_target, visibility_click_target,
lock_click_target, lock_click_target,
grip_click_target, grip_click_target,
name_click_target, name_click_target,
}), })),
} }
}; };
@@ -736,7 +736,7 @@ pub struct DocumentNodeClickTargets {
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum NodeTypeClickTargets { pub enum NodeTypeClickTargets {
Layer(LayerClickTargets), Layer(Box<LayerClickTargets>),
Node, // No transient click targets are stored exclusively for nodes Node, // No transient click targets are stored exclusively for nodes
} }
@@ -615,7 +615,11 @@ pub fn set_stroke_weight_for_selected_layers(weight: f64, document: &DocumentMes
if let Some(node_id) = get_stroke_id(layer, &document.network_interface) { if let Some(node_id) = get_stroke_id(layer, &document.network_interface) {
let input_index = graphene_std::vector::stroke::WeightInput::INDEX; let input_index = graphene_std::vector::stroke::WeightInput::INDEX;
let value = TaggedValue::F64(weight); let value = TaggedValue::F64(weight);
responses.add(NodeGraphMessage::SetInputValue { node_id, input_index, value }); responses.add(NodeGraphMessage::SetInputValue {
node_id,
input_index,
value: value.into(),
});
} else if weight > 0. { } else if weight > 0. {
let color = Some(Color::BLACK); let color = Some(Color::BLACK);
let stroke = graphene_std::vector::style::Stroke::default().with_weight(weight); let stroke = graphene_std::vector::style::Stroke::default().with_weight(weight);
@@ -834,7 +838,11 @@ pub fn set_stroke_color_for_selected_layers(color: Option<Color>, weight: f64, d
if let Some(node_id) = get_stroke_id(layer, &document.network_interface) { if let Some(node_id) = get_stroke_id(layer, &document.network_interface) {
let input_index = graphene_std::vector::stroke::PaintInput::<List<Graphic>>::INDEX; let input_index = graphene_std::vector::stroke::PaintInput::<List<Graphic>>::INDEX;
let value = color.map_or_else(TaggedValue::no_paint, TaggedValue::Color); let value = color.map_or_else(TaggedValue::no_paint, TaggedValue::Color);
responses.add(NodeGraphMessage::SetInputValue { node_id, input_index, value }); responses.add(NodeGraphMessage::SetInputValue {
node_id,
input_index,
value: value.into(),
});
} else { } else {
let stroke = graphene_std::vector::style::Stroke::new(weight); let stroke = graphene_std::vector::style::Stroke::new(weight);
responses.add(GraphOperationMessage::StrokeSet { layer, color, stroke }); responses.add(GraphOperationMessage::StrokeSet { layer, color, stroke });
@@ -904,7 +912,7 @@ pub fn set_proto_node_input_for_selected_layers(
responses.add(NodeGraphMessage::SetInputValue { responses.add(NodeGraphMessage::SetInputValue {
node_id, node_id,
input_index, input_index,
value: value.clone(), value: value.clone().into(),
}); });
} }
} }
@@ -2159,7 +2159,8 @@ mod test_gradient {
midpoint: 0.5, midpoint: 0.5,
color: Color::BLUE, color: Color::BLUE,
}, },
])), ]))
.into(),
}) })
.await; .await;
@@ -2196,7 +2197,8 @@ mod test_gradient {
midpoint: 0.5, midpoint: 0.5,
color: Color::BLUE, color: Color::BLUE,
}, },
])), ]))
.into(),
}) })
.await; .await;
@@ -2839,7 +2841,8 @@ mod test_gradient {
midpoint: 0.5, midpoint: 0.5,
color: Color::BLUE, color: Color::BLUE,
}, },
])), ]))
.into(),
}) })
.await; .await;
@@ -118,7 +118,7 @@ fn create_text_widgets(tool: &TextTool, font_catalog: &FontCatalog, document: &D
NodeGraphMessage::SetInputValue { NodeGraphMessage::SetInputValue {
node_id, node_id,
input_index: graphene_std::text::text::FontInput::INDEX, input_index: graphene_std::text::text::FontInput::INDEX,
value: TaggedValue::Resource(resource_id), value: TaggedValue::Resource(resource_id).into(),
} }
.into(), .into(),
]), ]),
@@ -349,7 +349,7 @@ impl<'a> MessageHandler<ToolMessage, &mut ToolActionMessageContext<'a>> for Text
responses.add(NodeGraphMessage::SetInputValue { responses.add(NodeGraphMessage::SetInputValue {
node_id, node_id,
input_index: graphene_std::text::text::SizeInput::INDEX, input_index: graphene_std::text::text::SizeInput::INDEX,
value: TaggedValue::F64(font_size), value: TaggedValue::F64(font_size).into(),
}); });
} }
} }
@@ -364,7 +364,7 @@ impl<'a> MessageHandler<ToolMessage, &mut ToolActionMessageContext<'a>> for Text
responses.add(NodeGraphMessage::SetInputValue { responses.add(NodeGraphMessage::SetInputValue {
node_id, node_id,
input_index: graphene_std::text::text::AlignInput::INDEX, input_index: graphene_std::text::text::AlignInput::INDEX,
value: TaggedValue::TextAlign(align), value: TaggedValue::TextAlign(align).into(),
}); });
} }
} }
+2 -2
View File
@@ -48,7 +48,7 @@ pub struct CompilationResponse {
} }
pub enum NodeGraphUpdate { pub enum NodeGraphUpdate {
ExecutionResponse(ExecutionResponse), ExecutionResponse(Box<ExecutionResponse>),
CompilationResponse(CompilationResponse), CompilationResponse(CompilationResponse),
EyedropperPreview(Raster<CPU>), EyedropperPreview(Raster<CPU>),
NodeGraphUpdateMessage(NodeGraphUpdateMessage), NodeGraphUpdateMessage(NodeGraphUpdateMessage),
@@ -365,7 +365,7 @@ impl NodeGraphExecutor {
responses: existing_responses, responses: existing_responses,
vector_modify, vector_modify,
inspect_result, inspect_result,
} = execution_response; } = *execution_response;
while let Some(&(queued_execution_id, _)) = self.futures.front() { while let Some(&(queued_execution_id, _)) = self.futures.front() {
if queued_execution_id < execution_id { if queued_execution_id < execution_id {
+1 -1
View File
@@ -102,7 +102,7 @@ impl InternalNodeGraphUpdateSender {
} }
fn send_execution_response(&self, response: ExecutionResponse) { fn send_execution_response(&self, response: ExecutionResponse) {
self.0.send(NodeGraphUpdate::ExecutionResponse(response)).expect("Failed to send response") self.0.send(NodeGraphUpdate::ExecutionResponse(Box::new(response))).expect("Failed to send response")
} }
fn send_eyedropper_preview(&self, raster: Raster<CPU>) { fn send_eyedropper_preview(&self, raster: Raster<CPU>) {
+1 -1
View File
@@ -179,7 +179,7 @@ pub(crate) fn generate_node_code(crate_ident: &CrateIdent, parsed: &ParsedNodeFn
} }
} }
ParsedValueSource::Scope(data) => { 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.as_ref() {
quote!(RegistryValueSource::Scope(#data)) quote!(RegistryValueSource::Scope(#data))
} else { } else {
quote!(RegistryValueSource::Scope(#data.as_static_str())) quote!(RegistryValueSource::Scope(#data.as_static_str()))
+2 -2
View File
@@ -65,7 +65,7 @@ pub enum ParsedValueSource {
#[default] #[default]
None, None,
Default(TokenStream2), Default(TokenStream2),
Scope(Expr), Scope(Box<Expr>),
} }
// #[widget(ParsedWidgetOverride::Hidden)] // #[widget(ParsedWidgetOverride::Hidden)]
@@ -815,7 +815,7 @@ fn parse_field(pat_ident: PatIdent, ty: Type, attrs: &[Attribute]) -> syn::Resul
let value_source = match (default_value, scope) { let value_source = match (default_value, scope) {
(Some(_), Some(_)) => return Err(Error::new_spanned(&pat_ident, "Cannot have both `default` and `scope` attributes")), (Some(_), Some(_)) => return Err(Error::new_spanned(&pat_ident, "Cannot have both `default` and `scope` attributes")),
(Some(default_value), _) => ParsedValueSource::Default(default_value), (Some(default_value), _) => ParsedValueSource::Default(default_value),
(_, Some(scope)) => ParsedValueSource::Scope(scope), (_, Some(scope)) => ParsedValueSource::Scope(Box::new(scope)),
_ => ParsedValueSource::None, _ => ParsedValueSource::None,
}; };
@@ -241,7 +241,7 @@ impl PerPixelAdjustCodegen<'_> {
ty: ParsedFieldType::classify(RegularParsedField { ty: ParsedFieldType::classify(RegularParsedField {
ty: parse_quote!(#gcore::list::Item<&'a WgpuExecutor>), ty: parse_quote!(#gcore::list::Item<&'a WgpuExecutor>),
exposed: true, exposed: true,
value_source: ParsedValueSource::Scope(parse_quote!("graphene_std::platform_application_io::WgpuExecutorNode")), value_source: ParsedValueSource::Scope(Box::new(parse_quote!("graphene_std::platform_application_io::WgpuExecutorNode"))),
number_soft_min: None, number_soft_min: None,
number_soft_max: None, number_soft_max: None,
number_hard_min: None, number_hard_min: None,