Skip to content

Conversation

acl-cqc
Copy link
Contributor

@acl-cqc acl-cqc commented Sep 16, 2025

Follows #2529

  • Add insert_link_hugr and insert_link_view taking a node under which to add the entrypoint
  • Add reachability analysis and NewFuncHandling::AddIfReached,ErrorIfReached
  • Extend NameLinkingPolicy to allow setting how to handle to new names in the source Hugr, and a switch to filter out unreachable private funcs

TODO

  • Tests!!
  • What about when the entrypoint is one of the functions of the source Hugr? Probably this should work OK (assuming the parent is the target's module_root, then basically just forces that function to be a reachable one? Or should we e.g. force adding it even contrary to the signature-conflict/multiple-impl handling used for other functions?)

closes #2517

Copy link

codecov bot commented Sep 16, 2025

Codecov Report

❌ Patch coverage is 66.66667% with 65 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.91%. Comparing base (5ca0e5f) to head (e5e1ad2).

Files with missing lines Patch % Lines
hugr-core/src/hugr/linking.rs 57.25% 55 Missing and 1 partial ⚠️
hugr-core/src/call_graph.rs 85.93% 7 Missing and 2 partials ⚠️
Additional details and impacted files
@@                Coverage Diff                @@
##           acl/link_hugr    #2555      +/-   ##
=================================================
- Coverage          83.00%   82.91%   -0.10%     
=================================================
  Files                254      255       +1     
  Lines              47781    47933     +152     
  Branches           43292    43444     +152     
=================================================
+ Hits               39663    39743      +80     
- Misses              6055     6124      +69     
- Partials            2063     2066       +3     
Flag Coverage Δ
python 91.42% <ø> (ø)
rust 82.03% <66.66%> (-0.11%) ⬇️

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 Sep 16, 2025

This PR contains breaking changes to the public Rust API.
Please deprecate the old API instead (if possible), or mark the PR with a ! to indicate a breaking change.

cargo-semver-checks summary

--- 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.43.0/src/lints/enum_no_repr_variant_discriminant_changed.ron

Failed in:
variant NewFuncHandling::Add 1 -> 2 in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-core/src/hugr/linking.rs:351

--- 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.43.0/src/lints/enum_variant_added.ron

Failed in:
variant NameLinkingError:NoNewNames in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-core/src/hugr/linking.rs:408

/// If the new function is reachable, then add it (as per [Self::Add]);
/// otherwise, skip it.
AddIfReached,
// /// If the new function is reachable, then add it but make it [Private];
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'll remove this, it can follow in another PR

@acl-cqc acl-cqc changed the title feat: Add insert_link_hugr to add entrypoint subtree AND link feat: (WIP) Add insert_link_hugr to add entrypoint subtree AND link Sep 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.

2 participants