-
Notifications
You must be signed in to change notification settings - Fork 13
feat!: Hugrmut on generic nodes #2111
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
Conversation
|
This PR contains breaking changes to the public Rust API. cargo-semver-checks summary |
- Allows `HugrMut` to be implemented for `HugrView`s with arbitrary node types - Removes `HugrMutInternals::hugr_mut(&mut self) -> &mut Hugr`, it can be implemented for more complex types drive-by: Fix a couple bugs in rewrite implementations that assumed that `SiblingMut` contained transitive children.
8bf5f99 to
2c2745e
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## release-rs-v0.16.0 #2111 +/- ##
======================================================
+ Coverage 83.33% 83.46% +0.12%
======================================================
Files 219 218 -1
Lines 42205 42053 -152
Branches 38307 38258 -49
======================================================
- Hits 35173 35098 -75
+ Misses 5221 5147 -74
+ Partials 1811 1808 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
hugr-core/src/hugr/hugrmut.rs
Outdated
| "Received an invalid node {node} while mutating a HUGR:\n\n {}", | ||
| hugr.mermaid_string() | ||
| ); | ||
| if cfg!(debug_assertions) && !hugr.valid_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.
Hmm strictly speaking the docs promise that operations panic if nodes are invalid. Do we need to specify that this is only true in debug builds?
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.
The main issue is that now that we don't have the hugr_mut shortcut, stacked hugr wrappers will end up running the check at each and every layer.
Maybe we should leave them enabled and benchmark the performance impact later.
| /// # Errors | ||
| /// | ||
| /// Returns a [`HugrError::InvalidTag`] if this would break the bound | ||
| /// (`Self::RootHandle`) on the root node's OpTag. |
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 all impls still do this check. Should the error still be documented?
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. The error is being dropped in the next PR but this got filtered into this one
| /// | ||
| /// Returns the old OpType. | ||
| /// | ||
| /// TODO: Add a version which ignores input extensions |
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.
Is this TODO no longer relevant?
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.
Nop, we don't check the replaced signature
6066389 to
c70d989
Compare
- Allows `HugrMut` to be implemented for `HugrView`s with arbitrary node types - Removes `HugrMutInternals::hugr_mut(&mut self) -> &mut Hugr`, it can be implemented for more complex types. This is required for #1926, but I haven't touched the read-only side yet. - Added a `Node` associated type to `Rewrite`. All existing rewrites only implement `Rewrite<Node = Node>` for now, expanding their type is left for a separate PR. drive-by: Fix a couple bugs in rewrite implementations that assumed that `SiblingMut` contained transitive children. BREAKING CHANGE: `HugrMut` is now implemented generically for any `HugrView::Node` type. BREAKING CHANGE: `SiblingMut` has a new type parameter for the wrapped hugr type.
HugrMutto be implemented forHugrViews with arbitrary node typesHugrMutInternals::hugr_mut(&mut self) -> &mut Hugr, it can be implemented for more complex types. This is required for ReplaceHugrInternals::base_hugrwith simpler methods #1926, but I haven't touched the read-only side yet.Nodeassociated type toRewrite. All existing rewrites only implementRewrite<Node = Node>for now, expanding their type is left for a separate PR.drive-by: Fix a couple bugs in rewrite implementations that assumed that
SiblingMutcontained transitive children.BREAKING CHANGE:
HugrMutis now implemented generically for anyHugrView::Nodetype.BREAKING CHANGE:
SiblingMuthas a new type parameter for the wrapped hugr type.