Skip to content

feat!: Add Visibility to FuncDefn/FuncDecl. #2143

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

Merged
merged 94 commits into from
Jul 9, 2025
Merged

Conversation

acl-cqc
Copy link
Contributor

@acl-cqc acl-cqc commented Apr 29, 2025

Note: modified to come after #2412 as I want those Schema checks in place to check this works!
closes #2354, #1752.
Includes cherry-pick of #2343.

  • Add enum Visibility. In fact *2 (hugr-model version is not serde-able so cannot be used in hugr-core).

  • FuncDefn and FuncDecl gain this. (A good use-case for a private FuncDecl is building cyclic functions via builder define_declaration.)

    • I've not added to AliasDecl or AliasDefn - I could, it would be consistent, but we hardly use them....
  • validate checks that the public children of a Module have unique names (except multiple FuncDecls may alias).

  • FuncDefn::new defaults to private (also builder define_function / FunctionBuilder::new, and json-deserialize in both python and rust). There is a _vis taking an explicit Visibility parameter.

  • FuncDecl::new defaults to public (also builder declare_function, and json-deserialize*2). Again there is _vis.

  • hugr-model import/export + roundtrip + AST printing via new keyword pub. Note since hugr-core does not have visibility on aliases or extension operations I've defaulted these to private to avoid any change to textual output.

  • add field to hugr-py, using "string"-enum (Literal["Public", "Private"])

  • I've attempted to add hugr-model hugr-py bindings, but there are no tests of these yet.

Note all changes to hugr-passes delayed until a follow-up PR.

BREAKING CHANGE: hugr-model: Symbol has an extra field

@hugrbot
Copy link
Collaborator

hugrbot commented Apr 29, 2025

This PR contains breaking changes to the public Rust API.

cargo-semver-checks summary

--- failure constructible_struct_adds_field: externally-constructible struct adds field ---

Description:
A pub struct constructible with a struct literal has a new pub field. Existing struct literals must be updated to include the new field.
      ref: https://doc.rust-lang.org/reference/expressions/struct-expr.html
     impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.42.0/src/lints/constructible_struct_adds_field.ron

Failed in:
field Symbol.visibility in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-model/src/v0/ast/mod.rs:198
field Symbol.visibility in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-model/src/v0/table/mod.rs:307

@acl-cqc acl-cqc force-pushed the acl/linking_prelims branch from 5788e0f to f15eccb Compare April 29, 2025 16:28
Copy link

codecov bot commented Apr 29, 2025

Codecov Report

Attention: Patch coverage is 76.92308% with 66 lines in your changes missing coverage. Please review.

Project coverage is 82.01%. Comparing base (68415f4) to head (5a81bc0).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
hugr-model/src/v0/ast/python.rs 0.00% 17 Missing ⚠️
hugr-core/src/builder/module.rs 64.28% 13 Missing and 2 partials ⚠️
hugr-model/src/capnp/hugr_v0_capnp.rs 52.38% 10 Missing ⚠️
hugr-model/src/v0/binary/read.rs 70.00% 1 Missing and 8 partials ⚠️
hugr-core/src/builder/dataflow.rs 36.36% 7 Missing ⚠️
hugr-core/src/ops/module.rs 81.25% 6 Missing ⚠️
hugr-py/src/hugr/model/export.py 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2143      +/-   ##
==========================================
- Coverage   82.06%   82.01%   -0.05%     
==========================================
  Files         245      245              
  Lines       45289    45474     +185     
  Branches    41033    41210     +177     
==========================================
+ Hits        37166    37297     +131     
- Misses       6108     6172      +64     
+ Partials     2015     2005      -10     
Flag Coverage Δ
python 85.38% <84.61%> (+0.02%) ⬆️
rust 81.66% <76.55%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@acl-cqc acl-cqc requested review from zrho and doug-q April 30, 2025 09:09
@doug-q
Copy link
Collaborator

doug-q commented Apr 30, 2025

I've not reviewed the code, but the description is so good I can give initial feedback from that"

So when a FuncDefn with public == true is "lifted" to a module the public flag "turns on"? This seems a bit dangerous. Lifting functions to modules is very normal and useful. I don't see a better path though. This is a case for emitting a warning (non-module-child has link name)

  • An alternative would be to have a separate field link_name: Option<String>. Preferences? Factory/builder methods might default to using the same string for both kinds of name. However, name then has no use in the code, so might be better replaced by name/description metadata....?

This is my preference. I expect the "String" to grow in complexity over time, linking is complicated. One might want to link two hugrs together, i.e. one uses a "public" function of the other, but that function doesn't want to be actually exposed as a public symbol after conversion to llvm. There is weak linking, ODR. I expect we will want more than zero of these features.

Yes name can be moved to metadata. Or it can stay where it is because it's Very Important Metadata.

Nice to have: it would be great if we were able to be unconcerned with naming generated functions (e.g. monomorphise)

  • Or even just make name an Option - all (Module-child) functions are exported unless they are anonymous?

I think there is benefit in maintaining the distinction between "link name" and "user-written-name".

  • validate checks that the public children of a Module have unique names (also FuncDecls - i.e. don't allow exporting a FuncDefn and importing the same name)
  • Duplicate "name"s should be allowed.
  • The link names of module child FuncDefns should be unique, and distinct from link names of module child FuncDecls
  • multiple FuncDecls with the same signature should be able to share link names (the two funcdecls are aliased)
  • It should be valid for FuncDecls to not have link names. Obviously you can't codegen this yet, but I expect such HUGRs to be useful.
  • TODO: this should also incorporate AliasDefn/AliasDecl
    We don't use these, let's delete them
  • It might/probably make(s) sense to use these in all dataflow analyses that care about entry points...e.g. that would include constant folding (i.e. default to joining inputs of public functions with Top unless explicitly disabled)

Yes, once we have a definition of public dataflow analysis should use this

  • Various faffing around with factory methods and builder define_function methods

Unclear whether this would be part of 0.16.0 release but I suspect "too late for that deadline".
.

  • TODO Also for now I have bodged the hugr-model import.rs (@zrho)
  • TODO: Update hugr-py

BREAKING CHANGE: FuncDefn has an extra field, recommend using new, new_public or new_private

Perhaps we should mark FuncDefn (and everything else?) #[non_exhaustive] ?

Do you think we should change "FuncDecls must be children of module" here?

I do not think we should attempt to link Consts. One can just write a function that returns the const. Yes we need const de-duplication, but we need it without linking too.

@acl-cqc
Copy link
Contributor Author

acl-cqc commented May 1, 2025

Thanks @doug-q, great points! :)

So when a FuncDefn with public == true is "lifted" to a module the public flag "turns on"? This seems a bit dangerous. Lifting functions to modules is very normal and useful.

Yes, good point. I've made it an error to have an exported FuncDefn that isn't at the top-level.

  • An alternative would be to have a separate field link_name: Option<String>. Preferences? Factory/builder methods might default to using the same string for both kinds of name. However, name then has no use in the code, so might be better replaced by name/description metadata....?

This is my preference. I expect the "String" to grow in complexity over time, linking is complicated. One might want to link two hugrs together, i.e. one uses a "public" function of the other, but that function doesn't want to be actually exposed as a public symbol after conversion to llvm. There is weak linking, ODR. I expect we will want more than zero of these features.

Yes name can be moved to metadata. Or it can stay where it is because it's Very Important Metadata.

Yup ok, I've kept name but not enforced uniqueness, and added optional link_name, with uniqueness requirement

Nice to have: it would be great if we were able to be unconcerned with naming generated functions (e.g. monomorphise)

Right. So monomorphise now mangles link_name only, and leaves name unchanged. (Tests need updating here.)

  • multiple FuncDecls with the same signature should be able to share link names (the two funcdecls are aliased)

yup, good point, done

  • It should be valid for FuncDecls to not have link names. Obviously you can't codegen this yet, but I expect such HUGRs to be useful.

This is the one I haven't really seen the use case for. Seems to me that whereas a FuncDefn has both name and optionally link-name, a FuncDecl has only (but always) link-name. What else does a FuncDecl do except open the way for linking?

Perhaps we should mark FuncDefn (and everything else?) #[non_exhaustive] ?

Yup, done

Do you think we should change "FuncDecls must be children of module" here?

Now that every Hugr has a module root, no, I think we can insist every FuncDecl lives there.

I do not think we should attempt to link Consts. One can just write a function that returns the const. Yes we need const de-duplication, but we need it without linking too.

Removed.

@acl-cqc acl-cqc force-pushed the acl/linking_prelims branch from 7fb8962 to aaeffa6 Compare May 12, 2025 17:52
@zrho
Copy link
Contributor

zrho commented May 14, 2025

I think it is important that functions, aliases, etc. can be referred to by a name. This is not immediately clear when just concentrating on writing the in-memory data structure of the compiler, but becomes much more apparent when considering other aspects, including but not limited to linking. These other aspects have been neglected so far, which I think can be felt very acutely. Names are in particular essential for the text format. That hugr-core has this design choice in contrast to every other IR known to me I think is caused by it being designed with only the in-memory representation in mind.

How about this: the current name becomes name_hint (or title or something like that) and is "Very Important Metadata". The proposed link_name becomes name. Both are optional. There are no rules for name_hint, but when a name is given then it must follow uniqueness/scoping rules. When exporting from core to model everything gets a name; if it didn't have one already, one is created from node id and name_hint. Stuff that is marked as public for linking must have a name in core. With that we can still avoid having to deal with the apparently intractable problem of alpha renaming in core, which appears to be the motivation behind the non-functional names so far, and at the same time acknlowedge that names are useful for more than just linking.

@acl-cqc
Copy link
Contributor Author

acl-cqc commented May 16, 2025

Thanks, both. I like Lukas' suggestion (rename "Metadata" name to title or even description; and link_name to name). That name must be provided when the thing is public is what I'm aiming for here ;) but @lukas do you mean you want to allow a (ex-link_)name even when not public?

Also it seems odd for metadata that is used only by humans to be compulsory. I guess (if there is no uniqueness requirement) one can provide an empty string (which, incidentally, would be another way to declare that a function has no link-name; empty string is, after all, not a legal name).

Finally @doug-q the idea that monomorphization leaves human-name unchanged but mangles link-name is kinda annoying in that monomorphization still acts on functions that have no link-name, but then the human-name does not give any way to tell them apart. I guess one then has to inspect the type of the function, which is much more cumbersome.

@zrho
Copy link
Contributor

zrho commented May 16, 2025

Yes, there's an argument to allow for names on non-public things. This keeps names as the general mechanism to refer to symbols such as functions, but allows to internally go for a nameless representation when convenient, e.g. while rewriting. The philosophy then would be that everything has a name, but for some things we don't care what it is.

The human readable title should be optional. If hugr-core had a nicer interface for metadata already, it probably wouldn't even need to be blessed metadata.

@acl-cqc acl-cqc self-assigned this May 21, 2025
@doug-q
Copy link
Collaborator

doug-q commented May 21, 2025

Yes, there's an argument to allow for names on non-public things. This keeps names as the general mechanism to refer to symbols such as functions, but allows to internally go for a nameless representation when convenient, e.g. while rewriting. The philosophy then would be that everything has a name, but for some things we don't care what it is.

Indeed, maybe we could just assign an int as a name? We could call it node id.

Renaming name and adding another field called name is a recipe for disaster. Renaming the field is unnecessary breakage, changing it's semantics as suggested above is sabotage.

I think we are agreed that we should add an optional field, say link_name to FuncDefn and FuncDecl. We are not agreed on how that field should be named or whether we should rename the existing name field.

The detail of which Func{Defn,Decl}s are allowed and/or required to have link_names is not resolved.

My suggestion is that any Func{Defn,Decl} is allowed a link_name, and that the link_name of children of Modules, if it is present, must be unique in that Module. This avoids any scoping issues.

What monomorphisation does is not material here. we can mangle name if we want.

@acl-cqc acl-cqc force-pushed the acl/linking_prelims branch from d495080 to cabd1bc Compare June 11, 2025 17:30
@acl-cqc acl-cqc force-pushed the acl/linking_prelims branch from 7baa225 to b5d5e9e Compare June 16, 2025 15:11
Base automatically changed from acl/schema_test2 to main July 8, 2025 12:17
@acl-cqc acl-cqc enabled auto-merge July 8, 2025 12:36
@aborgna-q aborgna-q linked an issue Jul 8, 2025 that may be closed by this pull request
@aborgna-q aborgna-q disabled auto-merge July 8, 2025 12:42
Comment on lines 689 to 693
"required": [
"parent",
"name",
"signature"
"signature",
"visibility"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a default (public?) fall-back instead of requiring the new visibility field, so the format remains backwards-compatible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I view the defaults used when deserializing as a legacy backwards-compatibility mechanism. AFAICS serde correctly applies the defaults and there is no problem loading an "old" Hugr w/out visibility - at least outside the envelope mechanism, I'm working on a test using production/envelope-loading code.

Do you think that marking old hugrs as "not schema compliant" prevents loading them? I mean, do we require old Hugrs to be schema-compliant (not just loadable) in order to say backwards compatibility is maintained? (Do we really need the schema to encompass all supported legacy formats?) Your answer suggests "yes" to at least the last two questions here, is that really what you mean?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fields must be marked as default-if-not-present to be correctly loaded, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a test using Hugr::load of a FuncDecl and a FuncDefn without any visibility. Defaults correctly applied....?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, it looks like that's undocumented serde behaviour.
It doesn't hurt to be explicit though...

I tested a toy example for pydantic, and I'm pretty sure that we require the default there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right - I was just thinking, what's the next thing to try - do the same thing in python.

Clearly this is more subtle than I expected and as such I think having some tests of loading legacy Hugrs really is warranted after all. Let's get your "toy example" in as well and then I can resolve (somehow)....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so python test added using the same file in resources, skipped if it can't read it (e.g. sdist).
Defaults added to pydantic, sadly duplicating those for serde.

I think you can see all the changes here: https://github.com/CQCL/hugr/compare/2cbe99f44d123b3788fb0801a630bca5e0d9c735..acl/linking_prelims

That's on top of the other changes since approval - removing the special-case for FuncDefn called "main" (now just defaults to private), and all changes to hugr-passes (pending followup PR) - after discussion with @ss2165 .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I tried adding a default "unspecified" to the hugr-model capnp, so Symbol can have Option. This is tidier in many ways (albeit more verbose), see here: https://github.com/CQCL/hugr/compare/acl/linking_prelims..acl/vis_unspec I could include that here (probably switching the model text format to "public" and "private" rather than "pub" and "priv") if you think it's worth it?

@aborgna-q aborgna-q added this to the hugr-rs 0.21 milestone Jul 8, 2025
@acl-cqc acl-cqc requested a review from aborgna-q July 8, 2025 18:03
@acl-cqc acl-cqc enabled auto-merge July 9, 2025 10:59
@acl-cqc acl-cqc added this pull request to the merge queue Jul 9, 2025
Merged via the queue into main with commit 5bbe0cd Jul 9, 2025
26 of 27 checks passed
@acl-cqc acl-cqc deleted the acl/linking_prelims branch July 9, 2025 11:05
lmondada pushed a commit that referenced this pull request Jul 9, 2025
Note: modified to come after #2412 as I want those Schema checks in
place to check this works!
closes #2354, #1752.
Includes cherry-pick of #2343.

* Add `enum Visibility`. In fact *2 (hugr-model version is not
serde-able so cannot be used in hugr-core).
* `FuncDefn` and `FuncDecl` gain this. (A good use-case for a private
FuncDecl is building cyclic functions via builder `define_declaration`.)
* I've not added to `AliasDecl` or `AliasDefn` - I could, it would be
consistent, but we hardly use them....
* `validate` checks that the *public* children of a Module have unique
names (except multiple FuncDecls may alias).

* `FuncDefn::new` defaults to private (also builder `define_function` /
`FunctionBuilder::new`, and json-deserialize in both python and rust).
There is a `_vis` taking an explicit Visibility parameter.
* `FuncDecl::new` defaults to public (also builder `declare_function`,
and json-deserialize*2). Again there is `_vis`.
* hugr-model import/export + roundtrip + AST printing via new keyword
`pub`. Note since `hugr-core` does not have visibility on aliases or
extension operations I've defaulted these to private to avoid any change
to textual output.
* add field to hugr-py, using "string"-enum (`Literal["Public",
"Private"]`)
* I've attempted to add hugr-model hugr-py bindings, but there are no
tests of these yet.

Note all changes to hugr-passes delayed until a follow-up PR.

BREAKING CHANGE: hugr-model: Symbol has an extra field
@hugrbot hugrbot mentioned this pull request Jul 9, 2025
github-merge-queue bot pushed a commit that referenced this pull request Jul 10, 2025
This release includes a long list of changes:

- The HUGR model serialization format is now stable, and should be
preferred over the old JSON format.
- Type parameters and type arguments are now unified into a single
`Term` type.
- Function definitions can no longer be nested inside dataflow regions.
Now they must be defined at the top level module.
- Function definitions and declarations now have a `Visibility` field,
which define whether they are visible in the public API of the module.
- And many more fixes and improvements.

---

## 🤖 New release

* `hugr-model`: 0.20.2 -> 0.21.0 (⚠ API breaking changes)
* `hugr-core`: 0.20.2 -> 0.21.0 (⚠ API breaking changes)
* `hugr-llvm`: 0.20.2 -> 0.21.0 (⚠ API breaking changes)
* `hugr-passes`: 0.20.2 -> 0.21.0 (✓ API compatible changes)
* `hugr`: 0.20.2 -> 0.21.0 (✓ API compatible changes)
* `hugr-cli`: 0.20.2 -> 0.21.0 (⚠ API breaking changes)

### ⚠ `hugr-model` breaking changes

```text
--- failure constructible_struct_adds_field: externally-constructible struct adds field ---

Description:
A pub struct constructible with a struct literal has a new pub field. Existing struct literals must be updated to include the new field.
        ref: https://doc.rust-lang.org/reference/expressions/struct-expr.html
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.41.0/src/lints/constructible_struct_adds_field.ron

Failed in:
  field Symbol.visibility in /tmp/.tmpEqPTGR/hugr/hugr-model/src/v0/ast/mod.rs:198
  field Symbol.visibility in /tmp/.tmpEqPTGR/hugr/hugr-model/src/v0/table/mod.rs:307

--- failure pub_module_level_const_missing: pub module-level const is missing ---

Description:
A public const is missing or renamed
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.41.0/src/lints/pub_module_level_const_missing.ron

Failed in:
  CORE_CTRL_TYPE in file /tmp/.tmp1p6e1v/hugr-model/src/v0/mod.rs:175

--- failure struct_with_no_pub_fields_changed_type: public API struct with no public fields is no longer a struct ---

Description:
A struct without pub fields became an enum or union, breaking pattern matching.
        ref: https://internals.rust-lang.org/t/rest-patterns-foo-should-match-non-struct-types/21607
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.41.0/src/lints/struct_with_no_pub_fields_changed_type.ron

Failed in:
  struct hugr_model::v0::scope::UnknownVarError became enum in file /tmp/.tmpEqPTGR/hugr/hugr-model/src/v0/scope/vars.rs:147
```

### ⚠ `hugr-core` breaking changes

```text
--- failure auto_trait_impl_removed: auto trait no longer implemented ---

Description:
A public type has stopped implementing one or more auto traits. This can break downstream code that depends on the traits being implemented.
        ref: https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.41.0/src/lints/auto_trait_impl_removed.ron

Failed in:
  type Term is no longer UnwindSafe, in /tmp/.tmpEqPTGR/hugr/hugr-core/src/types/type_param.rs:70
  type Term is no longer RefUnwindSafe, in /tmp/.tmpEqPTGR/hugr/hugr-core/src/types/type_param.rs:70

--- 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.41.0/src/lints/enum_missing.ron

Failed in:
  enum hugr_core::types::type_param::TypeArgError, previously in file /tmp/.tmp1p6e1v/hugr-core/src/types/type_param.rs:450
  enum hugr_core::hugr::persistent::walker::PinNodeError, previously in file /tmp/.tmp1p6e1v/hugr-core/src/hugr/persistent/walker.rs:333
  enum hugr_core::hugr::persistent::serial::SerialCommitData, previously in file /tmp/.tmp1p6e1v/hugr-core/src/hugr/persistent/state_space/serial.rs:11
  enum hugr_core::import::ImportError, previously in file /tmp/.tmp1p6e1v/hugr-core/src/import.rs:39
  enum hugr_core::import::OrderHintError, previously in file /tmp/.tmp1p6e1v/hugr-core/src/import.rs:82
  enum hugr_core::hugr::persistent::InvalidCommit, previously in file /tmp/.tmp1p6e1v/hugr-core/src/hugr/persistent/state_space.rs:474

--- failure enum_no_repr_variant_discriminant_changed: enum variant had its discriminant change value ---

Description:
The enum's variant had its discriminant value change. This breaks downstream code that used its value via a numeric cast like `as isize`.
        ref: https://doc.rust-lang.org/reference/items/enumerations.html#assigning-discriminant-values
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.41.0/src/lints/enum_no_repr_variant_discriminant_changed.ron

Failed in:
  variant InterGraphEdgeError::NonCFGAncestor 2 -> 1 in /tmp/.tmpEqPTGR/hugr/hugr-core/src/hugr/validate.rs:795
  variant InterGraphEdgeError::MissingOrderEdge 3 -> 2 in /tmp/.tmpEqPTGR/hugr/hugr-core/src/hugr/validate.rs:806
  variant InterGraphEdgeError::NoRelation 4 -> 3 in /tmp/.tmpEqPTGR/hugr/hugr-core/src/hugr/validate.rs:817
  variant InterGraphEdgeError::NonDominatedAncestor 5 -> 4 in /tmp/.tmpEqPTGR/hugr/hugr-core/src/hugr/validate.rs:827

--- failure enum_variant_added: enum variant added on exhaustive enum ---

Description:
A publicly-visible enum without #[non_exhaustive] has a new variant.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#enum-variant-new
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.41.0/src/lints/enum_variant_added.ron

Failed in:
  variant TypeBound:Linear in /tmp/.tmpEqPTGR/hugr/hugr-core/src/types.rs:138

--- 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.41.0/src/lints/enum_variant_missing.ron

Failed in:
  variant PackageEncodingError::RuntimeExtensionResolution, previously in file /tmp/.tmp1p6e1v/hugr-core/src/envelope/package_json.rs:77
  variant Term::Type, previously in file /tmp/.tmp1p6e1v/hugr-core/src/types/type_param.rs:67
  variant Term::Type, previously in file /tmp/.tmp1p6e1v/hugr-core/src/types/type_param.rs:158
  variant Term::Sequence, previously in file /tmp/.tmp1p6e1v/hugr-core/src/types/type_param.rs:180
  variant Term::Type, previously in file /tmp/.tmp1p6e1v/hugr-core/src/types/type_param.rs:158
  variant Term::Sequence, previously in file /tmp/.tmp1p6e1v/hugr-core/src/types/type_param.rs:180
  variant TypeBound::Any, previously in file /tmp/.tmp1p6e1v/hugr-core/src/types.rs:136
  variant InterGraphEdgeError::ValueEdgeIntoFunc, previously in file /tmp/.tmp1p6e1v/hugr-core/src/hugr/validate.rs:766
  variant ValidationError::ExtensionError, previously in file /tmp/.tmp1p6e1v/hugr-core/src/hugr/validate.rs:714
  variant ValidationError::ExtensionError, previously in file /tmp/.tmp1p6e1v/hugr-core/src/hugr/validate.rs:714

--- 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.41.0/src/lints/function_missing.ron

Failed in:
  function hugr_core::types::type_param::check_type_arg, previously in file /tmp/.tmp1p6e1v/hugr-core/src/types/type_param.rs:384
  function hugr_core::types::type_param::check_type_args, previously in file /tmp/.tmp1p6e1v/hugr-core/src/types/type_param.rs:437

--- 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.41.0/src/lints/inherent_method_missing.ron

Failed in:
  Term::max_nat, previously in file /tmp/.tmp1p6e1v/hugr-core/src/types/type_param.rs:100
  Term::bounded_nat, previously in file /tmp/.tmp1p6e1v/hugr-core/src/types/type_param.rs:108
  Term::as_type, previously in file /tmp/.tmp1p6e1v/hugr-core/src/types/type_param.rs:275
  Term::as_type, previously in file /tmp/.tmp1p6e1v/hugr-core/src/types/type_param.rs:275

--- 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.41.0/src/lints/method_parameter_count_changed.ron

Failed in:
  hugr_core::hugr::patch::simple_replace::SimpleReplacement::linked_replacement_output now takes 4 parameters instead of 3, in /tmp/.tmpEqPTGR/hugr/hugr-core/src/hugr/patch/simple_replace.rs:134
  hugr_core::hugr::patch::simple_replace::SimpleReplacement::linked_replacement_inputs now takes 4 parameters instead of 3, in /tmp/.tmpEqPTGR/hugr/hugr-core/src/hugr/patch/simple_replace.rs:221
  hugr_core::hugr::patch::SimpleReplacement::linked_replacement_output now takes 4 parameters instead of 3, in /tmp/.tmpEqPTGR/hugr/hugr-core/src/hugr/patch/simple_replace.rs:134
  hugr_core::hugr::patch::SimpleReplacement::linked_replacement_inputs now takes 4 parameters instead of 3, in /tmp/.tmpEqPTGR/hugr/hugr-core/src/hugr/patch/simple_replace.rs:221
  hugr_core::hugr::SimpleReplacement::linked_replacement_output now takes 4 parameters instead of 3, in /tmp/.tmpEqPTGR/hugr/hugr-core/src/hugr/patch/simple_replace.rs:134
  hugr_core::hugr::SimpleReplacement::linked_replacement_inputs now takes 4 parameters instead of 3, in /tmp/.tmpEqPTGR/hugr/hugr-core/src/hugr/patch/simple_replace.rs:221
  hugr_core::SimpleReplacement::linked_replacement_output now takes 4 parameters instead of 3, in /tmp/.tmpEqPTGR/hugr/hugr-core/src/hugr/patch/simple_replace.rs:134
  hugr_core::SimpleReplacement::linked_replacement_inputs now takes 4 parameters instead of 3, in /tmp/.tmpEqPTGR/hugr/hugr-core/src/hugr/patch/simple_replace.rs:221

--- 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.41.0/src/lints/module_missing.ron

Failed in:
  mod hugr_core::hugr::persistent, previously in file /tmp/.tmp1p6e1v/hugr-core/src/hugr/persistent.rs:1
  mod hugr_core::hugr::persistent::walker, previously in file /tmp/.tmp1p6e1v/hugr-core/src/hugr/persistent/walker.rs:1
  mod hugr_core::hugr::persistent::serial, previously in file /tmp/.tmp1p6e1v/hugr-core/src/hugr/persistent.rs:769

--- 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.41.0/src/lints/struct_missing.ron

Failed in:
  struct hugr_core::hugr::persistent::PatchNode, previously in file /tmp/.tmp1p6e1v/hugr-core/src/hugr/persistent/state_space.rs:28
  struct hugr_core::hugr::persistent::walker::PinnedWire, previously in file /tmp/.tmp1p6e1v/hugr-core/src/hugr/persistent/walker/pinned.rs:30
  struct hugr_core::hugr::persistent::PinnedWire, previously in file /tmp/.tmp1p6e1v/hugr-core/src/hugr/persistent/walker/pinned.rs:30
  struct hugr_core::hugr::persistent::PersistentHugr, previously in file /tmp/.tmp1p6e1v/hugr-core/src/hugr/persistent.rs:274
  struct hugr_core::hugr::persistent::serial::SerialCommitStateSpace, previously in file /tmp/.tmp1p6e1v/hugr-core/src/hugr/persistent/state_space/serial.rs:54
  struct hugr_core::types::type_param::TypeArgVariable, previously in file /tmp/.tmp1p6e1v/hugr-core/src/types/type_param.rs:236
  struct hugr_core::hugr::persistent::walker::Walker, previously in file /tmp/.tmp1p6e1v/hugr-core/src/hugr/persistent/walker.rs:87
  struct hugr_core::hugr::persistent::Walker, previously in file /tmp/.tmp1p6e1v/hugr-core/src/hugr/persistent/walker.rs:87
  struct hugr_core::hugr::persistent::PointerEqResolver, previously in file /tmp/.tmp1p6e1v/hugr-core/src/hugr/persistent/resolver.rs:11
  struct hugr_core::hugr::persistent::CommitStateSpace, previously in file /tmp/.tmp1p6e1v/hugr-core/src/hugr/persistent/state_space.rs:64
  struct hugr_core::hugr::persistent::Commit, previously in file /tmp/.tmp1p6e1v/hugr-core/src/hugr/persistent.rs:108

--- failure trait_method_missing: pub trait method removed or renamed ---

Description:
A trait method is no longer callable, and may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#major-any-change-to-trait-item-signatures
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.41.0/src/lints/trait_method_missing.ron

Failed in:
  method define_function of trait Container, previously in file /tmp/.tmp1p6e1v/hugr-core/src/builder/build_traits.rs:92
```

### ⚠ `hugr-llvm` breaking changes

```text
--- failure trait_method_requires_different_generic_type_params: trait method now requires a different number of generic type parameters ---

Description:
A trait method now requires a different number of generic type parameters than it used to. Calls or implementations of this trait method using 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.41.0/src/lints/trait_method_requires_different_generic_type_params.ron

Failed in:
  FatExt::fat_root (1 -> 0 generic types) in /tmp/.tmpEqPTGR/hugr/hugr-llvm/src/utils/fat.rs:376
```

### ⚠ `hugr-cli` breaking changes

```text
--- 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.41.0/src/lints/inherent_method_missing.ron

Failed in:
  ValArgs::verbosity, previously in file /tmp/.tmp1p6e1v/hugr-cli/src/validate.rs:53
  MermaidArgs::verbosity, previously in file /tmp/.tmp1p6e1v/hugr-cli/src/mermaid.rs:78

--- 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.41.0/src/lints/struct_pub_field_missing.ron

Failed in:
  field other_args of struct ValArgs, previously in file /tmp/.tmp1p6e1v/hugr-cli/src/validate.rs:24
  field other_args of struct MermaidArgs, previously in file /tmp/.tmp1p6e1v/hugr-cli/src/mermaid.rs:36

--- 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.41.0/src/lints/enum_missing.ron

Failed in:
  enum hugr_cli::CliArgs, previously in file /tmp/.tmp1p6e1v/hugr-cli/src/lib.rs:78

--- 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.41.0/src/lints/struct_missing.ron

Failed in:
  struct hugr_cli::OtherArgs, previously in file /tmp/.tmp1p6e1v/hugr-cli/src/lib.rs:122
```

<details><summary><i><b>Changelog</b></i></summary><p>

## `hugr-model`

<blockquote>

##
[0.21.0](hugr-model-v0.20.2...hugr-model-v0.21.0)
- 2025-07-09

### Bug Fixes

- Model import should perform extension resolution
([#2326](#2326))
- [**breaking**] Fixed bugs in model CFG handling and improved CFG
signatures ([#2334](#2334))
- [**breaking**] Fix panic in model resolver when variable is used
outside of symbol. ([#2362](#2362))
- Order hints on input and output nodes.
([#2422](#2422))

### New Features

- [**breaking**] Added float and bytes literal to core and python
bindings. ([#2289](#2289))
- better errors using metadata from generator
([#2368](#2368))
- [**breaking**] Add Visibility to FuncDefn/FuncDecl.
([#2143](#2143))
- [**breaking**] hugr-model use explicit Option<Visibility>, with
::Unspecified in capnp ([#2424](#2424))
</blockquote>

## `hugr-core`

<blockquote>

##
[0.21.0](hugr-core-v0.20.2...hugr-core-v0.21.0)
- 2025-07-09

### Bug Fixes

- Fixed two bugs in import/export of function operations
([#2324](#2324))
- Model import should perform extension resolution
([#2326](#2326))
- [**breaking**] Fixed bugs in model CFG handling and improved CFG
signatures ([#2334](#2334))
- Use List instead of Tuple in conversions for TypeArg/TypeRow
([#2378](#2378))
- Do extension resolution on loaded extensions from the model format
([#2389](#2389))
- Make JSON Schema checks actually work again
([#2412](#2412))
- Order hints on input and output nodes.
([#2422](#2422))

### New Features

- [**breaking**] No nested FuncDefns (or AliasDefns)
([#2256](#2256))
- Add serial data types for SimpleReplacement and PersistentHugr
([#2300](#2300))
- [**breaking**] Split `TypeArg::Sequence` into tuples and lists.
([#2140](#2140))
- [**breaking**] Added float and bytes literal to core and python
bindings. ([#2289](#2289))
- [**breaking**] More helpful error messages in model import
([#2272](#2272))
- Add MermaidFormatter to replace RenderConfig
([#2275](#2275))
- [**breaking**] Better error reporting in `hugr-cli`.
([#2318](#2318))
- *(core)* builder pattern for EnvelopeConfig
([#2330](#2330))
- *(core, llvm)* add array unpack operations
([#2339](#2339))
- [**breaking**] Merge `TypeParam` and `TypeArg` into one `Term` type in
Rust ([#2309](#2309))
- *(persistent)* Add serialisation for CommitStateSpace
([#2344](#2344))
- Deprecate invalidation_set, add invalidated_nodes and
SimpleReplacement::invalidation_set
([#2358](#2358))
- Rewrite for peeling a TailLoop
([#2290](#2290))
- Create Module/FunctionBuilders from existing Hugrs
([#2359](#2359))
- add TryFrom impls for TypeArg/TypeRow
([#2366](#2366))
- better errors using metadata from generator
([#2368](#2368))
- use `core.` prefixes for generator metadata keys
([#2371](#2371))
- Add `MakeError` op ([#2377](#2377))
- Open lists and tuples in `Term`
([#2360](#2360))
- Call `FunctionBuilder::add_{in,out}put` for any AsMut<Hugr>
([#2376](#2376))
- Add Root checked methods to DataflowParentID
([#2382](#2382))
- Add PersistentWire type
([#2361](#2361))
- Add `BorrowArray` extension
([#2395](#2395))
- [**breaking**] Rename 'Any' type bound to 'Linear'
([#2421](#2421))
- [**breaking**] Add Visibility to FuncDefn/FuncDecl.
([#2143](#2143))
- *(per)* [**breaking**] Support empty wires in commits
([#2349](#2349))
- [**breaking**] hugr-model use explicit Option<Visibility>, with
::Unspecified in capnp ([#2424](#2424))

### Refactor

- [**breaking**] move PersistentHugr into separate crate
([#2277](#2277))
- *(types.rs)* rm incorrect comment and unnecessary allow-unused
([#2340](#2340))
- [**breaking**] remove deprecated runtime extension errors
([#2369](#2369))
- [**breaking**] Reduce error type sizes
([#2420](#2420))

### Testing

- Check hugr json serializations against the schema (again)
([#2216](#2216))
</blockquote>

## `hugr-llvm`

<blockquote>

##
[0.21.0](hugr-llvm-v0.20.2...hugr-llvm-v0.21.0)
- 2025-07-09

### New Features

- [**breaking**] No nested FuncDefns (or AliasDefns)
([#2256](#2256))
- [**breaking**] Split `TypeArg::Sequence` into tuples and lists.
([#2140](#2140))
- [**breaking**] More helpful error messages in model import
([#2272](#2272))
- *(core, llvm)* add array unpack operations
([#2339](#2339))
- [**breaking**] Merge `TypeParam` and `TypeArg` into one `Term` type in
Rust ([#2309](#2309))
- Add `MakeError` op ([#2377](#2377))

### Refactor

- *(llvm)* replace HashMap with BTreeMap
([#2313](#2313))
</blockquote>

## `hugr-passes`

<blockquote>

##
[0.21.0](hugr-passes-v0.20.2...hugr-passes-v0.21.0)
- 2025-07-09

### Bug Fixes

- update CallGraph and remove_dead_funcs for module-only FuncDefns
([#2336](#2336))
- DeadFuncElimPass+CallGraph w/ non-module-child entrypoint
([#2390](#2390))

### New Features

- [**breaking**] No nested FuncDefns (or AliasDefns)
([#2256](#2256))
- [**breaking**] Split `TypeArg::Sequence` into tuples and lists.
([#2140](#2140))
- [**breaking**] Merge `TypeParam` and `TypeArg` into one `Term` type in
Rust ([#2309](#2309))
- [**breaking**] Rename 'Any' type bound to 'Linear'
([#2421](#2421))

### Refactor

- [**breaking**] Reduce error type sizes
([#2420](#2420))
</blockquote>

## `hugr`

<blockquote>

##
[0.21.0](hugr-v0.20.2...hugr-v0.21.0)
- 2025-07-09

### Bug Fixes

- update CallGraph and remove_dead_funcs for module-only FuncDefns
([#2336](#2336))
- DeadFuncElimPass+CallGraph w/ non-module-child entrypoint
([#2390](#2390))
- Fixed two bugs in import/export of function operations
([#2324](#2324))
- Model import should perform extension resolution
([#2326](#2326))
- [**breaking**] Fixed bugs in model CFG handling and improved CFG
signatures ([#2334](#2334))
- Use List instead of Tuple in conversions for TypeArg/TypeRow
([#2378](#2378))
- Do extension resolution on loaded extensions from the model format
([#2389](#2389))
- Make JSON Schema checks actually work again
([#2412](#2412))
- Order hints on input and output nodes.
([#2422](#2422))

### Documentation

- Hide hugr-persistent docs
([#2357](#2357))

### New Features

- Add serial data types for SimpleReplacement and PersistentHugr
([#2300](#2300))
- [**breaking**] Split `TypeArg::Sequence` into tuples and lists.
([#2140](#2140))
- [**breaking**] Added float and bytes literal to core and python
bindings. ([#2289](#2289))
- [**breaking**] More helpful error messages in model import
([#2272](#2272))
- Add MermaidFormatter to replace RenderConfig
([#2275](#2275))
- [**breaking**] Better error reporting in `hugr-cli`.
([#2318](#2318))
- *(core, llvm)* add array unpack operations
([#2339](#2339))
- [**breaking**] Merge `TypeParam` and `TypeArg` into one `Term` type in
Rust ([#2309](#2309))
- *(persistent)* Add serialisation for CommitStateSpace
([#2344](#2344))
- Deprecate invalidation_set, add invalidated_nodes and
SimpleReplacement::invalidation_set
([#2358](#2358))
- Rewrite for peeling a TailLoop
([#2290](#2290))
- Create Module/FunctionBuilders from existing Hugrs
([#2359](#2359))
- add TryFrom impls for TypeArg/TypeRow
([#2366](#2366))
- better errors using metadata from generator
([#2368](#2368))
- use `core.` prefixes for generator metadata keys
([#2371](#2371))
- Add `MakeError` op ([#2377](#2377))
- Open lists and tuples in `Term`
([#2360](#2360))
- Call `FunctionBuilder::add_{in,out}put` for any AsMut<Hugr>
([#2376](#2376))
- Add Root checked methods to DataflowParentID
([#2382](#2382))
- Add PersistentWire type
([#2361](#2361))
- Add `BorrowArray` extension
([#2395](#2395))
- [**breaking**] Add Visibility to FuncDefn/FuncDecl.
([#2143](#2143))
- *(per)* [**breaking**] Support empty wires in commits
([#2349](#2349))
- [**breaking**] hugr-model use explicit Option<Visibility>, with
::Unspecified in capnp ([#2424](#2424))
- [**breaking**] No nested FuncDefns (or AliasDefns)
([#2256](#2256))
- *(core)* builder pattern for EnvelopeConfig
([#2330](#2330))
- [**breaking**] Rename 'Any' type bound to 'Linear'
([#2421](#2421))

### Refactor

- *(types.rs)* rm incorrect comment and unnecessary allow-unused
([#2340](#2340))
- [**breaking**] remove deprecated runtime extension errors
([#2369](#2369))
- [**breaking**] Reduce error type sizes
([#2420](#2420))
- [**breaking**] move PersistentHugr into separate crate
([#2277](#2277))

### Testing

- Check hugr json serializations against the schema (again)
([#2216](#2216))
</blockquote>

## `hugr-cli`

<blockquote>

##
[0.21.0](hugr-cli-v0.20.2...hugr-cli-v0.21.0)
- 2025-07-09

### New Features

- [**breaking**] Better error reporting in `hugr-cli`.
([#2318](#2318))
- *(cli)* convert sub-command for converting envelope formats
([#2331](#2331))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

---------

Co-authored-by: Agustín Borgna <agustin.borgna@quantinuum.com>
@hugrbot hugrbot mentioned this pull request Jul 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add visibility specifier to FuncDefn (+friends) Decide on which functions are "public"
5 participants