Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore!: Add associated type Node to HugrView #1932

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

lmondada
Copy link
Contributor

@lmondada lmondada commented Feb 24, 2025

closes #1927

Yey, this is a fun one 🫠

This makes HugrView general over the Node type. Note that HugrMut and all operations that mutate hugrs still only act on the node type Node.

I suggest once this is merged in that we add a .git-blame-ignore-revs file to simplify future git blames:

# Commits to be ignored by git blame

# Add Node associated type to HugrView (large mechanical change)
<commit of this PR on main>

BREAKING CHANGE: HugrView now has a Node associated type. Make your code generic over the node type where you can, replacing Node with H::Node. Otherwise, use the type bound H: HugrView<Node = Node>.

@lmondada lmondada requested a review from a team as a code owner February 24, 2025 17:54
@lmondada lmondada requested a review from cqc-alec February 24, 2025 17:54
Copy link

codecov bot commented Feb 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.67%. Comparing base (929edb6) to head (1a24227).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1932      +/-   ##
==========================================
- Coverage   83.71%   83.67%   -0.04%     
==========================================
  Files         196      196              
  Lines       37533    37168     -365     
  Branches    34346    33981     -365     
==========================================
- Hits        31422    31102     -320     
+ Misses       4328     4285      -43     
+ Partials     1783     1781       -2     
Flag Coverage Δ
python 92.34% <ø> (ø)

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.

@hugrbot
Copy link
Collaborator

hugrbot commented Feb 24, 2025

This PR contains breaking changes to the public Rust API.

cargo-semver-checks summary

--- 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 /home/runner/work/hugr/hugr/PR_BRANCH/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 /home/runner/work/hugr/hugr/PR_BRANCH/hugr-core/src/hugr/views/sibling_subgraph.rs:234

--- 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 /home/runner/work/hugr/hugr/PR_BRANCH/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::to_pg_index in file /home/runner/work/hugr/hugr/PR_BRANCH/hugr-core/src/hugr/internal.rs:42
trait method hugr_core::hugr::internal::HugrInternals::to_node in file /home/runner/work/hugr/hugr/PR_BRANCH/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 /home/runner/work/hugr/hugr/PR_BRANCH/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 /home/runner/work/hugr/hugr/PR_BRANCH/hugr-core/src/hugr/views/petgraph.rs:187

--- 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 /home/runner/work/hugr/hugr/PR_BRANCH/hugr-passes/src/non_local.rs:32
function ensure_no_nonlocal_edges (0 -> 1 generic types) in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-passes/src/non_local.rs:32
function nonlocal_edges (0 -> 1 generic types) in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-passes/src/non_local.rs:14
function nonlocal_edges (0 -> 1 generic types) in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-passes/src/non_local.rs:14
function partial_from_const (1 -> 2 generic types) in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-passes/src/dataflow.rs:93

--- 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 /home/runner/work/hugr/hugr/PR_BRANCH/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 /home/runner/work/hugr/hugr/PR_BRANCH/hugr-passes/src/non_local.rs:26
trait ConstLocation (0 -> 1 required generic types) in /home/runner/work/hugr/hugr/PR_BRANCH/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 /home/runner/work/hugr/hugr/PR_BRANCH/hugr-passes/src/non_local.rs:26
Enum ConstLocation (0 -> 1 required generic types) in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-passes/src/dataflow.rs:44

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.

The Node type should be an associated type of HugrView
2 participants