Skip to content
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

fix!: ops::Module now empty struct rather than unit struct #1271

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions hugr-core/src/hugr/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ struct NodeSer {
parent: Node,
#[serde(flatten)]
op: OpType,

#[serde(skip_serializing, default)]
input_extensions: Option<crate::extension::ExtensionSet>,
}

/// Version 1 of the HUGR serialization format.
Expand Down Expand Up @@ -149,7 +146,6 @@ impl TryFrom<&Hugr> for SerHugrV1 {
nodes[new_node] = Some(NodeSer {
parent,
op: opt.clone(),
input_extensions: None,
});
metadata[new_node].clone_from(hugr.metadata.get(n.pg_index()));
}
Expand Down
7 changes: 1 addition & 6 deletions hugr-core/src/hugr/serialize/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,6 @@ fn roundtrip_optype(#[case] optype: impl Into<OpType> + std::fmt::Debug) {
check_testing_roundtrip(NodeSer {
parent: portgraph::NodeIndex::new(0).into(),
op: optype.into(),
input_extensions: None,
});
}

Expand Down Expand Up @@ -495,11 +494,7 @@ mod proptest {
(0..i32::MAX as usize).prop_map(|x| portgraph::NodeIndex::new(x).into()),
any::<OpType>(),
)
.prop_map(|(parent, op)| NodeSer {
parent,
op,
input_extensions: None,
})
.prop_map(|(parent, op)| NodeSer { parent, op })
.boxed()
}
}
Expand Down
8 changes: 6 additions & 2 deletions hugr-core/src/ops/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ use super::{impl_op_name, OpTag, OpTrait};
/// The root of a module, parent of all other `OpType`s.
#[derive(Debug, Clone, PartialEq, Eq, Default, serde::Serialize, serde::Deserialize)]
#[cfg_attr(test, derive(Arbitrary))]
pub struct Module;
pub struct Module {
// can't be simple unit struct due to flattened serialization issues
// see https://github.com/CQCL/hugr/issues/1270
}

impl Module {
/// Construct a new Module.
pub const fn new() -> Self {
Self
Self {}
}
}

Expand Down
Loading