Skip to content

feat: Add non-generic with_scope method for composable passes#2910

Merged
aborgna-q merged 2 commits intomainfrom
ab/with_scope-generic
Mar 2, 2026
Merged

feat: Add non-generic with_scope method for composable passes#2910
aborgna-q merged 2 commits intomainfrom
ab/with_scope-generic

Conversation

@aborgna-q
Copy link
Copy Markdown
Collaborator

Adds a non-generic extension trait for ComposablePass so we can call with_scope without having to specify the hugr generic being used.

Renames ComposablePass::with_scope to ComposablePass::with_scope_internal. This is not a breaking change, since the method has not been published yet.

@aborgna-q aborgna-q requested a review from acl-cqc February 27, 2026 14:50
@aborgna-q aborgna-q requested a review from a team as a code owner February 27, 2026 14:50
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 27, 2026

Codecov Report

❌ Patch coverage is 0% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.83%. Comparing base (847b864) to head (64f021d).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
hugr-passes/src/composable.rs 0.00% 14 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2910      +/-   ##
==========================================
+ Coverage   83.81%   83.83%   +0.01%     
==========================================
  Files         269      269              
  Lines       53953    54021      +68     
  Branches    47920    47974      +54     
==========================================
+ Hits        45223    45286      +63     
- Misses       6315     6320       +5     
  Partials     2415     2415              
Flag Coverage Δ
python 88.65% <ø> (-0.01%) ⬇️
rust 83.22% <0.00%> (+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
Copy Markdown
Collaborator

hugrbot commented Feb 27, 2026

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
    Building hugr v0.25.6 (current)
     Built [  45.281s] (current)
   Parsing hugr v0.25.6 (current)
    Parsed [   0.005s] (current)
  Building hugr v0.25.6 (baseline)
     Built [  22.268s] (baseline)
   Parsing hugr v0.25.6 (baseline)
    Parsed [   0.005s] (baseline)
  Checking hugr v0.25.6 -> v0.25.6 (assume minor change)
   Checked [   0.013s] 196 checks: 196 pass, 49 skip
   Summary no semver update required
  Finished [  69.512s] hugr
  Building hugr-cli v0.25.6 (current)
     Built [  34.029s] (current)
   Parsing hugr-cli v0.25.6 (current)
    Parsed [   0.009s] (current)
  Building hugr-cli v0.25.6 (baseline)
     Built [  20.611s] (baseline)
   Parsing hugr-cli v0.25.6 (baseline)
    Parsed [   0.009s] (baseline)
  Checking hugr-cli v0.25.6 -> v0.25.6 (assume minor change)
   Checked [   0.017s] 196 checks: 196 pass, 49 skip
   Summary no semver update required
  Finished [  56.276s] hugr-cli
  Building hugr-core v0.25.6 (current)
     Built [  17.553s] (current)
   Parsing hugr-core v0.25.6 (current)
    Parsed [   0.077s] (current)
  Building hugr-core v0.25.6 (baseline)
     Built [  17.378s] (baseline)
   Parsing hugr-core v0.25.6 (baseline)
    Parsed [   0.074s] (baseline)
  Checking hugr-core v0.25.6 -> v0.25.6 (assume minor change)
   Checked [   0.239s] 196 checks: 196 pass, 49 skip
   Summary no semver update required
  Finished [  36.656s] hugr-core
  Building hugr-llvm v0.25.6 (current)
     Built [  16.368s] (current)
   Parsing hugr-llvm v0.25.6 (current)
    Parsed [   0.012s] (current)
  Building hugr-llvm v0.25.6 (baseline)
     Built [  16.298s] (baseline)
   Parsing hugr-llvm v0.25.6 (baseline)
    Parsed [   0.012s] (baseline)
  Checking hugr-llvm v0.25.6 -> v0.25.6 (assume minor change)
   Checked [   0.043s] 196 checks: 196 pass, 49 skip
   Summary no semver update required
  Finished [  34.153s] hugr-llvm
  Building hugr-model v0.25.6 (current)
     Built [   5.417s] (current)
   Parsing hugr-model v0.25.6 (current)
    Parsed [   0.017s] (current)
  Building hugr-model v0.25.6 (baseline)
     Built [   5.572s] (baseline)
   Parsing hugr-model v0.25.6 (baseline)
    Parsed [   0.016s] (baseline)
  Checking hugr-model v0.25.6 -> v0.25.6 (assume minor change)
   Checked [   0.032s] 196 checks: 196 pass, 49 skip
   Summary no semver update required
  Finished [  11.872s] hugr-model
  Building hugr-passes v0.25.6 (current)
     Built [  16.173s] (current)
   Parsing hugr-passes v0.25.6 (current)
    Parsed [   0.026s] (current)
  Building hugr-passes v0.25.6 (baseline)
     Built [  16.124s] (baseline)
   Parsing hugr-passes v0.25.6 (baseline)
    Parsed [   0.024s] (baseline)
  Checking hugr-passes v0.25.6 -> v0.25.6 (assume minor change)
   Checked [   0.041s] 196 checks: 195 pass, 1 fail, 0 warn, 49 skip

--- failure trait_method_missing: pub trait method removed or renamed ---

Description:
A trait method is no longer callable, and may have been renamed or removed entirely.
      ref: https://doc.rust-lang.org/cargo/reference/semver.html#major-any-change-to-trait-item-signatures
     impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/trait_method_missing.ron

Failed in:
method with_scope of trait ComposablePass, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-passes/src/composable.rs:39
method with_scope of trait ComposablePass, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-passes/src/composable.rs:39

   Summary semver requires new major version: 1 major and 0 minor checks failed
  Finished [  33.626s] hugr-passes
  Building hugr-persistent v0.4.6 (current)
     Built [  12.424s] (current)
   Parsing hugr-persistent v0.4.6 (current)
    Parsed [   0.011s] (current)
  Building hugr-persistent v0.4.6 (baseline)
     Built [  21.405s] (baseline)
   Parsing hugr-persistent v0.4.6 (baseline)
    Parsed [   0.008s] (baseline)
  Checking hugr-persistent v0.4.6 -> v0.4.6 (assume minor change)
   Checked [   0.015s] 196 checks: 196 pass, 49 skip
   Summary no semver update required
  Finished [  34.903s] hugr-persistent

Copy link
Copy Markdown
Contributor

@acl-cqc acl-cqc 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, thanks, but can we just not add the default?

@aborgna-q aborgna-q enabled auto-merge March 2, 2026 16:09
@aborgna-q aborgna-q added this pull request to the merge queue Mar 2, 2026
Merged via the queue into main with commit 437b936 Mar 2, 2026
27 of 28 checks passed
@aborgna-q aborgna-q deleted the ab/with_scope-generic branch March 2, 2026 16:18
@hugrbot hugrbot mentioned this pull request Mar 2, 2026
github-merge-queue bot pushed a commit that referenced this pull request Mar 6, 2026
## 🤖 New release

* `hugr-model`: 0.25.6 -> 0.25.7 (✓ API compatible changes)
* `hugr-core`: 0.25.6 -> 0.25.7 (✓ API compatible changes)
* `hugr-llvm`: 0.25.6 -> 0.25.7 (✓ API compatible changes)
* `hugr-passes`: 0.25.6 -> 0.25.7 (✓ API compatible changes)
* `hugr-persistent`: 0.4.6 -> 0.4.7 (✓ API compatible changes)
* `hugr`: 0.25.6 -> 0.25.7 (✓ API compatible changes)
* `hugr-cli`: 0.25.6 -> 0.25.7 (✓ API compatible changes)

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

## `hugr-model`

<blockquote>

##
[0.25.6](hugr-model-v0.25.5...hugr-model-v0.25.6)
- 2026-02-20

### New Features

- Remove size limitation for binary envelopes
([#2880](#2880))
</blockquote>

## `hugr-core`

<blockquote>

##
[0.25.7](hugr-core-v0.25.6...hugr-core-v0.25.7)
- 2026-03-06

### Documentation

- added examples in docs srtring
([#2920](#2920))
</blockquote>

## `hugr-llvm`

<blockquote>

##
[0.25.6](hugr-llvm-v0.25.5...hugr-llvm-v0.25.6)
- 2026-02-20

### New Features

- Add error context when lowering hugrs to LLVM
([#2869](#2869))
</blockquote>

## `hugr-passes`

<blockquote>

##
[0.25.7](hugr-passes-v0.25.6...hugr-passes-v0.25.7)
- 2026-03-06

### Documentation

- added examples in docs srtring
([#2920](#2920))

### New Features

- Define pass application scopes
([#2772](#2772))
- Modify dead code elimination pass to remove unreachable basic blocks
([#2884](#2884))
- Add non-generic `with_scope` method for composable passes
([#2910](#2910))
- update passes to use PassScope where non-breaking
([#2836](#2836))
</blockquote>

## `hugr-persistent`

<blockquote>

##
[0.4.0](hugr-persistent-v0.3.4...hugr-persistent-v0.4.0)
- 2025-12-22

### New Features

- [**breaking**] Remove `RootCheckable`
([#2704](#2704))
- [**breaking**] Bump MSRV to Rust 1.89
([#2747](#2747))
- [**breaking**] Type-safe access for node metadata
([#2755](#2755))

### Refactor

- [**breaking**] Remove multiple deprecated definitions
([#2751](#2751))
</blockquote>

## `hugr`

<blockquote>

##
[0.25.7](hugr-v0.25.6...hugr-v0.25.7)
- 2026-03-06

### Documentation

- added examples in docs srtring
([#2920](#2920))

### New Features

- Define pass application scopes
([#2772](#2772))
- Modify dead code elimination pass to remove unreachable basic blocks
([#2884](#2884))
- Add non-generic `with_scope` method for composable passes
([#2910](#2910))
- update passes to use PassScope where non-breaking
([#2836](#2836))
</blockquote>

## `hugr-cli`

<blockquote>

##
[0.25.6](hugr-cli-v0.25.5...hugr-cli-v0.25.6)
- 2026-02-20

### New Features

- Add s expression format to envelope formats
([#2864](#2864))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).
@hugrbot hugrbot mentioned this pull request Mar 9, 2026
github-merge-queue bot pushed a commit to Quantinuum/tket2 that referenced this pull request Mar 23, 2026
Adds support for `PassScope`s in the pass definitions. See
Quantinuum/hugr#2772.

~Requires a hugr release with the `PassScope` definition and
Quantinuum/hugr#2910

~Many of these also call other passes from `hugr_passes`. While we pass
the scope config along, proper support requires
Quantinuum/hugr#2836 and
Quantinuum/hugr#2871

This is a rust-only change, the python interface will follow up.

BREAKING CHANGE: Multiple unit-like pass structs must now be constructed
using a `::default()` call instead.
BREAKING CHANGE: `QSystemPass` is now a `ComposablePass`. Import the
trait to call `run`.
BREAKING CHANGE: `QSystemPass` no longer implements `Copy`.
BREAKING CHANGE: Renamed
`tket_qsystem::extension::qsystem::lower_tket_op` to `lower_tket_ops`.
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