-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Rewrite for inlining a single Call #1934
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1934 +/- ##
==========================================
+ Coverage 83.70% 83.76% +0.05%
==========================================
Files 198 199 +1
Lines 37823 38111 +288
Branches 34636 34924 +288
==========================================
+ Hits 31661 31922 +261
+ Misses 4376 4375 -1
- Partials 1786 1814 +28
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
hugr-core/src/hugr/hugrmut.rs
Outdated
@@ -448,6 +456,50 @@ impl<T: RootTagged<RootHandle = Node> + AsMut<Hugr>> HugrMut for T { | |||
} | |||
translate_indices(node_map) | |||
} | |||
|
|||
fn copy_descendants(&mut self, root: Node, new_parent: Node) -> HashMap<Node, Node> { | |||
// TODO should we check that we will not invalidate the Hugr? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My general feeling is that this is too hard, at the least, it involves at least O(size of subtree)
work (probably * O(depth)
), never mind Dom edges; and it'd only be meaningful if the new location was already in its final resting place in the hierarchy anyway. But it does leave a bit of a bad taste that a "valid" Rewrite could make a valid Hugr invalidate without warning or any method of detection....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any linear-typed edge incoming to
root
I don't think this a problem on its face. the ports of root have nothing to do with this. The copied Input node will have a linear outgoing edge, but it will be connected exactly once. A bigger problem is that new_parent
will now have two input nodes, unless you carefully arrange that it is initially empty
Non-local edges can't happen for FuncDefns, so that's nice.
Other methods on HugrMut
can invalidate the hugr, e.g. disconnect
. @aborgna-q What do you think? Should this method be on HugrMutInternals
?.
I would prefer this comment(well, at least the non-local edges bit) to be a doc on the definition in the trait.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think the linear-typed edge comment only applied to when I was copying subtrees not descendants, so I deleted that and left the rest....
Your example of disconnect
is good, so if the best we can do is to make this a doc comment (and raise an issue for better handling/detection of "nonlocal edges incoming to a subtree", if we don't have one already...hmmm), then let's do that....right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say yes. I tagged Agustin because he asked me to move a "dangerous" function, and he may disagree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@doug-q's comment seems reasonable imho.
We should describe how this may break the structure in the description, including the doubled i/o nodes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted in doc comment (in trait, not this impl, so a way away)
Coverage looks poor because of use of |
hugr-core/src/hugr/hugrmut.rs
Outdated
@@ -146,6 +146,14 @@ pub trait HugrMut: HugrMutInternals { | |||
self.hugr_mut().remove_node(node); | |||
} | |||
|
|||
/// Copies the strict descendants of `root` to under the `new_parent`. | |||
/// (That is, the immediate children of root, are copied to make children of `new_parent`). | |||
fn copy_descendants(&mut self, root: Node, new_parent: Node) -> HashMap<Node, Node> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could a test be refactored to use this function so it is covered?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done using RootChecked, SiblingMut is not much use
// Copy the optypes, metadata, and hierarchy | ||
for (&node, &new_node) in node_map.iter() { | ||
for ch in self.children(node).collect::<Vec<_>>() { | ||
self.set_parent(*node_map.get(&ch).unwrap(), new_node); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like the hierarchy part isn't covered, do you need a test with more nesting?
let [i] = fb.input_wires_arr(); | ||
let add = fb.add_dataflow_op(IntOpDef::iadd.with_log_width(5), [i, cst1])?; | ||
let call = fb.call( | ||
&FuncID::<true>::from(fb.container_node()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not for this PR but this recursive handle should probably in the function builder API
} | ||
assert_eq!(ancestors.next(), Some(main.node())); | ||
assert_eq!(ancestors.next(), Some(hugr.root())); | ||
assert_eq!(ancestors.next(), None); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
hugr-core/src/hugr/hugrmut.rs
Outdated
}*/ | ||
let mut nodes = Vec::new(); | ||
let mut q = VecDeque::from_iter(self.children(root)); | ||
while let Some(n) = q.pop_front() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use DescendentsView
here? This is such a common operation I think we should provide a helper for it. I have code golfed
iter::successors(Some(vec![root]), |nodes| {
let children = nodes.iter().flat_map(|&n| hugr.children(n)).collect_vec();
(!children.is_empty()).then_some(children)
})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I originally avoided this because I didn't want to "build a whole DescendantsGraph" but now I realize that a DescendantsGraph isn't much more than the collection of nodes that we want.
However, in fact there is a method in Hierarchy
that does pretty much exactly what we want. So I've used that. Do you (still) think it's worth adding a helper to HugrView??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general yes, for you here, no. Hierarchy is not available out-of-crate.
@@ -0,0 +1,234 @@ | |||
//! Rewrite to inline a Call to a FuncDefn by copying the body of the function | |||
//! into a DFG which replaces the Call node. | |||
use thiserror::Error; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use derive_more::Error
? One day we will be able to delete the thiserror dependency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wasn't obvious from looking at uses of both that we were trying to move from one to the other! But ok, done.
Ok(()) | ||
} | ||
|
||
fn apply(self, h: &mut impl HugrMut) -> Result<(), Self::Error> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you are considering the case of polymorphic functions here? I think you need to substitute the type args of the call into the signature and all descendents.
I fo think it's ok to reject polymorphic functions for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh dang that's a good point. Knew some things would get forgotten what with this sleeping over hack fortnight...
So I could do this later, but it's not much new code - you just need to iterate through the same nodes
and apply the substitution. However, this does involve cloning the OpType in copy_descendants
followed by applying the substitution (which is kinda a copy itself). So we could
- decide this bit of extra copying isn't important
- make substitution destructive (mutating). This would be perhaps the biggest change.
- pass a
impl Fn(&OpType) -> OpType
intocopy_descendants
. Seems a little bit arbitrary (shouldn't we also have callbacks to copy metadata, etc....) but I think it's reasonable to argue that we should have this one. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact on the third I am tempted to make copy_descendants
take an Option<Substitution>
rather than a generic callback. Substitution is pretty fundamental and it avoids the argument that we should also do the same thing for e.g. metadata ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the copying is important.
I do like passing an optional substitution, this is very nice.
It seems like a bit of a weird inter-module dependency, this is very low level, substitution pretty high level. But this is just a vibe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you were a type theorist, substitution would be a very low level op....lower level than copying a whole load of nodes which include types ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional substitution added, by "happy coincidence" test revealed the bug you mentioned too
}); | ||
let (in_ports, out_ports) = (new_op.input_count(), new_op.output_count()); | ||
h.replace_op(self.0, new_op).unwrap(); | ||
h.set_num_ports(self.0, in_ports as _, out_ports as _); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@trvto Is getting a panic here. I think it's being caused by the incoming order edge on the call. I think you need to disconnect it and reconnect them on the DFG, because the called_function_port has been deleted.
I think this would work because we know how DFGs and Call ports work, but it would be nice to debug_assert! our understanding in case it changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Panic was as per CQCL/portgraph#191 but fix included in portgraph release 13.3 which is in here now so would be good if you / @trvto could try again now.
And, code for handling move of Order edges also now included.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me but will defer to @doug-q for the approve
I see a test you added failing. I'll wait for you to fix that before I review again. |
Oop, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, thank you.
## 🤖 New release * `hugr-model`: 0.17.1 -> 0.18.0 (⚠ API breaking changes) * `hugr-core`: 0.14.4 -> 0.15.0 (⚠ API breaking changes) * `hugr-llvm`: 0.14.4 -> 0.15.0 (⚠ API breaking changes) * `hugr-passes`: 0.14.4 -> 0.15.0 (⚠ API breaking changes) * `hugr`: 0.14.4 -> 0.15.0 (✓ API compatible changes) * `hugr-cli`: 0.14.4 -> 0.15.0 (⚠ API breaking changes) ### ⚠ `hugr-model` breaking changes ```text --- failure enum_missing: pub enum removed or renamed --- Description: A publicly-visible enum cannot be imported by its prior path. A `pub use` may have been removed, or the enum itself may have been renamed or removed entirely. ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/enum_missing.ron Failed in: enum hugr_model::v0::ModelError, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:698 enum hugr_model::v0::Term, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:598 enum hugr_model::v0::ListPart, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:669 enum hugr_model::v0::Operation, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:452 enum hugr_model::v0::TuplePart, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:660 enum hugr_model::v0::ExtSetPart, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:678 --- failure function_missing: pub fn removed or renamed --- Description: A publicly-visible function cannot be imported by its prior path. A `pub use` may have been removed, or the function itself may have been renamed or removed entirely. ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/function_missing.ron Failed in: function hugr_model::v0::text::parse, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/text/parse.rs:41 function hugr_model::v0::text::print_to_string, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/text/print.rs:14 --- failure module_missing: pub module removed or renamed --- Description: A publicly-visible module cannot be imported by its prior path. A `pub use` may have been removed, or the module may have been renamed, removed, or made non-public. ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/module_missing.ron Failed in: mod hugr_model::v0::text, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/text/mod.rs:1 --- failure struct_missing: pub struct removed or renamed --- Description: A publicly-visible struct cannot be imported by its prior path. A `pub use` may have been removed, or the struct itself may have been renamed or removed entirely. ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/struct_missing.ron Failed in: struct hugr_model::v0::text::ParsedModule, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/text/parse.rs:34 struct hugr_model::v0::RegionScope, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:551 struct hugr_model::v0::VarId, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:354 struct hugr_model::v0::Param, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:689 struct hugr_model::v0::NodeId, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:322 struct hugr_model::v0::TermId, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:340 struct hugr_model::v0::Symbol, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:582 struct hugr_model::v0::text::ParseError, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/text/parse.rs:830 struct hugr_model::v0::LinkId, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:349 struct hugr_model::v0::Module, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:358 struct hugr_model::v0::Node, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:430 struct hugr_model::v0::LinkIndex, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:328 struct hugr_model::v0::RegionId, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:334 struct hugr_model::v0::Region, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:530 ``` ### ⚠ `hugr-core` breaking changes ```text --- failure method_requires_different_generic_type_params: method now requires a different number of generic type parameters --- Description: A method now requires a different number of generic type parameters than it used to. Uses of this method that supplied the previous number of generic types will be broken. ref: https://doc.rust-lang.org/reference/items/generics.html impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/method_requires_different_generic_type_params.ron Failed in: hugr_core::hugr::views::sibling_subgraph::SiblingSubgraph::try_from_nodes_with_checker takes 0 generic types instead of 1, in /tmp/.tmpgXR84S/hugr/hugr-core/src/hugr/views/sibling_subgraph.rs:234 hugr_core::hugr::views::SiblingSubgraph::try_from_nodes_with_checker takes 0 generic types instead of 1, in /tmp/.tmpgXR84S/hugr/hugr-core/src/hugr/views/sibling_subgraph.rs:234 --- failure struct_missing: pub struct removed or renamed --- Description: A publicly-visible struct cannot be imported by its prior path. A `pub use` may have been removed, or the struct itself may have been renamed or removed entirely. ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/struct_missing.ron Failed in: struct hugr_core::extension::prelude::Lift, previously in file /tmp/.tmpuOV2md/hugr-core/src/extension/prelude.rs:883 struct hugr_core::extension::prelude::LiftDef, previously in file /tmp/.tmpuOV2md/hugr-core/src/extension/prelude.rs:831 --- failure trait_associated_type_added: non-sealed public trait added associated type without default value --- Description: A non-sealed trait has gained an associated type without a default value, which breaks downstream implementations of the trait ref: https://doc.rust-lang.org/cargo/reference/semver.html#trait-new-item-no-default impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/trait_associated_type_added.ron Failed in: trait associated type hugr_core::hugr::internal::HugrInternals::Node in file /tmp/.tmpgXR84S/hugr/hugr-core/src/hugr/internal.rs:30 --- failure trait_method_added: pub trait method added --- Description: A non-sealed public trait added a new method without a default implementation, which breaks downstream implementations of the trait ref: https://doc.rust-lang.org/cargo/reference/semver.html#trait-new-item-no-default impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/trait_method_added.ron Failed in: trait method hugr_core::hugr::internal::HugrInternals::get_pg_index in file /tmp/.tmpgXR84S/hugr/hugr-core/src/hugr/internal.rs:42 trait method hugr_core::hugr::internal::HugrInternals::get_node in file /tmp/.tmpgXR84S/hugr/hugr-core/src/hugr/internal.rs:45 --- failure trait_requires_more_generic_type_params: trait now requires more generic type parameters --- Description: A trait now requires more generic type parameters than it used to. Uses of this trait that supplied the previously-required number of generic types will be broken. To fix this, consider supplying default values for newly-added generic types. ref: https://doc.rust-lang.org/cargo/reference/semver.html#trait-new-parameter-no-default impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/trait_requires_more_generic_type_params.ron Failed in: trait HugrNodeRef (0 -> 1 required generic types) in /tmp/.tmpgXR84S/hugr/hugr-core/src/hugr/views/petgraph.rs:187 --- failure type_requires_more_generic_type_params: type now requires more generic type parameters --- Description: A type now requires more generic type parameters than it used to. Uses of this type that supplied the previously-required number of generic types will be broken. To fix this, consider supplying default values for newly-added generic types. ref: https://doc.rust-lang.org/cargo/reference/semver.html#trait-new-parameter-no-default impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/type_requires_more_generic_type_params.ron Failed in: Struct HugrNodeRef (0 -> 1 required generic types) in /tmp/.tmpgXR84S/hugr/hugr-core/src/hugr/views/petgraph.rs:187 ``` ### ⚠ `hugr-llvm` breaking changes ```text --- failure feature_missing: package feature removed or renamed --- Description: A feature has been removed from this package's Cargo.toml. This will break downstream crates which enable that feature. ref: https://doc.rust-lang.org/cargo/reference/semver.html#cargo-feature-remove impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/feature_missing.ron Failed in: feature typetag in the package's Cargo.toml feature pathsearch in the package's Cargo.toml feature serde in the package's Cargo.toml feature serde_json in the package's Cargo.toml ``` ### ⚠ `hugr-passes` breaking changes ```text --- failure function_requires_different_generic_type_params: function now requires a different number of generic type parameters --- Description: A function now requires a different number of generic type parameters than it used to. Uses of this function that supplied the previous number of generic types will be broken. ref: https://doc.rust-lang.org/reference/items/generics.html impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/function_requires_different_generic_type_params.ron Failed in: function ensure_no_nonlocal_edges (0 -> 1 generic types) in /tmp/.tmpgXR84S/hugr/hugr-passes/src/non_local.rs:32 function ensure_no_nonlocal_edges (0 -> 1 generic types) in /tmp/.tmpgXR84S/hugr/hugr-passes/src/non_local.rs:32 function nonlocal_edges (0 -> 1 generic types) in /tmp/.tmpgXR84S/hugr/hugr-passes/src/non_local.rs:14 function nonlocal_edges (0 -> 1 generic types) in /tmp/.tmpgXR84S/hugr/hugr-passes/src/non_local.rs:14 function partial_from_const (1 -> 2 generic types) in /tmp/.tmpgXR84S/hugr/hugr-passes/src/dataflow.rs:93 --- failure inherent_method_missing: pub method removed or renamed --- Description: A publicly-visible method or associated fn is no longer available under its prior name. It may have been renamed or removed entirely. ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/inherent_method_missing.ron Failed in: Machine::prepopulate_df_inputs, previously in file /tmp/.tmpuOV2md/hugr-passes/src/dataflow/datalog.rs:51 --- failure method_parameter_count_changed: pub method parameter count changed --- Description: A publicly-visible method now takes a different number of parameters. ref: https://doc.rust-lang.org/cargo/reference/semver.html#fn-change-arity impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/method_parameter_count_changed.ron Failed in: hugr_passes::const_fold::ConstantFoldPass::with_inputs now takes 3 parameters instead of 2, in /tmp/.tmpgXR84S/hugr/hugr-passes/src/const_fold.rs:82 --- failure trait_associated_type_added: non-sealed public trait added associated type without default value --- Description: A non-sealed trait has gained an associated type without a default value, which breaks downstream implementations of the trait ref: https://doc.rust-lang.org/cargo/reference/semver.html#trait-new-item-no-default impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/trait_associated_type_added.ron Failed in: trait associated type hugr_passes::dataflow::ConstLoader::Node in file /tmp/.tmpgXR84S/hugr/hugr-passes/src/dataflow.rs:63 --- failure trait_requires_more_generic_type_params: trait now requires more generic type parameters --- Description: A trait now requires more generic type parameters than it used to. Uses of this trait that supplied the previously-required number of generic types will be broken. To fix this, consider supplying default values for newly-added generic types. ref: https://doc.rust-lang.org/cargo/reference/semver.html#trait-new-parameter-no-default impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/trait_requires_more_generic_type_params.ron Failed in: trait NonLocalEdgesError (0 -> 1 required generic types) in /tmp/.tmpgXR84S/hugr/hugr-passes/src/non_local.rs:26 trait ConstLocation (0 -> 1 required generic types) in /tmp/.tmpgXR84S/hugr/hugr-passes/src/dataflow.rs:44 --- failure type_requires_more_generic_type_params: type now requires more generic type parameters --- Description: A type now requires more generic type parameters than it used to. Uses of this type that supplied the previously-required number of generic types will be broken. To fix this, consider supplying default values for newly-added generic types. ref: https://doc.rust-lang.org/cargo/reference/semver.html#trait-new-parameter-no-default impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/type_requires_more_generic_type_params.ron Failed in: Enum NonLocalEdgesError (0 -> 1 required generic types) in /tmp/.tmpgXR84S/hugr/hugr-passes/src/non_local.rs:26 Enum ConstLocation (0 -> 1 required generic types) in /tmp/.tmpgXR84S/hugr/hugr-passes/src/dataflow.rs:44 ``` ### ⚠ `hugr-cli` breaking changes ```text --- failure enum_variant_missing: pub enum variant removed or renamed --- Description: A publicly-visible enum has at least one variant that is no longer available under its prior name. It may have been renamed or removed entirely. ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/enum_variant_missing.ron Failed in: variant CliError::HUGRLoad, previously in file /tmp/.tmpuOV2md/hugr-cli/src/lib.rs:49 --- failure struct_pub_field_missing: pub struct's pub field removed or renamed --- Description: A publicly-visible struct has at least one public field that is no longer available under its prior name. It may have been renamed or removed entirely. ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/struct_pub_field_missing.ron Failed in: field hugr_args of struct ValArgs, previously in file /tmp/.tmpuOV2md/hugr-cli/src/validate.rs:18 field hugr_args of struct MermaidArgs, previously in file /tmp/.tmpuOV2md/hugr-cli/src/mermaid.rs:17 --- warning enum_missing: pub enum removed or renamed --- Description: A publicly-visible enum cannot be imported by its prior path. A `pub use` may have been removed, or the enum itself may have been renamed or removed entirely. ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/enum_missing.ron Failed in: enum hugr_cli::PackageOrHugr, previously in file /tmp/.tmpuOV2md/hugr-cli/src/lib.rs:83 --- warning struct_missing: pub struct removed or renamed --- Description: A publicly-visible struct cannot be imported by its prior path. A `pub use` may have been removed, or the struct itself may have been renamed or removed entirely. ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/struct_missing.ron Failed in: struct hugr_cli::HugrArgs, previously in file /tmp/.tmpuOV2md/hugr-cli/src/lib.rs:57 ``` <details><summary><i><b>Changelog</b></i></summary><p> ## `hugr-model` <blockquote> ## [0.18.0](hugr-model-v0.17.1...hugr-model-v0.18.0) - 2025-03-14 ### Bug Fixes - Hugr-model using undeclared derive_more features ([#1940](#1940)) ### New Features - *(hugr-model)* [**breaking**] Add `read_from_reader` and `write_to_writer` for streaming reads and writes. ([#1871](#1871)) - `hugr-model` AST ([#1953](#1953)) ### Refactor - *(hugr-model)* Reexport `bumpalo` from `hugr-model` ([#1870](#1870)) </blockquote> ## `hugr-core` <blockquote> ## [0.15.0](hugr-core-v0.14.4...hugr-core-v0.15.0) - 2025-03-14 ### New Features - [**breaking**] Add associated type Node to HugrView ([#1932](#1932)) - Rewrite for inlining a single Call ([#1934](#1934)) - [**breaking**] replace `Lift` with `Barrier` ([#1952](#1952)) - `hugr-model` AST ([#1953](#1953)) - Add float <--> int bytecasting ops to conversions extension ([#1956](#1956)) - Add collections.static_array extension. ([#1964](#1964)) - [**breaking**] Generic HUGR serialization with envelopes ([#1958](#1958)) ### Refactor - [**breaking**] remove unused dependencies ([#1935](#1935)) - *(hugr-model)* Reexport `bumpalo` from `hugr-model` ([#1870](#1870)) </blockquote> ## `hugr-llvm` <blockquote> ## [0.15.0](hugr-llvm-v0.14.4...hugr-llvm-v0.15.0) - 2025-03-14 ### Bug Fixes - Rename widen insta tests ([#1949](#1949)) ### New Features - [**breaking**] Add associated type Node to HugrView ([#1932](#1932)) - Emit `widen` ops from the int ops extension ([#1946](#1946)) - [**breaking**] replace `Lift` with `Barrier` ([#1952](#1952)) - *(hugr-llvm)* Emit narrow ops ([#1955](#1955)) - Add float <--> int bytecasting ops to conversions extension ([#1956](#1956)) - *(hugr-llvm)* Emit iu_to_s and is_to_u ([#1978](#1978)) ### Refactor - [**breaking**] remove unused dependencies ([#1935](#1935)) </blockquote> ## `hugr-passes` <blockquote> ## [0.15.0](hugr-passes-v0.14.4...hugr-passes-v0.15.0) - 2025-03-14 ### New Features - [**breaking**] Add associated type Node to HugrView ([#1932](#1932)) - add separate DCE pass ([#1902](#1902)) - [**breaking**] replace `Lift` with `Barrier` ([#1952](#1952)) - [**breaking**] don't assume "main"-function in dataflow + constant folding ([#1896](#1896)) </blockquote> ## `hugr` <blockquote> ## [0.15.0](hugr-v0.14.4...hugr-v0.15.0) - 2025-03-14 ### New Features - add separate DCE pass ([#1902](#1902)) - [**breaking**] don't assume "main"-function in dataflow + constant folding ([#1896](#1896)) - [**breaking**] Add associated type Node to HugrView ([#1932](#1932)) - Rewrite for inlining a single Call ([#1934](#1934)) - [**breaking**] replace `Lift` with `Barrier` ([#1952](#1952)) - `hugr-model` AST ([#1953](#1953)) - Add float <--> int bytecasting ops to conversions extension ([#1956](#1956)) - Add collections.static_array extension. ([#1964](#1964)) - [**breaking**] Generic HUGR serialization with envelopes ([#1958](#1958)) ### Refactor - *(hugr-model)* Reexport `bumpalo` from `hugr-model` ([#1870](#1870)) - [**breaking**] remove unused dependencies ([#1935](#1935)) </blockquote> ## `hugr-cli` <blockquote> ## [0.15.0](hugr-cli-v0.14.4...hugr-cli-v0.15.0) - 2025-03-14 ### New Features - [**breaking**] Generic HUGR serialization with envelopes ([#1958](#1958)) </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/release-plz/release-plz/). --------- Co-authored-by: Agustín Borgna <[email protected]>
Including adding a new method for copying descendants of another node (preserving edges incoming to that subtree), with optional Substitution.
The choice of copying descendants rather than a subtree and its root may seem a little strange. The minor difference is that in most usecases (others are peeling tail loops, and monomorphization which can be refactored to use this too) we're gonna update the root node optype too, so we might as well just make the new optype first rather than copy+overwrite. The bigger differences are
closes #1833, #1886