From 580739d3e75c6fff612579ba39a3183a936fb39c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Borgna?= Date: Fri, 6 Mar 2026 10:42:18 +0000 Subject: [PATCH 1/4] feat!: Make `WithScope` a supertrait of `ComposablePass` --- hugr-passes/src/composable.rs | 57 +++++++++++++----------- hugr-passes/src/const_fold.rs | 9 ++++ hugr-passes/src/dead_code.rs | 6 ++- hugr-passes/src/dead_funcs.rs | 15 ++++--- hugr-passes/src/inline_dfgs.rs | 5 ++- hugr-passes/src/monomorphize.rs | 6 ++- hugr-passes/src/non_local.rs | 5 ++- hugr-passes/src/normalize_cfgs.rs | 6 ++- hugr-passes/src/redundant_order_edges.rs | 13 +++--- hugr-passes/src/replace_types.rs | 25 ++++++----- hugr-passes/src/untuple.rs | 5 ++- 11 files changed, 96 insertions(+), 56 deletions(-) diff --git a/hugr-passes/src/composable.rs b/hugr-passes/src/composable.rs index 857eec4c8..5e0740172 100644 --- a/hugr-passes/src/composable.rs +++ b/hugr-passes/src/composable.rs @@ -7,7 +7,6 @@ mod scope; -use hugr_core::Hugr; pub use scope::{InScope, PassScope, Preserve}; use std::{error::Error, marker::PhantomData}; @@ -23,7 +22,7 @@ use itertools::Either; /// idempotent (i.e. such that after running a pass, rerunning it immediately has /// no further effect). However this is *not* a requirement, e.g. a sequence of /// idempotent passes created by [ComposablePass::then] may not be idempotent itself. -pub trait ComposablePass: Sized { +pub trait ComposablePass: WithScope + Sized { /// Error thrown by this pass. type Error: Error; /// Result returned by this pass. @@ -32,13 +31,6 @@ pub trait ComposablePass: Sized { /// Run the pass on the given HUGR. fn run(&self, hugr: &mut H) -> Result; - /// Set the scope configuration used to run the pass. - /// - /// See [`PassScope`] for more details. - /// - /// Since `hugr >=0.26.0`, passes must implement this to respect the scope configuration. - fn with_scope_internal(self, scope: impl Into) -> Self; - /// Apply a function to the error type of this pass, returning a new /// [`ComposablePass`] that has the same result type. fn map_err( @@ -79,12 +71,17 @@ pub trait ComposablePass: Sized { let res2 = self.1.run(hugr).map_err(E::from_second)?; Ok((res1, res2)) } - - fn with_scope_internal(self, scope: impl Into) -> Self { + } + impl WithScope for Sequence + where + P1: WithScope, + P2: WithScope, + { + fn with_scope(self, scope: impl Into) -> Self { let scope = scope.into(); Self( - self.0.with_scope_internal(scope.clone()), - self.1.with_scope_internal(scope), + self.0.with_scope(scope.clone()), + self.1.with_scope(scope), PhantomData, ) } @@ -100,15 +97,11 @@ pub trait WithScope { /// Set the scope configuration used to run the pass. /// /// See [`PassScope`] for more details. + /// + /// Since `hugr >=0.26.0`, passes must implement this to respect the scope configuration. fn with_scope(self, scope: impl Into) -> Self; } -impl> WithScope for P { - fn with_scope(self, scope: impl Into) -> Self { - self.with_scope_internal(scope) - } -} - /// Trait for combining the error types from two different passes /// into a single error. pub trait ErrorCombiner: Error { @@ -165,9 +158,13 @@ impl, H: HugrMut, E: Error, F: Fn(P::Error) -> E> Composabl fn run(&self, hugr: &mut H) -> Result { self.0.run(hugr).map_err(&self.1) } +} - fn with_scope_internal(self, scope: impl Into) -> Self { - Self(self.0.with_scope_internal(scope), self.1, PhantomData) +impl, H: HugrMut, E: Error, F: Fn(P::Error) -> E> WithScope + for ErrMapper +{ + fn with_scope(self, scope: impl Into) -> Self { + Self(self.0.with_scope(scope), self.1, PhantomData) } } @@ -247,9 +244,11 @@ where })?; Ok(res) } +} - fn with_scope_internal(self, scope: impl Into) -> Self { - Self(self.0.with_scope_internal(scope), self.1) +impl, H: HugrMut> WithScope for ValidatingPass { + fn with_scope(self, scope: impl Into) -> Self { + Self(self.0.with_scope(scope), self.1) } } @@ -288,12 +287,18 @@ impl< res.then(|| self.1.run(hugr).map_err(ErrorCombiner::from_second)) .transpose() } +} - fn with_scope_internal(self, scope: impl Into) -> Self { +impl WithScope for IfThen +where + A: WithScope, + B: WithScope, +{ + fn with_scope(self, scope: impl Into) -> Self { let scope = scope.into(); Self( - self.0.with_scope_internal(scope.clone()), - self.1.with_scope_internal(scope), + self.0.with_scope(scope.clone()), + self.1.with_scope(scope), PhantomData, ) } diff --git a/hugr-passes/src/const_fold.rs b/hugr-passes/src/const_fold.rs index db31434c9..7b1a2ec72 100644 --- a/hugr-passes/src/const_fold.rs +++ b/hugr-passes/src/const_fold.rs @@ -15,6 +15,8 @@ use hugr_core::{ }; use value_handle::ValueHandle; +use crate::PassScope; +use crate::composable::WithScope; use crate::dataflow::{ ConstLoader, ConstLocation, DFContext, Machine, PartialValue, TailLoopTermination, partial_from_const, @@ -215,6 +217,13 @@ impl + 'static> ComposablePass for ConstantFoldPass { } } +impl WithScope for ConstantFoldPass { + fn with_scope(self, _scope: impl Into) -> Self { + // TODO: Set the scope configuration + self + } +} + /// Exhaustively apply constant folding to a HUGR. /// If the Hugr's entrypoint is its [`Module`], assumes all [`FuncDefn`] children are reachable. /// diff --git a/hugr-passes/src/dead_code.rs b/hugr-passes/src/dead_code.rs index b91c4e8e5..42174b78f 100644 --- a/hugr-passes/src/dead_code.rs +++ b/hugr-passes/src/dead_code.rs @@ -6,6 +6,7 @@ use std::collections::{HashMap, HashSet, VecDeque}; use std::fmt::{Debug, Display, Formatter}; use std::sync::Arc; +use crate::composable::WithScope; use crate::{ComposablePass, PassScope}; /// Configuration for Dead Code Elimination pass @@ -212,12 +213,15 @@ impl ComposablePass for DeadCodeElimPass { } Ok(()) } +} - fn with_scope_internal(mut self, scope: impl Into) -> Self { +impl WithScope for DeadCodeElimPass { + fn with_scope(mut self, scope: impl Into) -> Self { self.scope = Some(scope.into()); self } } + #[cfg(test)] mod test { use std::sync::Arc; diff --git a/hugr-passes/src/dead_funcs.rs b/hugr-passes/src/dead_funcs.rs index 2862e06e9..25bc23377 100644 --- a/hugr-passes/src/dead_funcs.rs +++ b/hugr-passes/src/dead_funcs.rs @@ -11,6 +11,8 @@ use hugr_core::{ use itertools::Either; use petgraph::visit::{Dfs, Walker}; +use crate::PassScope; +use crate::composable::WithScope; use crate::{ ComposablePass, PassScope, composable::{Preserve, ValidatePassError, validate_if_test}, @@ -92,12 +94,6 @@ impl> ComposablePass for RemoveDeadFuncsPass { type Error = RemoveDeadFuncsError; type Result = (); - /// Overrides any entrypoints set by a call to [Self::with_module_entry_points]. - fn with_scope_internal(mut self, scope: impl Into) -> Self { - self.entry_points = Either::Right(scope.into()); - self - } - fn run(&self, hugr: &mut H) -> Result<(), RemoveDeadFuncsError> { let mut entry_points = Vec::new(); match &self.entry_points { @@ -161,6 +157,13 @@ impl> ComposablePass for RemoveDeadFuncsPass { } } +impl WithScope for RemoveDeadFuncsPass { + fn with_scope(mut self, scope: impl Into) -> Self { + self.entry_points = Either::Right(scope.into()); + self + } +} + /// Deletes from the Hugr any functions that are not used by either `Call` or /// `LoadFunction` nodes in reachable parts. /// diff --git a/hugr-passes/src/inline_dfgs.rs b/hugr-passes/src/inline_dfgs.rs index 48e8f90c9..273b40bcd 100644 --- a/hugr-passes/src/inline_dfgs.rs +++ b/hugr-passes/src/inline_dfgs.rs @@ -7,6 +7,7 @@ use hugr_core::hugr::{ }; use itertools::Itertools; +use crate::composable::WithScope; use crate::{ComposablePass, PassScope}; /// Inlines all DFG nodes nested below the entrypoint. @@ -44,8 +45,10 @@ impl ComposablePass for InlineDFGsPass { } Ok(()) } +} - fn with_scope_internal(mut self, scope: impl Into) -> Self { +impl WithScope for InlineDFGsPass { + fn with_scope(mut self, scope: impl Into) -> Self { self.scope = scope.into(); self } diff --git a/hugr-passes/src/monomorphize.rs b/hugr-passes/src/monomorphize.rs index 8669481fa..bb572cf02 100644 --- a/hugr-passes/src/monomorphize.rs +++ b/hugr-passes/src/monomorphize.rs @@ -13,7 +13,7 @@ use hugr_core::{ use hugr_core::hugr::{HugrView, OpType, hugrmut::HugrMut}; use itertools::Itertools as _; -use crate::composable::{ValidatePassError, validate_if_test}; +use crate::composable::{ValidatePassError, WithScope, validate_if_test}; use crate::{ComposablePass, PassScope}; /// Replaces calls to polymorphic functions with calls to new monomorphic @@ -223,8 +223,10 @@ impl> ComposablePass for MonomorphizePass { }; Ok(()) } +} - fn with_scope_internal(mut self, scope: impl Into) -> Self { +impl WithScope for MonomorphizePass { + fn with_scope(mut self, scope: impl Into) -> Self { self.scope = scope.into(); self } diff --git a/hugr-passes/src/non_local.rs b/hugr-passes/src/non_local.rs index ae12952a0..c35779e95 100644 --- a/hugr-passes/src/non_local.rs +++ b/hugr-passes/src/non_local.rs @@ -6,6 +6,7 @@ use hugr_core::{ types::{EdgeKind, Type}, }; +use crate::composable::WithScope; use crate::{ComposablePass, PassScope, composable::Preserve}; mod localize; @@ -78,8 +79,10 @@ impl ComposablePass for LocalizeEdges { Ok(()) } +} - fn with_scope_internal(mut self, scope: impl Into) -> Self { +impl WithScope for LocalizeEdges { + fn with_scope(mut self, scope: impl Into) -> Self { self.scope = scope.into(); self } diff --git a/hugr-passes/src/normalize_cfgs.rs b/hugr-passes/src/normalize_cfgs.rs index 1cfe1655d..834dd43b0 100644 --- a/hugr-passes/src/normalize_cfgs.rs +++ b/hugr-passes/src/normalize_cfgs.rs @@ -18,6 +18,7 @@ use hugr_core::ops::{ }; use hugr_core::{Direction, Hugr, HugrView, Node, OutgoingPort, PortIndex}; +use crate::composable::WithScope; use crate::{ComposablePass, PassScope}; /// Merge any basic blocks that are direct children of the specified [`CFG`]-entrypoint @@ -168,9 +169,10 @@ impl ComposablePass for NormalizeCFGPass { } Ok(results) } +} - /// Overrides any previous call to [Self::cfgs] - fn with_scope_internal(mut self, scope: impl Into) -> Self { +impl WithScope for NormalizeCFGPass { + fn with_scope(mut self, scope: impl Into) -> Self { self.scope = Either::Right(scope.into()); self } diff --git a/hugr-passes/src/redundant_order_edges.rs b/hugr-passes/src/redundant_order_edges.rs index dba6c5ed3..b2f3feb8a 100644 --- a/hugr-passes/src/redundant_order_edges.rs +++ b/hugr-passes/src/redundant_order_edges.rs @@ -10,6 +10,7 @@ use hugr_core::{HugrView, IncomingPort, Node, OutgoingPort}; use itertools::Itertools; use petgraph::visit::Walker; +use crate::composable::WithScope; use crate::{ComposablePass, PassScope}; /// A pass for removing order edges in a Hugr region that are already implied by @@ -156,11 +157,6 @@ impl> ComposablePass for RedundantOrderEdgesPass { type Error = HugrError; type Result = RedundantOrderEdgesResult; - fn with_scope_internal(mut self, scope: impl Into) -> Self { - self.scope = scope.into(); - self - } - fn run(&self, hugr: &mut H) -> Result { // Nodes to explore in the hugr. let mut region_candidates = VecDeque::from_iter(self.scope.root(hugr)); @@ -180,6 +176,13 @@ impl> ComposablePass for RedundantOrderEdgesPass { } } +impl WithScope for RedundantOrderEdgesPass { + fn with_scope(mut self, scope: impl Into) -> Self { + self.scope = scope.into(); + self + } +} + #[cfg(test)] mod tests { use hugr_core::builder::{Dataflow, DataflowHugr, FunctionBuilder, SubContainer}; diff --git a/hugr-passes/src/replace_types.rs b/hugr-passes/src/replace_types.rs index 1ad2433e9..0f8c963db 100644 --- a/hugr-passes/src/replace_types.rs +++ b/hugr-passes/src/replace_types.rs @@ -29,6 +29,7 @@ use hugr_core::types::{ }; use hugr_core::{Direction, Hugr, HugrView, Node, PortIndex, Visibility, Wire}; +use crate::composable::WithScope; use crate::{ComposablePass, PassScope}; mod linearize; @@ -912,17 +913,6 @@ impl> ComposablePass for ReplaceTypes { type Error = ReplaceTypesError; type Result = bool; - /// Sets the scope within which the pass will operate. Note that this pass ignores - /// * [PassScope::preserve_interface], as this is a lowering pass: its purpose is to - /// change node signatures. - /// * [PassScope::recursive], as non-recursion generally leads to invalid Hugrs. - /// - /// Hence, really only the [PassScope::root] affects the pass. - fn with_scope_internal(mut self, scope: impl Into) -> Self { - self.scope = Either::Left(scope.into()); - self - } - fn run(&self, hugr: &mut H) -> Result { let temp: Vec; // keep alive let regions = match &self.scope { @@ -940,6 +930,19 @@ impl> ComposablePass for ReplaceTypes { } } +impl WithScope for ReplaceTypes { + /// Sets the scope within which the pass will operate. Note that this pass ignores + /// * [PassScope::preserve_interface], as this is a lowering pass: its purpose is to + /// change node signatures. + /// * [PassScope::recursive], as non-recursion generally leads to invalid Hugrs. + /// + /// Hence, really only the [PassScope::root] affects the pass. + fn with_scope(mut self, scope: impl Into) -> Self { + self.scope = Either::Left(scope.into()); + self + } +} + pub mod handlers; #[derive(Clone, Hash, PartialEq, Eq)] diff --git a/hugr-passes/src/untuple.rs b/hugr-passes/src/untuple.rs index eef4bc545..fa7ebbba3 100644 --- a/hugr-passes/src/untuple.rs +++ b/hugr-passes/src/untuple.rs @@ -13,6 +13,7 @@ use hugr_core::types::Type; use hugr_core::{HugrView, Node, PortIndex, SimpleReplacement}; use itertools::{Either, Itertools}; +use crate::composable::WithScope; use crate::{ComposablePass, PassScope}; /// Configuration enum for the untuple rewrite pass. @@ -222,9 +223,11 @@ impl> ComposablePass for UntuplePass { } Ok(UntupleResult { rewrites_applied }) } +} +impl WithScope for UntuplePass { /// Overrides any [Self::set_parent] or [Self::recursive] - fn with_scope_internal(mut self, scope: impl Into) -> Self { + fn with_scope(mut self, scope: impl Into) -> Self { self.scope = Either::Left(scope.into()); self } From 8348d0c98c75880247c2a13854730c795d954348 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Borgna?= Date: Fri, 6 Mar 2026 14:04:11 +0000 Subject: [PATCH 2/4] Add default_scoped --- hugr-passes/src/composable.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hugr-passes/src/composable.rs b/hugr-passes/src/composable.rs index 5e0740172..7bc5ced29 100644 --- a/hugr-passes/src/composable.rs +++ b/hugr-passes/src/composable.rs @@ -100,6 +100,17 @@ pub trait WithScope { /// /// Since `hugr >=0.26.0`, passes must implement this to respect the scope configuration. fn with_scope(self, scope: impl Into) -> Self; + + /// Return a default instance of the pass with the given scope. + /// + /// See [`PassScope`] for more details. + #[must_use] + fn default_scoped(scope: PassScope) -> Self + where + Self: Default, + { + Self::default().with_scope(scope) + } } /// Trait for combining the error types from two different passes From 7c73a7d7485c6b7127209f9697535097a9d26305 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Borgna?= Date: Wed, 11 Mar 2026 15:25:04 +0000 Subject: [PATCH 3/4] Fix merge issues --- hugr-passes/src/const_fold.rs | 15 ++++----------- hugr-passes/src/dead_funcs.rs | 9 +++------ hugr-passes/src/normalize_cfgs.rs | 2 +- hugr-passes/src/replace_types.rs | 2 +- hugr-passes/src/untuple.rs | 6 +++--- 5 files changed, 12 insertions(+), 22 deletions(-) diff --git a/hugr-passes/src/const_fold.rs b/hugr-passes/src/const_fold.rs index 7b1a2ec72..1a12486f8 100644 --- a/hugr-passes/src/const_fold.rs +++ b/hugr-passes/src/const_fold.rs @@ -15,14 +15,12 @@ use hugr_core::{ }; use value_handle::ValueHandle; -use crate::PassScope; -use crate::composable::WithScope; +use crate::composable::{ComposablePass, PassScope, WithScope, validate_if_test}; use crate::dataflow::{ ConstLoader, ConstLocation, DFContext, Machine, PartialValue, TailLoopTermination, partial_from_const, }; use crate::dead_code::{DeadCodeElimError, DeadCodeElimPass, PreserveNode}; -use crate::{ComposablePass, PassScope, composable::validate_if_test}; #[derive(Debug, Clone, Default)] /// A configuration for the Constant Folding pass. @@ -188,7 +186,7 @@ impl + 'static> ComposablePass for ConstantFoldPass { .scope .as_ref() .map_or(DeadCodeElimPass::::default(), |scope| { - DeadCodeElimPass::::default().with_scope_internal(scope.clone()) + DeadCodeElimPass::::default_scoped(scope.clone()) }); dce.with_entry_points(self.inputs.keys().copied()) .set_preserve_callback(if self.allow_increase_termination { @@ -210,16 +208,11 @@ impl + 'static> ComposablePass for ConstantFoldPass { })?; Ok(()) } - - fn with_scope_internal(mut self, scope: impl Into) -> Self { - self.scope = Some(scope.into()); - self - } } impl WithScope for ConstantFoldPass { - fn with_scope(self, _scope: impl Into) -> Self { - // TODO: Set the scope configuration + fn with_scope(mut self, scope: impl Into) -> Self { + self.scope = Some(scope.into()); self } } diff --git a/hugr-passes/src/dead_funcs.rs b/hugr-passes/src/dead_funcs.rs index 25bc23377..a2fbcdddf 100644 --- a/hugr-passes/src/dead_funcs.rs +++ b/hugr-passes/src/dead_funcs.rs @@ -11,11 +11,8 @@ use hugr_core::{ use itertools::Either; use petgraph::visit::{Dfs, Walker}; -use crate::PassScope; -use crate::composable::WithScope; -use crate::{ - ComposablePass, PassScope, - composable::{Preserve, ValidatePassError, validate_if_test}, +use crate::composable::{ + ComposablePass, PassScope, Preserve, ValidatePassError, WithScope, validate_if_test, }; #[derive(Debug, thiserror::Error)] @@ -70,7 +67,7 @@ impl RemoveDeadFuncsPass { /// Adds new entry points - these must be [`FuncDefn`] nodes /// that are children of the [`Module`] at the root of the Hugr. /// - /// Overrides any [PassScope] set by a call to [Self::with_scope_internal]. + /// Overrides any [PassScope] set by a call to [Self::with_scope]. /// /// [`FuncDefn`]: hugr_core::ops::OpType::FuncDefn /// [`Module`]: hugr_core::ops::OpType::Module diff --git a/hugr-passes/src/normalize_cfgs.rs b/hugr-passes/src/normalize_cfgs.rs index 834dd43b0..8b6b81b26 100644 --- a/hugr-passes/src/normalize_cfgs.rs +++ b/hugr-passes/src/normalize_cfgs.rs @@ -114,7 +114,7 @@ impl NormalizeCFGPass { /// Allows mutating the set of CFG nodes that will be normalized. /// /// Note that calling this method (even if the returned mut-ref is not written to) will - /// override any previous call to [Self::with_scope_internal]. + /// override any previous call to [Self::with_scope]. /// /// If empty (the default), all (non-strict) descendants of the [HugrView::entrypoint] /// will be normalized. diff --git a/hugr-passes/src/replace_types.rs b/hugr-passes/src/replace_types.rs index 0f8c963db..1f0985377 100644 --- a/hugr-passes/src/replace_types.rs +++ b/hugr-passes/src/replace_types.rs @@ -710,7 +710,7 @@ impl ReplaceTypes { /// Set the regions of the Hugr to which this pass should be applied. /// /// If not set, the pass is applied to the whole Hugr. - /// Each call overwrites any previous calls to `set_regions` and/or [Self::with_scope_internal]. + /// Each call overwrites any previous calls to `set_regions` and/or [Self::with_scope]. pub fn set_regions(&mut self, regions: impl IntoIterator) { self.scope = Either::Right(regions.into_iter().collect()); } diff --git a/hugr-passes/src/untuple.rs b/hugr-passes/src/untuple.rs index fa7ebbba3..93722b013 100644 --- a/hugr-passes/src/untuple.rs +++ b/hugr-passes/src/untuple.rs @@ -108,7 +108,7 @@ impl UntuplePass { /// Sets the parent node to optimize (overwrites any previous setting) /// - /// If the pass was previously configured by [Self::with_scope_internal] then + /// If the pass was previously configured by [Self::with_scope] then /// implicitly `[Self::set_recursive]`'s with [PassScope::recursive] #[deprecated(note = "Use with_scope instead", since = "0.25.7")] #[expect(deprecated)] // Remove along with UntupleRecursive @@ -129,7 +129,7 @@ impl UntuplePass { /// Sets whether the pass should traverse the HUGR recursively. /// - /// If the pass was last configured via [Self::with_scope_internal], overrides that, + /// If the pass was last configured via [Self::with_scope], overrides that, /// with `set_parent` of default `None`. #[must_use] #[deprecated(note = "Use with_scope", since = "0.25.7")] @@ -142,7 +142,7 @@ impl UntuplePass { /// Find tuple pack operations followed by tuple unpack operations /// beneath a specified parent and according to this instance's recursiveness - /// ([Self::recursive] or [Self::with_scope_internal] + [PassScope::recursive]) + /// ([Self::recursive] or [Self::with_scope] + [PassScope::recursive]) /// and generate rewrites to remove them. /// /// The returned rewrites are guaranteed to be independent of each other. From 0956293559f3d2a80572c6e7a4d6237f3ee4cc1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Borgna?= Date: Wed, 11 Mar 2026 15:28:59 +0000 Subject: [PATCH 4/4] default_with_scope --- hugr-passes/src/composable.rs | 2 +- hugr-passes/src/const_fold.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hugr-passes/src/composable.rs b/hugr-passes/src/composable.rs index 7bc5ced29..41bdc628b 100644 --- a/hugr-passes/src/composable.rs +++ b/hugr-passes/src/composable.rs @@ -105,7 +105,7 @@ pub trait WithScope { /// /// See [`PassScope`] for more details. #[must_use] - fn default_scoped(scope: PassScope) -> Self + fn default_with_scope(scope: PassScope) -> Self where Self: Default, { diff --git a/hugr-passes/src/const_fold.rs b/hugr-passes/src/const_fold.rs index 1a12486f8..310c5c3b3 100644 --- a/hugr-passes/src/const_fold.rs +++ b/hugr-passes/src/const_fold.rs @@ -186,7 +186,7 @@ impl + 'static> ComposablePass for ConstantFoldPass { .scope .as_ref() .map_or(DeadCodeElimPass::::default(), |scope| { - DeadCodeElimPass::::default_scoped(scope.clone()) + DeadCodeElimPass::::default_with_scope(scope.clone()) }); dce.with_entry_points(self.inputs.keys().copied()) .set_preserve_callback(if self.allow_increase_termination {