Skip to content

Conversation

@aborgna-q
Copy link
Collaborator

@aborgna-q aborgna-q commented May 6, 2025

Removes the dependency on base_hugr when validating views.
Now the validation code runs directly on any given HugrView.

To make this work I had to add <N: HugrNode> parameters to multiple error types.
This makes sense, as now validating a non-Node hugr will return errors with the correct indices.

BREAKING CHANGE: Added node parameters to multiple error types, including the one returned by HugrView::validate.

@codecov
Copy link

codecov bot commented May 6, 2025

Codecov Report

Attention: Patch coverage is 95.28302% with 5 lines in your changes missing coverage. Please review.

Project coverage is 82.09%. Comparing base (531fe69) to head (f3320e3).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
hugr-core/src/extension/resolution.rs 33.33% 2 Missing ⚠️
hugr-core/src/ops/validate.rs 91.30% 2 Missing ⚠️
hugr-core/src/hugr/views/rerooted.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2155      +/-   ##
==========================================
- Coverage   82.10%   82.09%   -0.01%     
==========================================
  Files         227      227              
  Lines       39805    39802       -3     
  Branches    35904    35901       -3     
==========================================
- Hits        32682    32677       -5     
- Misses       5301     5303       +2     
  Partials     1822     1822              
Flag Coverage Δ
python 85.64% <ø> (ø)
rust 81.71% <95.28%> (-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.

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

@hugrbot
Copy link
Collaborator

hugrbot commented May 6, 2025

This PR contains breaking changes to the public Rust API.

cargo-semver-checks summary

--- 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:
ValidateOp::validity_flags (0 -> 1 generic types) in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-core/src/ops.rs:493
ValidateOp::validate_op_children (0 -> 1 generic types) in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-core/src/ops.rs:499

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

Failed in:
trait ChildrenValidationError (0 -> 1 required generic types) in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-core/src/ops/validate.rs:172
trait InterGraphEdgeError (0 -> 1 required generic types) in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-core/src/hugr/validate.rs:703
trait EdgeValidationError (0 -> 1 required generic types) in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-core/src/ops/validate.rs:222
trait ChildrenEdgeData (0 -> 1 required generic types) in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-core/src/ops/validate.rs:245
trait ValidationError (0 -> 1 required generic types) in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-core/src/hugr/validate.rs:575
trait ValidationError (0 -> 1 required generic types) in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-core/src/hugr/validate.rs:575
trait OpValidityFlags (0 -> 1 required generic types) in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-core/src/ops/validate.rs:26
trait OpaqueOpError (0 -> 1 required generic types) in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-core/src/ops/custom.rs:320

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

Failed in:
Enum ChildrenValidationError (0 -> 1 required generic types) in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-core/src/ops/validate.rs:172
Enum InterGraphEdgeError (0 -> 1 required generic types) in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-core/src/hugr/validate.rs:703
Enum EdgeValidationError (0 -> 1 required generic types) in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-core/src/ops/validate.rs:222
Struct ChildrenEdgeData (0 -> 1 required generic types) in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-core/src/ops/validate.rs:245
Enum ValidationError (0 -> 1 required generic types) in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-core/src/hugr/validate.rs:575
Enum ValidationError (0 -> 1 required generic types) in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-core/src/hugr/validate.rs:575
Struct OpValidityFlags (0 -> 1 required generic types) in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-core/src/ops/validate.rs:26
Enum OpaqueOpError (0 -> 1 required generic types) in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-core/src/ops/custom.rs:320

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

Failed in:
trait ValidatePassError (1 -> 2 required generic types) in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-passes/src/composable.rs:116

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

Failed in:
Enum ValidatePassError (1 -> 2 required generic types) in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-passes/src/composable.rs:116

@aborgna-q aborgna-q added this to the hugr-rs 0̶.̶1̶6̶ 0.20 milestone May 6, 2025
@aborgna-q aborgna-q force-pushed the ab/validate-any-view branch 2 times, most recently from 8806a2e to 163fe0a Compare May 7, 2025 11:13
@aborgna-q aborgna-q marked this pull request as ready for review May 7, 2025 11:53
@aborgna-q aborgna-q requested a review from a team as a code owner May 7, 2025 11:53
@aborgna-q aborgna-q requested review from zrho and removed request for a team May 7, 2025 11:53
Base automatically changed from ab/entrypoints to main May 8, 2025 12:30
@aborgna-q aborgna-q force-pushed the ab/validate-any-view branch from 163fe0a to 04d804a Compare May 8, 2025 12:42
@aborgna-q
Copy link
Collaborator Author

The changes here are mostly just noise due to adding the extra node type param to the errors. There is no logic change.

@aborgna-q aborgna-q force-pushed the ab/validate-any-view branch from 04d804a to f3320e3 Compare May 8, 2025 13:36
@aborgna-q aborgna-q added this pull request to the merge queue May 8, 2025
Merged via the queue into main with commit 679390c May 8, 2025
27 checks passed
@aborgna-q aborgna-q deleted the ab/validate-any-view branch May 8, 2025 14:18
This was referenced May 29, 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.

4 participants