Skip to content

Commit

Permalink
Rm check_args_impl
Browse files Browse the repository at this point in the history
  • Loading branch information
acl-cqc committed May 10, 2024
1 parent c45e6fc commit 1dae688
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
7 changes: 1 addition & 6 deletions hugr/src/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ use crate::hugr::IdentList;
use crate::ops::constant::{ValueName, ValueNameRef};
use crate::ops::custom::{ExtensionOp, OpaqueOp};
use crate::ops::{self, OpName, OpNameRef};
use crate::types::type_param::{check_type_args, TypeArgError};
use crate::types::type_param::{TypeArg, TypeParam};
use crate::types::type_param::{TypeArg, TypeArgError, TypeParam};
use crate::types::{check_typevar_decl, CustomType, Substitution, TypeBound, TypeName};
use crate::types::{FunctionType, TypeNameRef};

Expand Down Expand Up @@ -243,10 +242,6 @@ trait TypeParametrised {
fn params(&self) -> &[TypeParam];
/// The parent extension.
fn extension(&self) -> &ExtensionId;
/// Check provided type arguments are valid against parameters.
fn check_args_impl(&self, args: &[TypeArg]) -> Result<(), SignatureError> {
check_type_args(args, self.params()).map_err(SignatureError::TypeArgMismatch)
}
}

/// A constant value provided by a extension.
Expand Down
8 changes: 4 additions & 4 deletions hugr/src/extension/type_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use super::{Extension, ExtensionId, SignatureError, TypeParametrised};

use crate::types::{least_upper_bound, CustomType, TypeName};

use crate::types::type_param::TypeArg;
use crate::types::type_param::{check_type_args, TypeArg};

use crate::types::type_param::TypeParam;

Expand Down Expand Up @@ -49,7 +49,7 @@ pub struct TypeDef {
impl TypeDef {
/// Check provided type arguments are valid against parameters.
pub fn check_args(&self, args: &[TypeArg]) -> Result<(), SignatureError> {
self.check_args_impl(args)
check_type_args(args, &self.params).map_err(SignatureError::TypeArgMismatch)
}

/// Check [`CustomType`] is a valid instantiation of this definition.
Expand All @@ -72,7 +72,7 @@ impl TypeDef {
));
}

self.check_args_impl(custom.type_args())?;
check_type_args(custom.type_args(), &self.params)?;

let calc_bound = self.bound(custom.args());
if calc_bound == custom.bound() {
Expand All @@ -93,7 +93,7 @@ impl TypeDef {
/// valid instances of the type parameters.
pub fn instantiate(&self, args: impl Into<Vec<TypeArg>>) -> Result<CustomType, SignatureError> {
let args = args.into();
self.check_args_impl(&args)?;
check_type_args(&args, &self.params)?;
let bound = self.bound(&args);
Ok(CustomType::new(
self.name().clone(),
Expand Down

0 comments on commit 1dae688

Please sign in to comment.