From 479961bf50768113d2fffd41519483d8f4666c85 Mon Sep 17 00:00:00 2001 From: Seyon Sivarajah Date: Wed, 9 Oct 2024 16:04:02 +0100 Subject: [PATCH] feat: return replaced ops from lowering drive-by: whitespace trimming in yml --- .github/workflows/ci-py.yml | 4 ++-- hugr-passes/src/lower.rs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-py.yml b/.github/workflows/ci-py.yml index 8fca5e049..6f9e58e78 100644 --- a/.github/workflows/ci-py.yml +++ b/.github/workflows/ci-py.yml @@ -58,7 +58,7 @@ jobs: enable-cache: true - name: Install Python run: uv python install ${{ matrix.python-version }} - + - name: Setup dependencies. Fail if the lockfile is outdated. run: uv sync --locked @@ -106,7 +106,7 @@ jobs: - { py: '3.12', coverage: true } steps: - uses: actions/checkout@v4 - + - name: Set up uv uses: astral-sh/setup-uv@v3 with: diff --git a/hugr-passes/src/lower.rs b/hugr-passes/src/lower.rs index a7e75b355..b799638fc 100644 --- a/hugr-passes/src/lower.rs +++ b/hugr-passes/src/lower.rs @@ -55,7 +55,7 @@ pub enum LowerError { pub fn lower_ops( hugr: &mut impl HugrMut, lowering: impl Fn(&OpType) -> Option, -) -> Result, LowerError> { +) -> Result, LowerError> { let replacements = hugr .nodes() .filter_map(|node| { @@ -69,9 +69,9 @@ pub fn lower_ops( .map(|(node, replacement)| { let subcirc = SiblingSubgraph::try_from_nodes([node], hugr)?; let rw = subcirc.create_simple_replacement(hugr, replacement)?; - // TODO return weights once https://github.com/CQCL/hugr/issues/476 is done. - hugr.apply_rewrite(rw)?; - Ok(node) + let mut repls = hugr.apply_rewrite(rw)?; + debug_assert_eq!(repls.len(), 1); + Ok(repls.remove(0)) }) .collect() }