From e35f5afcec6f9cdc6bf58c2de20217888b845b60 Mon Sep 17 00:00:00 2001 From: Craig Roy Date: Mon, 23 Oct 2023 13:56:24 +0100 Subject: [PATCH] cleanup: Remove `add_node_before` --- src/builder/conditional.rs | 2 +- src/extension/infer.rs | 2 +- src/hugr/hugrmut.rs | 15 +-------------- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/builder/conditional.rs b/src/builder/conditional.rs index f1af1ad0d..3b3288270 100644 --- a/src/builder/conditional.rs +++ b/src/builder/conditional.rs @@ -127,7 +127,7 @@ impl + AsRef> ConditionalBuilder { // add case before any existing subsequent cases if let Some(&sibling_node) = self.case_nodes[case + 1..].iter().flatten().next() { // TODO: Allow this to be non-pure - self.hugr_mut().add_node_before(sibling_node, NodeType::open_extensions(case_op))? + self.hugr_mut().add_op_before(sibling_node, case_op)? } else { self.add_child_node(NodeType::open_extensions(case_op))? }; diff --git a/src/extension/infer.rs b/src/extension/infer.rs index ae59d9127..83f956a4f 100644 --- a/src/extension/infer.rs +++ b/src/extension/infer.rs @@ -1217,7 +1217,7 @@ mod test { }), )?; - let entry = hugr.add_node_before(exit, NodeType::open_extensions(dfb))?; + let entry = hugr.add_op_before(exit, dfb)?; let entry_in = hugr.add_node_with_parent( entry, NodeType::open_extensions(ops::Input { types: inputs }), diff --git a/src/hugr/hugrmut.rs b/src/hugr/hugrmut.rs index 7f91752b5..b70d99be8 100644 --- a/src/hugr/hugrmut.rs +++ b/src/hugr/hugrmut.rs @@ -66,15 +66,6 @@ pub trait HugrMut: HugrMutInternals { self.hugr_mut().add_op_before(sibling, op) } - /// A generalisation of [`HugrMut::add_op_before`], needed temporarily until - /// add_op type methods all default to creating nodes with open extensions. - /// See issue #424 - #[inline] - fn add_node_before(&mut self, sibling: Node, nodetype: NodeType) -> Result { - self.valid_non_root(sibling)?; - self.hugr_mut().add_node_before(sibling, nodetype) - } - /// Add a node to the graph as the next sibling of another node. /// /// The sibling node's parent becomes the new node's parent. @@ -216,11 +207,7 @@ impl + AsMut> HugrMut for T { } fn add_op_before(&mut self, sibling: Node, op: impl Into) -> Result { - self.add_node_before(sibling, NodeType::pure(op)) - } - - fn add_node_before(&mut self, sibling: Node, nodetype: NodeType) -> Result { - let node = self.as_mut().add_node(nodetype); + let node = self.as_mut().add_node(NodeType::open_extensions(op)); self.as_mut() .hierarchy .insert_before(node.index, sibling.index)?;