Skip to content

Commit 6017450

Browse files
aborgna-qlmondadazrhoss2165
authored
feat!: Update to hugr 0.21 (#965)
BREAKING CHANGE: Public `hugr` dependency updated to `0.21.0`. --------- Co-authored-by: Luca Mondada <luca@mondada.net> Co-authored-by: Lukas Heidemann <lukas@heidemann.me> Co-authored-by: Seyon Sivarajah <seyon.sivarajah@quantinuum.com>
1 parent 32356d9 commit 6017450

File tree

25 files changed

+217
-255
lines changed

25 files changed

+217
-255
lines changed

Cargo.lock

Lines changed: 39 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,18 @@ large_enum_variant = "allow"
3838
[patch.crates-io]
3939

4040
# Uncomment to use unreleased versions of hugr
41-
# hugr = { git = "https://github.com/CQCL/hugr", branch = "ss/push-xvxtzqlwkvux" }
42-
# hugr-core = { git = "https://github.com/CQCL/hugr", branch = "ss/push-xvxtzqlwkvux" }
43-
# hugr-passes = { git = "https://github.com/CQCL/hugr", branch = "ss/push-xvxtzqlwkvux" }
44-
# hugr-cli = { git = "https://github.com/CQCL/hugr", branch = "ss/push-xvxtzqlwkvux" }
45-
46-
41+
#hugr = { git = "https://github.com/CQCL/hugr", "rev" = "34eed3422c9aa34bd6b8ad868dcbab733eb5d14c" }
42+
#hugr-core = { git = "https://github.com/CQCL/hugr", "rev" = "34eed3422c9aa34bd6b8ad868dcbab733eb5d14c" }
43+
#hugr-passes = { git = "https://github.com/CQCL/hugr", "rev" = "34eed3422c9aa34bd6b8ad868dcbab733eb5d14c" }
44+
#hugr-cli = { git = "https://github.com/CQCL/hugr", "rev" = "34eed3422c9aa34bd6b8ad868dcbab733eb5d14c" }
4745
# portgraph = { git = "https://github.com/CQCL/portgraph", rev = "68b96ac737e0c285d8c543b2d74a7aa80a18202c" }
46+
4847
[workspace.dependencies]
4948

5049
# Make sure to run `just recompile-eccs` if the hugr serialisation format changes.
51-
hugr = "0.20.2"
52-
hugr-core = "0.20.2"
53-
hugr-cli = "0.20.2"
50+
hugr = "0.21.0"
51+
hugr-core = "0.21.0"
52+
hugr-cli = "0.21.0"
5453
portgraph = "0.14.1"
5554
pyo3 = ">= 0.23.4, < 0.26"
5655
itertools = "0.14.0"

tket2-exts/src/tket2_exts/data/tket2/wasm.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.1.0",
2+
"version": "0.2.0",
33
"name": "tket2.wasm",
44
"types": {
55
"context": {
@@ -85,7 +85,7 @@
8585
"id": "func",
8686
"args": [
8787
{
88-
"tya": "Sequence",
88+
"tya": "List",
8989
"elems": [
9090
{
9191
"tya": "Variable",
@@ -101,7 +101,7 @@
101101
]
102102
},
103103
{
104-
"tya": "Sequence",
104+
"tya": "List",
105105
"elems": [
106106
{
107107
"tya": "Variable",
@@ -258,7 +258,7 @@
258258
"id": "func",
259259
"args": [
260260
{
261-
"tya": "Sequence",
261+
"tya": "List",
262262
"elems": [
263263
{
264264
"tya": "Variable",
@@ -274,7 +274,7 @@
274274
]
275275
},
276276
{
277-
"tya": "Sequence",
277+
"tya": "List",
278278
"elems": [
279279
{
280280
"tya": "Variable",

tket2-hseries/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ categories = ["compilers"]
1515

1616
[features]
1717
default = ["cli"]
18-
cli = ["dep:clap", "dep:hugr-cli"]
18+
cli = ["dep:clap", "dep:hugr-cli", "dep:anyhow"]
1919
llvm = ["tket2/llvm", "dep:anyhow"]
2020

2121
[[bin]]

tket2-hseries/src/bin/tket2-hseries.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
//! CLI for tket2-hseries
22
3+
use anyhow::Result;
34
use clap::Parser as _;
45
use hugr::extension::ExtensionRegistry;
56
use tket2_hseries::cli::CliArgs;
67

7-
fn main() {
8+
fn main() -> Result<()> {
89
match CliArgs::parse() {
910
CliArgs::GenExtensions(args) => {
1011
let reg = ExtensionRegistry::new([
@@ -20,11 +21,13 @@ fn main() {
2021
tket2_hseries::extension::wasm::EXTENSION.to_owned(),
2122
]);
2223

23-
args.run_dump(&reg);
24+
args.run_dump(&reg)?;
2425
}
2526
_ => {
2627
eprintln!("Unknown command");
2728
std::process::exit(1);
2829
}
2930
};
31+
32+
Ok(())
3033
}

tket2-hseries/src/extension/futures.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ fn add_future_type_def(
4848
) -> Result<&TypeDef, ExtensionBuildError> {
4949
ext.add_type(
5050
FUTURE_TYPE_NAME.to_owned(),
51-
vec![TypeBound::Any.into()],
51+
vec![TypeBound::Linear.into()],
5252
"A value that is computed asynchronously".into(),
53-
TypeBound::Any.into(),
53+
TypeBound::Linear.into(),
5454
&extension_ref,
5555
)
5656
}
@@ -61,7 +61,7 @@ pub fn future_custom_type(t: Type, extension_ref: &Weak<Extension>) -> CustomTyp
6161
FUTURE_TYPE_NAME.to_owned(),
6262
vec![t.into()],
6363
EXTENSION_ID,
64-
TypeBound::Any,
64+
TypeBound::Linear,
6565
extension_ref,
6666
)
6767
}
@@ -101,8 +101,8 @@ impl MakeOpDef for FutureOpDef {
101101
}
102102

103103
fn init_signature(&self, extension_ref: &Weak<Extension>) -> SignatureFunc {
104-
let t_param = TypeParam::from(TypeBound::Any);
105-
let t_type = Type::new_var_use(0, TypeBound::Any);
104+
let t_param = TypeParam::from(TypeBound::Linear);
105+
let t_type = Type::new_var_use(0, TypeBound::Linear);
106106
let future_type = Type::new_extension(future_custom_type(t_type.clone(), extension_ref));
107107
match self {
108108
FutureOpDef::Read => {
@@ -148,7 +148,7 @@ impl HasConcrete for FutureOpDef {
148148

149149
fn instantiate(&self, type_args: &[TypeArg]) -> Result<Self::Concrete, OpLoadError> {
150150
match type_args {
151-
[TypeArg::Type { ty }] => Ok(FutureOp {
151+
[TypeArg::Runtime(ty)] => Ok(FutureOp {
152152
op: *self,
153153
typ: ty.clone(),
154154
}),
@@ -298,8 +298,8 @@ pub(crate) mod test {
298298

299299
#[test]
300300
fn circuit() {
301-
let t_param = TypeParam::from(TypeBound::Any);
302-
let t = Type::new_var_use(0, TypeBound::Any);
301+
let t_param = TypeParam::from(TypeBound::Linear);
302+
let t = Type::new_var_use(0, TypeBound::Linear);
303303
let future_type = future_type(t.clone());
304304

305305
let hugr = {

tket2-hseries/src/extension/qsystem.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,9 @@ impl MakeOpDef for RuntimeBarrierDef {
205205

206206
fn init_signature(&self, _extension_ref: &Weak<Extension>) -> SignatureFunc {
207207
PolyFuncType::new(
208-
[TypeParam::max_nat()],
208+
[TypeParam::max_nat_type()],
209209
Signature::new_endo(
210-
array_type_parametric(TypeArg::new_var_use(0, TypeParam::max_nat()), qb_t())
210+
array_type_parametric(TypeArg::new_var_use(0, TypeParam::max_nat_type()), qb_t())
211211
.unwrap(),
212212
),
213213
)
@@ -534,7 +534,7 @@ pub(crate) fn runtime_barrier_ext_op(
534534
) -> Result<ExtensionOp, hugr::extension::SignatureError> {
535535
ExtensionOp::new(
536536
EXTENSION.get_op(&RUNTIME_BARRIER_NAME).unwrap().clone(),
537-
[TypeArg::BoundedNat { n: array_size }],
537+
[TypeArg::BoundedNat(array_size)],
538538
)
539539
}
540540

0 commit comments

Comments
 (0)