diff --git a/editor/src/messages/portfolio/document/node_graph/node_properties.rs b/editor/src/messages/portfolio/document/node_graph/node_properties.rs index 5eb1e76c76..ecf9adf933 100644 --- a/editor/src/messages/portfolio/document/node_graph/node_properties.rs +++ b/editor/src/messages/portfolio/document/node_graph/node_properties.rs @@ -323,7 +323,6 @@ pub(crate) fn property_from_type( Type::Generic(_) => vec![TextLabel::new("Generic Type (Not Supported)").widget_instance()].into(), Type::Fn(_, out) => return property_from_type(node_id, index, out, number_options, unit, display_decimal_places, step, context), Type::Future(out) => return property_from_type(node_id, index, out, number_options, unit, display_decimal_places, step, context), - Type::Ref(inner) => return property_from_type(node_id, index, inner, number_options, unit, display_decimal_places, step, context), Type::Record(inner) => return property_from_type(node_id, index, inner, number_options, unit, display_decimal_places, step, context), }; diff --git a/node-graph/graph-craft/src/document/value.rs b/node-graph/graph-craft/src/document/value.rs index 40e12a4d70..e9aaf3f7f3 100644 --- a/node-graph/graph-craft/src/document/value.rs +++ b/node-graph/graph-craft/src/document/value.rs @@ -434,7 +434,6 @@ macro_rules! tagged_value { pub fn from_type(input: &Type) -> Option { match input { Type::Generic(_) => None, - Type::Ref(inner) => Self::from_type(inner), Type::Record(inner) => Self::from_type(inner), Type::Concrete(concrete_type) => { let name = concrete_type.name.as_ref(); @@ -696,7 +695,6 @@ impl TaggedValue { match ty { Type::Generic(_) => None, - Type::Ref(_) => None, Type::Record(_) => None, Type::Concrete(concrete_type) => { let ty = concrete_type.id?; diff --git a/node-graph/graph-craft/src/proto.rs b/node-graph/graph-craft/src/proto.rs index 7a35198703..1e6afbfa84 100644 --- a/node-graph/graph-craft/src/proto.rs +++ b/node-graph/graph-craft/src/proto.rs @@ -906,7 +906,6 @@ fn valid_type(from: &Type, to: &Type) -> bool { // More details explained here: (Type::Fn(in1, out1), Type::Fn(in2, out2)) => valid_type(out2, out1) && valid_type(in1, in2), // A lend edge is substitutable exactly when the lent values are. - (Type::Ref(in1), Type::Ref(in2)) => valid_type(in1, in2), // A record edge is substitutable exactly when the elements are. (Type::Record(in1), Type::Record(in2)) => valid_type(in1, in2), // If either the proposed input or the allowed input are generic, we allow the substitution (meaning this is a valid subtype). diff --git a/node-graph/libraries/core-types/src/registry.rs b/node-graph/libraries/core-types/src/registry.rs index b0b6882bb7..e8ec9bf07e 100644 --- a/node-graph/libraries/core-types/src/registry.rs +++ b/node-graph/libraries/core-types/src/registry.rs @@ -74,10 +74,6 @@ pub use crate::NodeIOTypes; pub type ErasedNode = dyn for<'c> Node, Output = T> + Send + Sync; #[cfg(target_family = "wasm")] pub type ErasedNode = dyn for<'c> Node, Output = T>; -#[cfg(not(target_family = "wasm"))] -pub type ErasedLendNode = dyn for<'c> Node, Output = &'c T> + Send + Sync; -#[cfg(target_family = "wasm")] -pub type ErasedLendNode = dyn for<'c> Node, Output = &'c T>; /// Element-independent by erasure; the wire's `Type::Record(El)` keeps element reads proven at wiring. #[cfg(not(target_family = "wasm"))] @@ -94,14 +90,6 @@ pub fn edge_type() -> Type { Type::Fn(Box::new(concrete!(Context)), Box::new(concrete!(T))) } -pub fn ref_type() -> Type { - Type::Ref(Box::new(concrete!(T))) -} - -pub fn lend_edge_type() -> Type { - Type::Fn(Box::new(concrete!(Context)), Box::new(ref_type::())) -} - pub fn record_type() -> Type { Type::Record(Box::new(concrete!(T))) } @@ -112,10 +100,7 @@ pub fn record_edge_type() -> Type { /// The record edge type of a token row, generic over the element. pub fn generic_record_edge_type(name: &'static str) -> Type { - Type::Fn( - Box::new(concrete!(Context)), - Box::new(Type::Record(Box::new(Type::Generic(std::borrow::Cow::Borrowed(name))))), - ) + Type::Fn(Box::new(concrete!(Context)), Box::new(Type::Record(Box::new(Type::Generic(std::borrow::Cow::Borrowed(name)))))) } pub fn cache_key(ctx: &C) -> u64 { @@ -217,10 +202,6 @@ impl EdgeHandle { Self::new_erased(node, edge_type::()) } - pub fn new_ref(node: std::sync::Arc>) -> Self { - Self::new_erased(node, lend_edge_type::()) - } - pub fn new_record(node: std::sync::Arc) -> Self { Self::new_erased(node, record_edge_type::()) } @@ -265,10 +246,6 @@ impl EdgeHandle { self.downcast_erased(edge_type::()) } - pub fn downcast_lend(self) -> Result>, ConstructionError> { - self.downcast_erased(lend_edge_type::()) - } - pub fn downcast_record(self) -> Result, ConstructionError> { self.downcast_erased(record_edge_type::()) } @@ -430,9 +407,9 @@ mod tests { let scope = scope_fixture(&generations, &arena); let ctx = ContextImpl::root(&scope); - let lending = EdgeHandle::new_ref(Arc::new(LendNode("held".to_string())) as Arc>); - let upstream = lending.downcast_lend::().unwrap(); - let node: Arc = Arc::new(SplitNode { content: upstream }); + let node: Arc = Arc::new(SplitNode { + content: LendNode("held".to_string()), + }); let handle = EdgeHandle::new_erased(node, concrete!(SplitBorrow<'static>)); assert_eq!(*handle.ty(), concrete!(SplitBorrow<'static>)); @@ -572,15 +549,6 @@ mod tests { found: Box::new(edge_type::()), } ); - - let lent = EdgeHandle::new_ref(Arc::new(LendNode("typed".to_string())) as Arc>); - assert_eq!( - construct(&entry, vec![lent]).unwrap_err(), - ConstructionError::Type { - expected: Box::new(edge_type::()), - found: Box::new(lend_edge_type::()), - } - ); } #[test] diff --git a/node-graph/libraries/core-types/src/types.rs b/node-graph/libraries/core-types/src/types.rs index e1558de29d..523b45395d 100644 --- a/node-graph/libraries/core-types/src/types.rs +++ b/node-graph/libraries/core-types/src/types.rs @@ -235,7 +235,6 @@ pub enum Type { Fn(Box, Box), /// Represents a future which promises to return the inner type. Future(Box), - Ref(Box), /// A packed record wire over the element type; the layout stays node-resident metadata. Record(Box), } @@ -311,7 +310,6 @@ impl Type { Self::Concrete(ty) => Some(ty.size), Self::Fn(_, _) => None, Self::Future(_) => None, - Self::Ref(_) => None, Self::Record(_) => None, } } @@ -322,7 +320,6 @@ impl Type { Self::Concrete(ty) => Some(ty.align), Self::Fn(_, _) => None, Self::Future(_) => None, - Self::Ref(_) => None, Self::Record(_) => None, } } @@ -333,7 +330,6 @@ impl Type { Self::Concrete(_) => self, Self::Fn(_, output) => output.nested_type(), Self::Future(output) => output.nested_type(), - Self::Ref(inner) => inner.nested_type(), Self::Record(inner) => inner.nested_type(), } } @@ -347,7 +343,6 @@ impl Type { Self::Concrete(_) => None, Self::Fn(_, output) => output.replace_nested(f), Self::Future(output) => output.replace_nested(f), - Self::Ref(inner) => inner.replace_nested(f), Self::Record(inner) => inner.replace_nested(f), } } @@ -358,7 +353,6 @@ impl Type { Type::Concrete(ty) => simplify_identifier_name(&ty.name), Type::Fn(call_arg, return_value) => format!("{} called with {}", return_value.identifier_name(), call_arg.identifier_name()), Type::Future(ty) => ty.identifier_name(), - Type::Ref(ty) => ty.identifier_name(), Type::Record(ty) => ty.identifier_name(), } } @@ -454,7 +448,6 @@ impl std::fmt::Display for Type { Type::Concrete(ty) => write!(f, "{ty}"), Type::Fn(_, return_value) => write!(f, "{return_value}"), Type::Future(ty) => write!(f, "{ty}"), - Type::Ref(ty) => write!(f, "{ty}"), Type::Record(ty) => write!(f, "{ty}"), } } diff --git a/node-graph/node-macro/src/codegen.rs b/node-graph/node-macro/src/codegen.rs index 6a64a71161..93002e5958 100644 --- a/node-graph/node-macro/src/codegen.rs +++ b/node-graph/node-macro/src/codegen.rs @@ -2149,54 +2149,24 @@ fn entries_tokens(parsed: &ParsedNodeFn, struct_name: &Ident, data_field_generic return quote!(); } - let ref_output_inner = match slot_value_type(&parsed.output_type) { - Type::Reference(reference) => Some((*reference.elem).clone()), - _ => None, - }; - if let Some(inner) = &ref_output_inner { - let ctx_ident = context_param(parsed).map(|ctx| ctx.ident.clone()); - let open_generics = parsed.fn_generics.iter().filter_map(|param| match param { - GenericParam::Type(type_param) if Some(&type_param.ident) != ctx_ident.as_ref() => Some(&type_param.ident), - _ => None, - }); - if open_generics.into_iter().any(|generic| type_contains_ident(inner, generic)) { - return quote!(); - } + if matches!(slot_value_type(&parsed.output_type), Type::Reference(_)) { + return quote!(); } let fn_name = &parsed.fn_name; let entries_name = format_ident!("{}_entries", fn_name); let arity = regular_fields.len(); let names: Vec<&Ident> = regular_fields.iter().map(|field| &field.pat_ident.ident).collect(); - let lend_flags: Vec = regular_fields - .iter() - .map(|field| matches!(&field.ty, ParsedFieldType::Regular(RegularParsedField { lend: Some(_), .. }))) - .collect(); let entries = rows.iter().map(|row| { - let input_types = row.iter().zip(&lend_flags).map(|(ty, lend)| match lend { - true => quote!(gcore::registry::lend_edge_type::<#ty>()), - false => quote!(gcore::registry::edge_type::<#ty>()), - }); - let edge_types = row.iter().zip(&lend_flags).map(|(ty, lend)| match lend { - true => quote!(gcore::registry::SharedEdge>), - false => quote!(gcore::registry::SharedEdge>), - }); + let input_types = row.iter().map(|ty| quote!(gcore::registry::edge_type::<#ty>())); + let edge_types = row.iter().map(|ty| quote!(gcore::registry::SharedEdge>)); let output = quote!(<#struct_name<#(#edge_types),*> as gcore::node::Node>>::Output); - let (io_output, construct) = match &ref_output_inner { - Some(inner) => ( - quote!(gcore::registry::ref_type::<#inner>()), - quote!(Ok(gcore::registry::EdgeHandle::new_ref(::std::sync::Arc::new(#struct_name::new(#(#names),*)) as ::std::sync::Arc>))), - ), - None => ( - quote!(gcore::concrete!(#output)), - quote!(Ok(gcore::registry::EdgeHandle::new(::std::sync::Arc::new(#struct_name::new(#(#names),*)) as ::std::sync::Arc>))), - ), - }; - let downcasts = names.iter().zip(row.iter()).zip(&lend_flags).map(|((name, ty), lend)| match lend { - true => quote!(let #name = inputs.next().unwrap().downcast_lend::<#ty>()?;), - false => quote!(let #name = inputs.next().unwrap().downcast::<#ty>()?;), - }); + let (io_output, construct) = ( + quote!(gcore::concrete!(#output)), + quote!(Ok(gcore::registry::EdgeHandle::new(::std::sync::Arc::new(#struct_name::new(#(#names),*)) as ::std::sync::Arc>))), + ); + let downcasts = names.iter().zip(row.iter()).map(|(name, ty)| quote!(let #name = inputs.next().unwrap().downcast::<#ty>()?;)); quote! { gcore::registry::RegistryEntry { io: gcore::registry::NodeIOTypes::new( @@ -2417,7 +2387,7 @@ fn routing_entries_tokens(parsed: &ParsedNodeFn, struct_name: &Ident, regular_fi return quote!(gcore::registry::generic_record_edge_type(#token_name)); } match &field.ty { - ParsedFieldType::Regular(RegularParsedField { ty, lend: Some(_), .. }) => quote!(gcore::registry::lend_edge_type::<#ty>()), + ParsedFieldType::Regular(RegularParsedField { ty, lend: Some(_), .. }) => quote!(gcore::registry::edge_type::<#ty>()), ParsedFieldType::Regular(RegularParsedField { ty, .. }) => quote!(gcore::registry::edge_type::<#ty>()), ParsedFieldType::Node(NodeParsedField { output_type, .. }) => quote!(gcore::registry::edge_type::<#output_type>()), } @@ -2444,7 +2414,7 @@ fn routing_entries_tokens(parsed: &ParsedNodeFn, struct_name: &Ident, regular_fi }; } match &field.ty { - ParsedFieldType::Regular(RegularParsedField { ty, lend: Some(_), .. }) => quote!(let #name = inputs.next().unwrap().downcast_lend::<#ty>()?;), + ParsedFieldType::Regular(RegularParsedField { ty, lend: Some(_), .. }) => quote!(let #name = inputs.next().unwrap().downcast::<#ty>()?;), ParsedFieldType::Regular(RegularParsedField { ty, .. }) => quote!(let #name = inputs.next().unwrap().downcast::<#ty>()?;), ParsedFieldType::Node(NodeParsedField { output_type, .. }) => quote!(let #name = inputs.next().unwrap().downcast::<#output_type>()?;), } @@ -2511,7 +2481,7 @@ fn record_opaque_entries_tokens(parsed: &ParsedNodeFn, struct_name: &Ident, regu return quote!(gcore::registry::generic_record_edge_type("T")); } match &field.ty { - ParsedFieldType::Regular(RegularParsedField { ty, lend: Some(_), .. }) => quote!(gcore::registry::lend_edge_type::<#ty>()), + ParsedFieldType::Regular(RegularParsedField { ty, lend: Some(_), .. }) => quote!(gcore::registry::edge_type::<#ty>()), ParsedFieldType::Regular(RegularParsedField { ty, .. }) => quote!(gcore::registry::edge_type::<#ty>()), ParsedFieldType::Node(NodeParsedField { output_type, .. }) => quote!(gcore::registry::edge_type::<#output_type>()), } @@ -2532,7 +2502,7 @@ fn record_opaque_entries_tokens(parsed: &ParsedNodeFn, struct_name: &Ident, regu }; } match &field.ty { - ParsedFieldType::Regular(RegularParsedField { ty, lend: Some(_), .. }) => quote!(let #name = inputs.next().unwrap().downcast_lend::<#ty>()?;), + ParsedFieldType::Regular(RegularParsedField { ty, lend: Some(_), .. }) => quote!(let #name = inputs.next().unwrap().downcast::<#ty>()?;), ParsedFieldType::Regular(RegularParsedField { ty, .. }) => quote!(let #name = inputs.next().unwrap().downcast::<#ty>()?;), ParsedFieldType::Node(NodeParsedField { output_type, .. }) => quote!(let #name = inputs.next().unwrap().downcast::<#output_type>()?;), } diff --git a/node-graph/nodes/gcore/src/memo.rs b/node-graph/nodes/gcore/src/memo.rs index c5482c0ca7..590a1fd992 100644 --- a/node-graph/nodes/gcore/src/memo.rs +++ b/node-graph/nodes/gcore/src/memo.rs @@ -130,7 +130,7 @@ mod tests { use core_types::SourceId; use core_types::arena::Arena; use core_types::context::{ContextImpl, EvalScope}; - use core_types::registry::{EdgeHandle, ErasedLendNode, ErasedNode, ErasedRecordNode}; + use core_types::registry::{EdgeHandle, ErasedNode, ErasedRecordNode}; use std::sync::atomic::{AtomicU32, Ordering}; struct CountingNode(AtomicU32);