diff --git a/crates/noirc_frontend/src/ast/expression.rs b/crates/noirc_frontend/src/ast/expression.rs index 879ee397477..f6e085cc95b 100644 --- a/crates/noirc_frontend/src/ast/expression.rs +++ b/crates/noirc_frontend/src/ast/expression.rs @@ -638,11 +638,7 @@ impl FunctionDefinition { let p = parameters .iter() .map(|(ident, unresolved_type)| { - ( - Pattern::Identifier(ident.clone()), - unresolved_type.clone(), - Visibility::Private, - ) + (Pattern::Identifier(ident.clone()), unresolved_type.clone(), Visibility::Private) }) .collect(); FunctionDefinition { @@ -692,6 +688,15 @@ impl Display for FunctionDefinition { } } +impl FunctionReturnType { + pub fn get_type(&self) -> &UnresolvedType { + match self { + FunctionReturnType::Default(_span) => &UnresolvedType::Unit, + FunctionReturnType::Ty(typ, _span) => typ, + } + } +} + impl Display for FunctionReturnType { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { diff --git a/crates/noirc_frontend/src/ast/mod.rs b/crates/noirc_frontend/src/ast/mod.rs index e5abab38f9d..e92d333fd69 100644 --- a/crates/noirc_frontend/src/ast/mod.rs +++ b/crates/noirc_frontend/src/ast/mod.rs @@ -187,16 +187,6 @@ impl UnresolvedTypeData { } } -impl FunctionReturnType { - pub fn get_type(&self) -> &UnresolvedType { - match item { - FunctionReturnType::Default(_span) => &UnresolvedType::Unit, - FunctionReturnType::Ty(typ, _span) => typ, - } - } -} -} - #[derive(Debug, PartialEq, Eq, Copy, Clone, Hash)] pub enum Signedness { Unsigned, diff --git a/crates/noirc_frontend/src/hir/def_collector/dc_mod.rs b/crates/noirc_frontend/src/hir/def_collector/dc_mod.rs index 7d5cd7fa599..dad2c25eb6e 100644 --- a/crates/noirc_frontend/src/hir/def_collector/dc_mod.rs +++ b/crates/noirc_frontend/src/hir/def_collector/dc_mod.rs @@ -105,9 +105,7 @@ fn check_trait_method_implementation_return_type( impl_method: &NoirFunction, trait_name: &str, ) -> Result<(), DefCollectorErrorKind> { - if UnresolvedType::from_func_return_type(expected_return_type) - == UnresolvedType::from_func_return_type(&impl_method.def.return_type) - { + if expected_return_type.get_type() == impl_method.def.return_type.get_type() { Ok(()) } else { Err(DefCollectorErrorKind::MismatchTraitImplementationReturnType {