diff --git a/hugr/src/extension/op_def.rs b/hugr/src/extension/op_def.rs index b7a8465d0..9665da09e 100644 --- a/hugr/src/extension/op_def.rs +++ b/hugr/src/extension/op_def.rs @@ -24,7 +24,7 @@ pub trait CustomSignatureFunc: Send + Sync { arg_values: &[TypeArg], def: &'o OpDef, extension_registry: &ExtensionRegistry, - ) -> Result, SignatureError>; + ) -> Result; /// The declared type parameters which require values in order for signature to /// be computed. fn static_params(&self) -> &[TypeParam]; @@ -37,7 +37,7 @@ pub trait SignatureFromArgs: Send + Sync { fn compute_signature( &self, arg_values: &[TypeArg], - ) -> Result, SignatureError>; + ) -> Result; /// The declared type parameters which require values in order for signature to /// be computed. fn static_params(&self) -> &[TypeParam]; @@ -50,7 +50,7 @@ impl CustomSignatureFunc for T { arg_values: &[TypeArg], _def: &'o OpDef, _extension_registry: &ExtensionRegistry, - ) -> Result, SignatureError> { + ) -> Result { SignatureFromArgs::compute_signature(self, arg_values) } @@ -123,14 +123,14 @@ pub trait CustomLowerFunc: Send + Sync { #[derive(serde::Deserialize, serde::Serialize)] pub struct CustomValidator { #[serde(flatten)] - poly_func: PolyFuncType, + poly_func: PolyFuncType, #[serde(skip)] pub(crate) validate: Box, } impl CustomValidator { /// Encode a signature using a `PolyFuncType` - pub fn from_polyfunc(poly_func: impl Into>) -> Self { + pub fn from_polyfunc(poly_func: impl Into) -> Self { Self { poly_func: poly_func.into(), validate: Default::default(), @@ -140,7 +140,7 @@ impl CustomValidator { /// Encode a signature using a `PolyFuncType`, with a custom function for /// validating type arguments before returning the signature. pub fn new_with_validator( - poly_func: impl Into>, + poly_func: impl Into, validate: impl ValidateTypeArgs + 'static, ) -> Self { Self { @@ -189,8 +189,8 @@ impl From for SignatureFunc { } } -impl From> for SignatureFunc { - fn from(v: PolyFuncType) -> Self { +impl From for SignatureFunc { + fn from(v: PolyFuncType) -> Self { Self::TypeScheme(CustomValidator::from_polyfunc(v)) } } @@ -232,7 +232,7 @@ impl SignatureFunc { args: &[TypeArg], exts: &ExtensionRegistry, ) -> Result { - let temp: PolyFuncType; + let temp: PolyFuncType; let (pf, args) = match &self { SignatureFunc::TypeScheme(custom) => { custom.validate.validate(args, def, exts)?; @@ -335,7 +335,7 @@ impl OpDef { exts: &ExtensionRegistry, var_decls: &[TypeParam], ) -> Result<(), SignatureError> { - let temp: PolyFuncType; // to keep alive + let temp: PolyFuncType; // to keep alive let (pf, args) = match &self.signature_func { SignatureFunc::TypeScheme(ts) => (&ts.poly_func, args), SignatureFunc::CustomFunc(custom) => { @@ -548,7 +548,7 @@ mod test { fn compute_signature( &self, arg_values: &[TypeArg], - ) -> Result, SignatureError> { + ) -> Result { const TP: TypeParam = TypeParam::Type { b: TypeBound::Any }; let [TypeArg::BoundedNat { n }] = arg_values else { return Err(SignatureError::InvalidTypeArgs); diff --git a/hugr/src/types/poly_func.rs b/hugr/src/types/poly_func.rs index 86c1a057c..85b0f5a53 100644 --- a/hugr/src/types/poly_func.rs +++ b/hugr/src/types/poly_func.rs @@ -28,7 +28,7 @@ use super::Substitution; "params.iter().map(ToString::to_string).join(\" \")", "body" )] -pub struct PolyFuncType { +pub struct PolyFuncType { /// The declared type parameters, i.e., these must be instantiated with /// the same number of [TypeArg]s before the function can be called. This /// defines the indices used by variables inside the body. @@ -99,7 +99,7 @@ impl PolyFuncType { } } -impl PolyFuncType { +impl PolyFuncType { /// Validates this instance, checking that the types in the body are /// wellformed with respect to the registry, and the type variables declared. /// Allows both inputs and outputs to contain [RowVariable]s @@ -135,7 +135,7 @@ pub(crate) mod test { ExtensionRegistry::try_new([PRELUDE.to_owned(), EXTENSION.to_owned()]).unwrap(); } - impl PolyFuncType { + impl PolyFuncType { fn new_validated( params: impl Into>, body: FunctionType,