Skip to content

feat: add separate DCE pass #1902

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 29 commits into from
Mar 3, 2025
Merged

feat: add separate DCE pass #1902

merged 29 commits into from
Mar 3, 2025

Conversation

acl-cqc
Copy link
Contributor

@acl-cqc acl-cqc commented Feb 3, 2025

Still non-breaking, so we leave Constant Folding as assuming inputs apply to main: the DCE pass allows explicitly specifying entry points, constant folding specifies main if appropriate. (I could add a flag to ConstantFoldPass = preserve all FuncDefns/FuncDecls?)

The callback mechanism generalizes the previous might_diverge mechanism but is significantly more general. (Too general??)

closes #1807

Base automatically changed from acl/fix_const_fold to main February 4, 2025 14:18
Copy link

codecov bot commented Feb 4, 2025

Codecov Report

Attention: Patch coverage is 93.18182% with 15 lines in your changes missing coverage. Please review.

Project coverage is 83.70%. Comparing base (b760ef8) to head (82b708d).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
hugr-passes/src/dead_code.rs 92.93% 13 Missing ⚠️
hugr-passes/src/const_fold.rs 95.83% 0 Missing and 1 partial ⚠️
hugr-passes/src/lib.rs 90.90% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1902      +/-   ##
==========================================
+ Coverage   83.69%   83.70%   +0.01%     
==========================================
  Files         196      198       +2     
  Lines       37691    37823     +132     
  Branches    34504    34636     +132     
==========================================
+ Hits        31545    31661     +116     
- Misses       4360     4376      +16     
  Partials     1786     1786              
Flag Coverage Δ
python 92.34% <ø> (ø)
rust 82.91% <93.18%> (+0.01%) ⬆️

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.

@acl-cqc acl-cqc marked this pull request as ready for review February 4, 2025 16:16
@acl-cqc acl-cqc requested a review from a team as a code owner February 4, 2025 16:16
@acl-cqc acl-cqc requested a review from cqc-alec February 4, 2025 16:16
pub type PreserveCallback = dyn Fn(&Hugr, Node) -> PreserveNode;

/// Signal that a node must be preserved even when its result is not used
pub enum PreserveNode {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The callback mechanism may be a sledgehammer to crack a nail, I'm not sure if there are alternatives.

  • One might just say that every node that shouldn't be removed should just be added as an entry-point (i.e. including Calls, TailLoops, etc.)
    • I'm not quite clear how this interacts with hierarchy, but that probably works ok
    • However, the issue here is that we want the default to be conservative, so we should assume Call/CFG/TailLoop are impure unless we have evidence otherwise. This would mean the default would require adding every Call/CFG/TailLoop as an entrypoint, which sounds like far too much work to inflict on the client. Instead we'd have to have an add_removable or something (and the client could list such nodes).
  • As it stands this enum does have "everything I could think of", so it might be appropriate to make the enum smaller and add [non_exhaustive]

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree we shouldn't demand the user specify every Call/CFG/TailLoop as an entry point; the interface does seem a bit awkward but I don't have a better suggestion.

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 the alternative is two methods on DeadCodeElimPass:

  • force_keep(&mut self, Node)
  • allow_remove(&mut self, Node)
    I guess we could add a bool flag to the latter to determine whether it allows removing a node without checking its descendants, or only if its descendants can also be removed.

This feels simpler in many ways but the drawback (IMHO) is that this approach requires any client to understand the defaults (i.e., currently, that Call + TailLoop + CFG default to being non-removable, nothing else). Potentially those defaults might change (e.g. if we change the DCEPass to look for acyclic CFGs), too. Seems to me that the enum PreserveNode + callback makes it easier for clients to replace the defaults (or fall back to them) without understanding what they are.

That might be illusory, though; one can implement any policy with either approach, e.g. making sure to call either force_keep or allow_remove for every Node. Thoughts @cqc-alec ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

That does feel a bit simpler. But I don't know if it would be in practice. With the callback mechanism, one can define a DeadCodeElimPass that can be used on multiple hugrs; whereas with these methods one would have to define a new one for each hugr. On balance I think I prefer the callbacks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a really good point about using it on different Hugrs. Ok, will keep callbacks...

#[derive(Clone, Default)]
pub struct DeadCodeElimPass {
entry_points: Vec<Node>,
preserve_callback: Option<Arc<PreserveCallback>>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

There should be some documentation of what these are, especially preserve_callback.

pub type PreserveCallback = dyn Fn(&Hugr, Node) -> PreserveNode;

/// Signal that a node must be preserved even when its result is not used
pub enum PreserveNode {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree we shouldn't demand the user specify every Call/CFG/TailLoop as an entry point; the interface does seem a bit awkward but I don't have a better suggestion.

Comment on lines 76 to 79
/// Mark some nodes as entry-points to the Hugr.
/// The root node is assumed to be an entry point;
/// for Module roots the client will want to mark some of the FuncDefn children
/// as entry-points too.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is "entry point" hyphenated or not? (I think not.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed not. I think this might be slightly harder to read/parse (how long to realize that entry here is an adjective), but ok.

.run_validated_pass(hugr, |h, _| self.run_no_validate(h))
}

fn run_no_validate(&self, hugr: &mut impl HugrMut) -> Result<(), ValidatePassError> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does the return type need to include ValidatePassError?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, it's a private helper method...so we could do it in the closure passed to run_validated_pass.....ok, it's clearer without the Result, indeed

}

// "Diverge" aka "never-terminate"
// TODO would be more efficient to compute this bottom-up and cache (dynamic programming)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Make an issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now we have a proper DCE pass....it really wasn't that hard....

match h.get_optype(n) {
OpType::CFG(_) => {
// TODO if the CFG has no cycles (that are possible given predicates)
// then we could say it definitely terminates (i.e. return false)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm probably missing something, but I'm not sure why we don't want to remove nodes that we can't prove terminate. It's true that doing so would change runtime behaviour (as is the case for any optimization), but would it change program semantics?

Found a discussion of this question here: https://stackoverflow.com/questions/2178115/are-compilers-allowed-to-eliminate-infinite-loops

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From reading that I am less sure than I was but OTOH I think this could just be the C "undefined behaviour" brigade. (That is, the school of thought that we can make your programs "faster" by making more of them do things you didn't expect and making it more and more difficult to write programs that do do what you want.) I think I would still say - changing nontermination into termination changes observable behaviour, in that, writing to files (including stdout) is observable, and a program that does that is different from a program that doesn't. So by one definition there, interpret "sequence point" and "volatile" as including system calls and data.

IOW - here are two ways of writing the same thing:

while b(): sleep()
launch_missiles()

and

while True:
   if b():
      sleep()
   else
      launch_missiles()
      break()

I think the "you can optimize away infinite loops" means you can turn the first into launch_missiles (at least, in the absence of "state edges" and other such extra inputs/outputs to b()), but not the second, which to me is a bit of a false dichotomy. I guess the counterargument is then that the second has a "control dependence" of launch_missiles() upon b() and we should add a representation of that into the first, i.e. there is some (hidden-in-the-source) probably-linear loop-variant mutated by b and then passed from the loop to launching. In which case maybe we need to put off this PR until we've thoroughly investigated ordering and effect systems https://github.com/quantinuum-dev/hm25/issues/62 #1813

Copy link
Collaborator

Choose a reason for hiding this comment

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

In my view it's distinct from UB. The example using sleep() maybe muddies the waters a bit because it implies a linear time type (or something similar) passing through so that the operation is effectful (and therefore can't be removed). But if we had noop there instead of sleep() then I'd be heading for the nearest bunker! We don't make any claim about the time taken to execute a noop...

writing to files (including stdout) is observable, and a program that does that is different from a program that doesn't

Dunno, I would agree if "a program that doesn't" is replaced by "a terminated program that didn't" ...

Not arguing this so much for philosophical reasons as to suggest we can make the optimizer simpler and better by not worrying about it. But indeed it may depend on exactly how we are handling states and effects.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah on balance I think the best thing to do here is to leave this existing behaviour unchanged - and this PR is a non-breaking change! - and then do something different when we resolve handling of effects. (Indeed I am heading towards, removing such nodes unless they have outgoing edges, but there's a significant semantic change to the Hugr there.)

If I address the rest, does that sound good?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds good to me.

@acl-cqc
Copy link
Contributor Author

acl-cqc commented Feb 26, 2025

Thanks, Alec - I've rejigged the callback a little (one less enum element, made default_for a function) and hopefully addressed the others :)

@acl-cqc acl-cqc requested a review from cqc-alec February 26, 2025 23:18
Copy link
Collaborator

@cqc-alec cqc-alec left a comment

Choose a reason for hiding this comment

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

Looks good, just a query on the names. And it seems there is a new CI issue that is unrelated.

Comment on lines 66 to 69
RemoveIgnoreChildren,
/// The node may be removed if all of its children can
/// (must be kept if, and only if, any of its children must be kept)
RemoveIfChildren,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if these names are quite descriptive enough. Maybe something like CanRemoveIgnoringChildren and CanRemoveIfChildrenRemoved ? Bit of a mouthful I know but maybe less room for confusion?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CanRemoveIgnoringChildren seems fair - perhaps DespiteChildren? ("Regardless" seems even longer)

CanRemoveIfChildrenRemovable I guess would be correct, but perhaps the point to note here is - this node makes no requirements (MustKeep is the requirement) - so how about just DeferToChildren, AccordingToChildren, AsChildren ??

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, DeferToChildren seems good!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@acl-cqc
Copy link
Contributor Author

acl-cqc commented Mar 3, 2025

Ok, merged with main - the change to HugrView::Node doesn't really impact as we always need a HugrMut anyway (which fixes upon Node)

@acl-cqc acl-cqc requested a review from cqc-alec March 3, 2025 10:05
@acl-cqc acl-cqc added this pull request to the merge queue Mar 3, 2025
Merged via the queue into main with commit 78e0176 Mar 3, 2025
25 checks passed
@acl-cqc acl-cqc deleted the acl/separate_dce branch March 3, 2025 11:17
@hugrbot hugrbot mentioned this pull request Feb 28, 2025
github-merge-queue bot pushed a commit that referenced this pull request Mar 13, 2025
…1896)

Instead, move towards explicitly stating entry-points, in common with
`remove_dead_funcs` and `remove_dead_code` in #1902

I've also tried to reorganise the code a bit better wrt.
`prepopulate_df_inputs` as we can also handle `Conditional` and `CFG`
nodes by using existing code, hence renaming to just
`prepopulate_inputs`

BREAKING CHANGE: dataflow analysis on Module-rooted Hugrs will no longer
accept input PartialValues for the main function, these should be passed
to `prepopulate_inputs` instead. Also `prepopulate_df_inputs` is gone,
again use `prepopulate_inputs`. ConstantFoldPass::with_inputs now takes
the entry-point node as first parameter as well as the inputs to apply
there.

---------

Co-authored-by: Douglas Wilson <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Mar 14, 2025
## 🤖 New release

* `hugr-model`: 0.17.1 -> 0.18.0 (⚠ API breaking changes)
* `hugr-core`: 0.14.4 -> 0.15.0 (⚠ API breaking changes)
* `hugr-llvm`: 0.14.4 -> 0.15.0 (⚠ API breaking changes)
* `hugr-passes`: 0.14.4 -> 0.15.0 (⚠ API breaking changes)
* `hugr`: 0.14.4 -> 0.15.0 (✓ API compatible changes)
* `hugr-cli`: 0.14.4 -> 0.15.0 (⚠ API breaking changes)

### ⚠ `hugr-model` breaking changes

```text
--- 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.39.0/src/lints/enum_missing.ron

Failed in:
  enum hugr_model::v0::ModelError, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:698
  enum hugr_model::v0::Term, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:598
  enum hugr_model::v0::ListPart, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:669
  enum hugr_model::v0::Operation, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:452
  enum hugr_model::v0::TuplePart, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:660
  enum hugr_model::v0::ExtSetPart, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:678

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

Failed in:
  function hugr_model::v0::text::parse, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/text/parse.rs:41
  function hugr_model::v0::text::print_to_string, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/text/print.rs:14

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

Failed in:
  mod hugr_model::v0::text, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/text/mod.rs:1

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

Failed in:
  struct hugr_model::v0::text::ParsedModule, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/text/parse.rs:34
  struct hugr_model::v0::RegionScope, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:551
  struct hugr_model::v0::VarId, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:354
  struct hugr_model::v0::Param, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:689
  struct hugr_model::v0::NodeId, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:322
  struct hugr_model::v0::TermId, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:340
  struct hugr_model::v0::Symbol, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:582
  struct hugr_model::v0::text::ParseError, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/text/parse.rs:830
  struct hugr_model::v0::LinkId, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:349
  struct hugr_model::v0::Module, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:358
  struct hugr_model::v0::Node, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:430
  struct hugr_model::v0::LinkIndex, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:328
  struct hugr_model::v0::RegionId, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:334
  struct hugr_model::v0::Region, previously in file /tmp/.tmpuOV2md/hugr-model/src/v0/mod.rs:530
```

### ⚠ `hugr-core` breaking changes

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

Description:
A method now requires a different number of generic type parameters than it used to. Uses of this method that supplied 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.39.0/src/lints/method_requires_different_generic_type_params.ron

Failed in:
  hugr_core::hugr::views::sibling_subgraph::SiblingSubgraph::try_from_nodes_with_checker takes 0 generic types instead of 1, in /tmp/.tmpgXR84S/hugr/hugr-core/src/hugr/views/sibling_subgraph.rs:234
  hugr_core::hugr::views::SiblingSubgraph::try_from_nodes_with_checker takes 0 generic types instead of 1, in /tmp/.tmpgXR84S/hugr/hugr-core/src/hugr/views/sibling_subgraph.rs:234

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

Failed in:
  struct hugr_core::extension::prelude::Lift, previously in file /tmp/.tmpuOV2md/hugr-core/src/extension/prelude.rs:883
  struct hugr_core::extension::prelude::LiftDef, previously in file /tmp/.tmpuOV2md/hugr-core/src/extension/prelude.rs:831

--- failure trait_associated_type_added: non-sealed public trait added associated type without default value ---

Description:
A non-sealed trait has gained an associated type without a default value, which breaks downstream implementations of the trait
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#trait-new-item-no-default
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/trait_associated_type_added.ron

Failed in:
  trait associated type hugr_core::hugr::internal::HugrInternals::Node in file /tmp/.tmpgXR84S/hugr/hugr-core/src/hugr/internal.rs:30

--- failure trait_method_added: pub trait method added ---

Description:
A non-sealed public trait added a new method without a default implementation, which breaks downstream implementations of the trait
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#trait-new-item-no-default
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/trait_method_added.ron

Failed in:
  trait method hugr_core::hugr::internal::HugrInternals::get_pg_index in file /tmp/.tmpgXR84S/hugr/hugr-core/src/hugr/internal.rs:42
  trait method hugr_core::hugr::internal::HugrInternals::get_node in file /tmp/.tmpgXR84S/hugr/hugr-core/src/hugr/internal.rs:45

--- failure trait_requires_more_generic_type_params: trait now requires more generic type parameters ---

Description:
A trait now requires more generic type parameters than it used to. Uses of this trait that supplied the previously-required number of generic types will be broken. To fix this, consider supplying default values for newly-added generic types.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#trait-new-parameter-no-default
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/trait_requires_more_generic_type_params.ron

Failed in:
  trait HugrNodeRef (0 -> 1 required generic types) in /tmp/.tmpgXR84S/hugr/hugr-core/src/hugr/views/petgraph.rs:187

--- failure type_requires_more_generic_type_params: type now requires more generic type parameters ---

Description:
A type now requires more generic type parameters than it used to. Uses of this type that supplied the previously-required number of generic types will be broken. To fix this, consider supplying default values for newly-added generic types.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#trait-new-parameter-no-default
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/type_requires_more_generic_type_params.ron

Failed in:
  Struct HugrNodeRef (0 -> 1 required generic types) in /tmp/.tmpgXR84S/hugr/hugr-core/src/hugr/views/petgraph.rs:187
```

### ⚠ `hugr-llvm` breaking changes

```text
--- failure feature_missing: package feature removed or renamed ---

Description:
A feature has been removed from this package's Cargo.toml. This will break downstream crates which enable that feature.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#cargo-feature-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/feature_missing.ron

Failed in:
  feature typetag in the package's Cargo.toml
  feature pathsearch in the package's Cargo.toml
  feature serde in the package's Cargo.toml
  feature serde_json in the package's Cargo.toml
```

### ⚠ `hugr-passes` breaking changes

```text
--- failure function_requires_different_generic_type_params: function now requires a different number of generic type parameters ---

Description:
A function now requires a different number of generic type parameters than it used to. Uses of this function that supplied 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.39.0/src/lints/function_requires_different_generic_type_params.ron

Failed in:
  function ensure_no_nonlocal_edges (0 -> 1 generic types) in /tmp/.tmpgXR84S/hugr/hugr-passes/src/non_local.rs:32
  function ensure_no_nonlocal_edges (0 -> 1 generic types) in /tmp/.tmpgXR84S/hugr/hugr-passes/src/non_local.rs:32
  function nonlocal_edges (0 -> 1 generic types) in /tmp/.tmpgXR84S/hugr/hugr-passes/src/non_local.rs:14
  function nonlocal_edges (0 -> 1 generic types) in /tmp/.tmpgXR84S/hugr/hugr-passes/src/non_local.rs:14
  function partial_from_const (1 -> 2 generic types) in /tmp/.tmpgXR84S/hugr/hugr-passes/src/dataflow.rs:93

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

Failed in:
  Machine::prepopulate_df_inputs, previously in file /tmp/.tmpuOV2md/hugr-passes/src/dataflow/datalog.rs:51

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

Failed in:
  hugr_passes::const_fold::ConstantFoldPass::with_inputs now takes 3 parameters instead of 2, in /tmp/.tmpgXR84S/hugr/hugr-passes/src/const_fold.rs:82

--- failure trait_associated_type_added: non-sealed public trait added associated type without default value ---

Description:
A non-sealed trait has gained an associated type without a default value, which breaks downstream implementations of the trait
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#trait-new-item-no-default
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/trait_associated_type_added.ron

Failed in:
  trait associated type hugr_passes::dataflow::ConstLoader::Node in file /tmp/.tmpgXR84S/hugr/hugr-passes/src/dataflow.rs:63

--- failure trait_requires_more_generic_type_params: trait now requires more generic type parameters ---

Description:
A trait now requires more generic type parameters than it used to. Uses of this trait that supplied the previously-required number of generic types will be broken. To fix this, consider supplying default values for newly-added generic types.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#trait-new-parameter-no-default
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/trait_requires_more_generic_type_params.ron

Failed in:
  trait NonLocalEdgesError (0 -> 1 required generic types) in /tmp/.tmpgXR84S/hugr/hugr-passes/src/non_local.rs:26
  trait ConstLocation (0 -> 1 required generic types) in /tmp/.tmpgXR84S/hugr/hugr-passes/src/dataflow.rs:44

--- failure type_requires_more_generic_type_params: type now requires more generic type parameters ---

Description:
A type now requires more generic type parameters than it used to. Uses of this type that supplied the previously-required number of generic types will be broken. To fix this, consider supplying default values for newly-added generic types.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#trait-new-parameter-no-default
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/type_requires_more_generic_type_params.ron

Failed in:
  Enum NonLocalEdgesError (0 -> 1 required generic types) in /tmp/.tmpgXR84S/hugr/hugr-passes/src/non_local.rs:26
  Enum ConstLocation (0 -> 1 required generic types) in /tmp/.tmpgXR84S/hugr/hugr-passes/src/dataflow.rs:44
```

### ⚠ `hugr-cli` breaking changes

```text
--- 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.39.0/src/lints/enum_variant_missing.ron

Failed in:
  variant CliError::HUGRLoad, previously in file /tmp/.tmpuOV2md/hugr-cli/src/lib.rs:49

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

Failed in:
  field hugr_args of struct ValArgs, previously in file /tmp/.tmpuOV2md/hugr-cli/src/validate.rs:18
  field hugr_args of struct MermaidArgs, previously in file /tmp/.tmpuOV2md/hugr-cli/src/mermaid.rs:17

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

Failed in:
  enum hugr_cli::PackageOrHugr, previously in file /tmp/.tmpuOV2md/hugr-cli/src/lib.rs:83

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

Failed in:
  struct hugr_cli::HugrArgs, previously in file /tmp/.tmpuOV2md/hugr-cli/src/lib.rs:57
```

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

## `hugr-model`

<blockquote>

##
[0.18.0](hugr-model-v0.17.1...hugr-model-v0.18.0)
- 2025-03-14

### Bug Fixes

- Hugr-model using undeclared derive_more features
([#1940](#1940))

### New Features

- *(hugr-model)* [**breaking**] Add `read_from_reader` and
`write_to_writer` for streaming reads and writes.
([#1871](#1871))
- `hugr-model` AST ([#1953](#1953))

### Refactor

- *(hugr-model)* Reexport `bumpalo` from `hugr-model`
([#1870](#1870))
</blockquote>

## `hugr-core`

<blockquote>

##
[0.15.0](hugr-core-v0.14.4...hugr-core-v0.15.0)
- 2025-03-14

### New Features

- [**breaking**] Add associated type Node to HugrView
([#1932](#1932))
- Rewrite for inlining a single Call
([#1934](#1934))
- [**breaking**] replace `Lift` with `Barrier`
([#1952](#1952))
- `hugr-model` AST ([#1953](#1953))
- Add float <--> int bytecasting ops to conversions extension
([#1956](#1956))
- Add collections.static_array extension.
([#1964](#1964))
- [**breaking**] Generic HUGR serialization with envelopes
([#1958](#1958))

### Refactor

- [**breaking**] remove unused dependencies
([#1935](#1935))
- *(hugr-model)* Reexport `bumpalo` from `hugr-model`
([#1870](#1870))
</blockquote>

## `hugr-llvm`

<blockquote>

##
[0.15.0](hugr-llvm-v0.14.4...hugr-llvm-v0.15.0)
- 2025-03-14

### Bug Fixes

- Rename widen insta tests
([#1949](#1949))

### New Features

- [**breaking**] Add associated type Node to HugrView
([#1932](#1932))
- Emit `widen` ops from the int ops extension
([#1946](#1946))
- [**breaking**] replace `Lift` with `Barrier`
([#1952](#1952))
- *(hugr-llvm)* Emit narrow ops
([#1955](#1955))
- Add float <--> int bytecasting ops to conversions extension
([#1956](#1956))
- *(hugr-llvm)* Emit iu_to_s and is_to_u
([#1978](#1978))

### Refactor

- [**breaking**] remove unused dependencies
([#1935](#1935))
</blockquote>

## `hugr-passes`

<blockquote>

##
[0.15.0](hugr-passes-v0.14.4...hugr-passes-v0.15.0)
- 2025-03-14

### New Features

- [**breaking**] Add associated type Node to HugrView
([#1932](#1932))
- add separate DCE pass
([#1902](#1902))
- [**breaking**] replace `Lift` with `Barrier`
([#1952](#1952))
- [**breaking**] don't assume "main"-function in dataflow + constant
folding ([#1896](#1896))
</blockquote>

## `hugr`

<blockquote>

##
[0.15.0](hugr-v0.14.4...hugr-v0.15.0)
- 2025-03-14

### New Features

- add separate DCE pass
([#1902](#1902))
- [**breaking**] don't assume "main"-function in dataflow + constant
folding ([#1896](#1896))
- [**breaking**] Add associated type Node to HugrView
([#1932](#1932))
- Rewrite for inlining a single Call
([#1934](#1934))
- [**breaking**] replace `Lift` with `Barrier`
([#1952](#1952))
- `hugr-model` AST ([#1953](#1953))
- Add float <--> int bytecasting ops to conversions extension
([#1956](#1956))
- Add collections.static_array extension.
([#1964](#1964))
- [**breaking**] Generic HUGR serialization with envelopes
([#1958](#1958))

### Refactor

- *(hugr-model)* Reexport `bumpalo` from `hugr-model`
([#1870](#1870))
- [**breaking**] remove unused dependencies
([#1935](#1935))
</blockquote>

## `hugr-cli`

<blockquote>

##
[0.15.0](hugr-cli-v0.14.4...hugr-cli-v0.15.0)
- 2025-03-14

### New Features

- [**breaking**] Generic HUGR serialization with envelopes
([#1958](#1958))
</blockquote>


</p></details>

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

---------

Co-authored-by: Agustín Borgna <[email protected]>
This was referenced Mar 18, 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.

Separate "dead-code-elimination" from constant folding
2 participants