Skip to content

Conversation

@acl-cqc
Copy link
Contributor

@acl-cqc acl-cqc commented Nov 18, 2025

Respin of #2531, marking the node/edge enums in the new StaticGraph as non-exhaustive and adding Consts + LoadConstants.

(Lukas originally planned to make something like this to reflect references from Terms to functions, and non-exhaustive allows extending this StaticGraph for that purpose - if we do go that way, however, I have a different plan, can describe if relevant. Rather I think non-exhaustive is just a reasonable allowance for future extension to new use-cases hopefully without damaging existing use-cases.)

This is taken from #2555, i.e. which uses it (although there it is still called CallGraph in hugr-core).

Naming: could be ModuleGraph ?? Other ideas welcome.

I will add a test with some Consts + use of out_edges (tho will be supplied in #2555 !)

@codecov
Copy link

codecov bot commented Nov 18, 2025

Codecov Report

❌ Patch coverage is 92.56198% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.49%. Comparing base (a73f871) to head (d0a40b3).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
hugr-core/src/module_graph.rs 95.28% 5 Missing ⚠️
hugr-passes/src/dead_funcs.rs 57.14% 2 Missing and 1 partial ⚠️
hugr-passes/src/inline_funcs.rs 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2698      +/-   ##
==========================================
- Coverage   83.53%   83.49%   -0.05%     
==========================================
  Files         264      265       +1     
  Lines       51538    51643     +105     
  Branches    47006    47108     +102     
==========================================
+ Hits        43051    43117      +66     
- Misses       6114     6154      +40     
+ Partials     2373     2372       -1     
Flag Coverage Δ
python 91.53% <ø> (+0.20%) ⬆️
rust 82.71% <92.56%> (-0.07%) ⬇️

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 marked this pull request as ready for review November 18, 2025 12:13
@acl-cqc acl-cqc requested a review from a team as a code owner November 18, 2025 12:13
@acl-cqc acl-cqc requested a review from mark-koch November 18, 2025 12:13
Copy link
Contributor

@mark-koch mark-koch 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 to me 👍

In terms of naming, I think I slightly prefer ModuleGraph since it only contains nodes on module level and not all static edges are included (e.g. consts inside functions)

}

/// Details the [`FuncDefn`]s, [`FuncDecl`]s and module-level [`Const`]s in a Hugr,
/// in a Hugr, along with the [`Call`]s, [`LoadFunction`]s, and [`LoadConstant`]s connecting them.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// in a Hugr, along with the [`Call`]s, [`LoadFunction`]s, and [`LoadConstant`]s connecting them.
/// along with the [`Call`]s, [`LoadFunction`]s, and [`LoadConstant`]s connecting them.

}

impl<N: HugrNode> StaticGraph<N> {
/// Makes a new `CallGraph` for a Hugr.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// Makes a new `CallGraph` for a Hugr.
/// Makes a new `StaticGraph` for a Hugr.

///
/// If the node is not recognised as a function or the entrypoint,
/// for example if it is a [`Const`](OpType::Const), the iterator will be empty.
pub fn out_edges(&self, n: N) -> impl Iterator<Item = (&StaticEdge<N>, &StaticNode<N>)> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we also want an in_edges method?

@acl-cqc acl-cqc added this pull request to the merge queue Nov 18, 2025
Merged via the queue into main with commit 86564e5 Nov 18, 2025
30 checks passed
@acl-cqc acl-cqc deleted the acl/static_graph branch November 18, 2025 18:02
@hugrbot hugrbot mentioned this pull request Nov 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.

3 participants