Skip to content

Commit 8ef4afb

Browse files
authored
feat!: Removed model_unstable feature flag. (#2113)
This PR removes the `model_unstable` feature flag across the repository. Closes #2104. BREAKING CHANGE: Downstream crates need to remove the `model_unstable` feature flag when referencing `hugr` or `hugr-core`.
1 parent c8090ca commit 8ef4afb

File tree

11 files changed

+42
-93
lines changed

11 files changed

+42
-93
lines changed

.github/workflows/ci-rs.yml

+21-22
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- main
77
pull_request:
88
branches:
9-
- '**'
9+
- "**"
1010
merge_group:
1111
types: [checks_requested]
1212
workflow_dispatch: {}
@@ -25,7 +25,6 @@ env:
2525
LLVM_VERSION: "14.0"
2626
LLVM_FEATURE_NAME: "14-0"
2727

28-
2928
jobs:
3029
# Check if changes were made to the relevant files.
3130
# Always returns true if running on the default branch, to ensure all changes are thoroughly checked.
@@ -43,25 +42,25 @@ jobs:
4342
model: ${{ steps.filter.outputs.model == 'true' || steps.override.outputs.out == 'true' }}
4443
llvm: ${{ steps.filter.outputs.llvm == 'true' || steps.override.outputs.out == 'true' }}
4544
steps:
46-
- uses: actions/checkout@v4
47-
- name: Override label
48-
id: override
49-
run: |
50-
echo "Label contains run-ci-checks: $OVERRIDE_LABEL"
51-
if [ "$OVERRIDE_LABEL" == "true" ]; then
52-
echo "Overriding due to label 'run-ci-checks'"
53-
echo "out=true" >> $GITHUB_OUTPUT
54-
elif [ "$DEFAULT_BRANCH" == "true" ]; then
55-
echo "Overriding due to running on the default branch"
56-
echo "out=true" >> $GITHUB_OUTPUT
57-
fi
58-
env:
59-
OVERRIDE_LABEL: ${{ github.event_name == 'pull_request' && contains( github.event.pull_request.labels.*.name, 'run-ci-checks') }}
60-
DEFAULT_BRANCH: ${{ github.ref_name == github.event.repository.default_branch }}
61-
- uses: dorny/paths-filter@v3
62-
id: filter
63-
with:
64-
filters: .github/change-filters.yml
45+
- uses: actions/checkout@v4
46+
- name: Override label
47+
id: override
48+
run: |
49+
echo "Label contains run-ci-checks: $OVERRIDE_LABEL"
50+
if [ "$OVERRIDE_LABEL" == "true" ]; then
51+
echo "Overriding due to label 'run-ci-checks'"
52+
echo "out=true" >> $GITHUB_OUTPUT
53+
elif [ "$DEFAULT_BRANCH" == "true" ]; then
54+
echo "Overriding due to running on the default branch"
55+
echo "out=true" >> $GITHUB_OUTPUT
56+
fi
57+
env:
58+
OVERRIDE_LABEL: ${{ github.event_name == 'pull_request' && contains( github.event.pull_request.labels.*.name, 'run-ci-checks') }}
59+
DEFAULT_BRANCH: ${{ github.ref_name == github.event.repository.default_branch }}
60+
- uses: dorny/paths-filter@v3
61+
id: filter
62+
with:
63+
filters: .github/change-filters.yml
6564

6665
check:
6766
needs: changes
@@ -109,7 +108,7 @@ jobs:
109108
- name: Override criterion with the CodSpeed harness
110109
run: cargo add --dev codspeed-criterion-compat --rename criterion --package hugr
111110
- name: Build benchmarks
112-
run: cargo codspeed build --profile bench --features extension_inference,declarative,model_unstable,llvm,llvm-test
111+
run: cargo codspeed build --profile bench --features extension_inference,declarative,llvm,llvm-test
113112
- name: Run benchmarks
114113
uses: CodSpeedHQ/action@v3
115114
with:

hugr-core/Cargo.toml

+1-3
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,16 @@ workspace = true
1919
[features]
2020
extension_inference = []
2121
declarative = ["serde_yaml"]
22-
model_unstable = ["hugr-model"]
2322
zstd = ["dep:zstd"]
2423

2524
[lib]
2625
bench = false
2726

2827
[[test]]
2928
name = "model"
30-
required-features = ["model_unstable"]
3129

3230
[dependencies]
33-
hugr-model = { version = "0.19.0", path = "../hugr-model", optional = true }
31+
hugr-model = { version = "0.19.0", path = "../hugr-model" }
3432

3533
cgmath = { workspace = true, features = ["serde"] }
3634
delegate = { workspace = true }

hugr-core/README.md

+8-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
![](/hugr/assets/hugr_logo.svg)
22

3-
hugr-core
4-
===============
3+
# hugr-core
54

65
[![build_status][]](https://github.com/CQCL/hugr/actions)
76
[![crates][]](https://crates.io/crates/hugr-core)
@@ -21,9 +20,6 @@ Please read the [API documentation here][].
2120
Not enabled by default.
2221
- `declarative`:
2322
Experimental support for declaring extensions in YAML files, support is limited.
24-
- `model_unstable`
25-
Import and export from the representation defined in the `hugr-model` crate.
26-
Unstable and subject to change. Not enabled by default.
2723

2824
## Recent Changes
2925

@@ -38,10 +34,10 @@ See [DEVELOPMENT.md](https://github.com/CQCL/hugr/blob/main/DEVELOPMENT.md) for
3834

3935
This project is licensed under Apache License, Version 2.0 ([LICENSE][] or http://www.apache.org/licenses/LICENSE-2.0).
4036

41-
[API documentation here]: https://docs.rs/hugr-core/
42-
[build_status]: https://github.com/CQCL/hugr/actions/workflows/ci-rs.yml/badge.svg?branch=main
43-
[msrv]: https://img.shields.io/badge/rust-1.75.0%2B-blue.svg
44-
[crates]: https://img.shields.io/crates/v/hugr-core
45-
[codecov]: https://img.shields.io/codecov/c/gh/CQCL/hugr?logo=codecov
46-
[LICENSE]: https://github.com/CQCL/hugr/blob/main/LICENCE
47-
[CHANGELOG]: https://github.com/CQCL/hugr/blob/main/hugr-core/CHANGELOG.md
37+
[API documentation here]: https://docs.rs/hugr-core/
38+
[build_status]: https://github.com/CQCL/hugr/actions/workflows/ci-rs.yml/badge.svg?branch=main
39+
[msrv]: https://img.shields.io/badge/rust-1.75.0%2B-blue.svg
40+
[crates]: https://img.shields.io/crates/v/hugr-core
41+
[codecov]: https://img.shields.io/codecov/c/gh/CQCL/hugr?logo=codecov
42+
[LICENSE]: https://github.com/CQCL/hugr/blob/main/LICENCE
43+
[CHANGELOG]: https://github.com/CQCL/hugr/blob/main/hugr-core/CHANGELOG.md

hugr-core/src/envelope.rs

+1-32
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ use std::io::Write;
5555
#[allow(unused_imports)]
5656
use itertools::Itertools as _;
5757

58-
#[cfg(feature = "model_unstable")]
5958
use crate::import::ImportError;
6059

6160
/// Read a HUGR envelope from a reader.
@@ -197,19 +196,16 @@ pub enum EnvelopeError {
197196
source: PackageEncodingError,
198197
},
199198
/// Error importing a HUGR from a hugr-model payload.
200-
#[cfg(feature = "model_unstable")]
201199
ModelImport {
202200
/// The source error.
203201
source: ImportError,
204202
},
205203
/// Error reading a HUGR model payload.
206-
#[cfg(feature = "model_unstable")]
207204
ModelRead {
208205
/// The source error.
209206
source: hugr_model::v0::binary::ReadError,
210207
},
211208
/// Error writing a HUGR model payload.
212-
#[cfg(feature = "model_unstable")]
213209
ModelWrite {
214210
/// The source error.
215211
source: hugr_model::v0::binary::WriteError,
@@ -225,17 +221,9 @@ fn read_impl(
225221
match header.format {
226222
#[allow(deprecated)]
227223
EnvelopeFormat::PackageJson => Ok(Package::from_json_reader(payload, registry)?),
228-
#[cfg(feature = "model_unstable")]
229224
EnvelopeFormat::Model | EnvelopeFormat::ModelWithExtensions => {
230225
decode_model(payload, registry, header.format)
231226
}
232-
#[cfg(not(feature = "model_unstable"))]
233-
EnvelopeFormat::Model | EnvelopeFormat::ModelWithExtensions => {
234-
Err(EnvelopeError::FormatUnsupported {
235-
format: header.format,
236-
feature: Some("model_unstable"),
237-
})
238-
}
239227
}
240228
}
241229

@@ -246,7 +234,6 @@ fn read_impl(
246234
/// - `extension_registry`: An extension registry with additional extensions to use when
247235
/// decoding the HUGR, if they are not already included in the package.
248236
/// - `format`: The format of the payload.
249-
#[cfg(feature = "model_unstable")]
250237
fn decode_model(
251238
mut stream: impl BufRead,
252239
extension_registry: &ExtensionRegistry,
@@ -286,22 +273,13 @@ fn write_impl(
286273
match config.format {
287274
#[allow(deprecated)]
288275
EnvelopeFormat::PackageJson => package.to_json_writer(writer)?,
289-
#[cfg(feature = "model_unstable")]
290276
EnvelopeFormat::Model | EnvelopeFormat::ModelWithExtensions => {
291277
encode_model(writer, package, config.format)?
292278
}
293-
#[cfg(not(feature = "model_unstable"))]
294-
EnvelopeFormat::Model | EnvelopeFormat::ModelWithExtensions => {
295-
return Err(EnvelopeError::FormatUnsupported {
296-
format: config.format,
297-
feature: Some("model_unstable"),
298-
})
299-
}
300279
}
301280
Ok(())
302281
}
303282

304-
#[cfg(feature = "model_unstable")]
305283
fn encode_model(
306284
mut writer: impl Write,
307285
package: &Package,
@@ -391,7 +369,6 @@ mod tests {
391369
//#[case::empty(Package::default())] // Not currently supported
392370
#[case::simple(simple_package())]
393371
//#[case::multi(multi_module_package())] // Not currently supported
394-
#[cfg(feature = "model_unstable")]
395372
fn module_exts_roundtrip(#[case] package: Package) {
396373
let mut buffer = Vec::new();
397374
let config = EnvelopeConfig {
@@ -417,15 +394,7 @@ mod tests {
417394
format: EnvelopeFormat::Model,
418395
zstd: None,
419396
};
420-
let res = package.store(&mut buffer, config);
421-
422-
match cfg!(feature = "model_unstable") {
423-
true => res.unwrap(),
424-
false => {
425-
assert_matches!(res, Err(EnvelopeError::FormatUnsupported { .. }));
426-
return;
427-
}
428-
}
397+
package.store(&mut buffer, config).unwrap();
429398

430399
let (decoded_config, new_package) =
431400
read_envelope(BufReader::new(buffer.as_slice()), &PRELUDE_REGISTRY).unwrap();

hugr-core/src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212
pub mod builder;
1313
pub mod core;
1414
pub mod envelope;
15-
#[cfg(feature = "model_unstable")]
1615
pub mod export;
1716
pub mod extension;
1817
pub mod hugr;
19-
#[cfg(feature = "model_unstable")]
2018
pub mod import;
2119
pub mod macros;
2220
pub mod ops;

hugr-core/src/std_extensions/arithmetic/float_types.rs

-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ impl std::ops::Deref for ConstF64 {
6565

6666
impl ConstF64 {
6767
/// Name of the constructor for creating constant 64bit floats.
68-
#[cfg_attr(not(feature = "model_unstable"), allow(dead_code))]
6968
pub(crate) const CTR_NAME: &'static str = "arithmetic.float.const_f64";
7069

7170
/// Create a new [`ConstF64`]

hugr-core/src/std_extensions/arithmetic/int_types.rs

-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ pub struct ConstInt {
105105

106106
impl ConstInt {
107107
/// Name of the constructor for creating constant integers.
108-
#[cfg_attr(not(feature = "model_unstable"), allow(dead_code))]
109108
pub(crate) const CTR_NAME: &'static str = "arithmetic.int.const";
110109

111110
/// Create a new [`ConstInt`] with a given width and unsigned value

hugr-core/src/std_extensions/collections/array.rs

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ pub struct ArrayValue {
4545

4646
impl ArrayValue {
4747
/// Name of the constructor for creating constant arrays.
48-
#[cfg_attr(not(feature = "model_unstable"), allow(dead_code))]
4948
pub(crate) const CTR_NAME: &'static str = "collections.array.const";
5049

5150
/// Create a new [CustomConst] for an array of values of type `typ`.

hugr/Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@ default = ["zstd"]
2626

2727
extension_inference = ["hugr-core/extension_inference"]
2828
declarative = ["hugr-core/declarative"]
29-
model_unstable = ["hugr-core/model_unstable", "hugr-model"]
3029
llvm = ["hugr-llvm/llvm14-0"]
3130
llvm-test = ["hugr-llvm/llvm14-0", "hugr-llvm/test-utils"]
3231
zstd = ["hugr-core/zstd"]
3332

3433
[dependencies]
35-
hugr-model = { path = "../hugr-model", optional = true, version = "0.19.0" }
34+
hugr-model = { path = "../hugr-model", version = "0.19.0" }
3635
hugr-core = { path = "../hugr-core", version = "0.15.3" }
3736
hugr-passes = { path = "../hugr-passes", version = "0.15.3" }
3837
hugr-llvm = { path = "../hugr-llvm", version = "0.15.3", optional = true }

hugr/benches/benchmarks/hugr.rs

+9-14
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ impl Serializer for JsonSer {
2424
}
2525
}
2626

27-
#[cfg(feature = "model_unstable")]
2827
struct CapnpSer;
2928

30-
#[cfg(feature = "model_unstable")]
3129
impl Serializer for CapnpSer {
3230
fn serialize(&self, hugr: &Hugr) -> Vec<u8> {
3331
let bump = bumpalo::Bump::new();
@@ -90,20 +88,17 @@ fn bench_serialization(c: &mut Criterion) {
9088
}
9189
group.finish();
9290

93-
#[cfg(feature = "model_unstable")]
94-
{
95-
let mut group = c.benchmark_group("circuit_roundtrip/capnp");
96-
group.plot_config(PlotConfiguration::default().summary_scale(AxisScale::Logarithmic));
97-
for size in [0, 1, 10, 100, 1000].iter() {
98-
group.bench_with_input(BenchmarkId::from_parameter(size), size, |b, &size| {
99-
let h = circuit(size).0;
100-
b.iter(|| {
101-
black_box(roundtrip(&h, CapnpSer));
102-
});
91+
let mut group = c.benchmark_group("circuit_roundtrip/capnp");
92+
group.plot_config(PlotConfiguration::default().summary_scale(AxisScale::Logarithmic));
93+
for size in [0, 1, 10, 100, 1000].iter() {
94+
group.bench_with_input(BenchmarkId::from_parameter(size), size, |b, &size| {
95+
let h = circuit(size).0;
96+
b.iter(|| {
97+
black_box(roundtrip(&h, CapnpSer));
10398
});
104-
}
105-
group.finish();
99+
});
106100
}
101+
group.finish();
107102
}
108103

109104
criterion_group! {

release-plz.toml

+1-3
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ version_group = "hugr"
6363
[[package]]
6464
name = "hugr-model"
6565
release = true
66-
# Use a separate version group while the dependency is `-unstable`,
67-
# to avoid breaking releases of the main package.
68-
version_group = "hugr-model"
66+
version_group = "hugr"
6967

7068
[[package]]
7169
name = "hugr-llvm"

0 commit comments

Comments
 (0)