diff --git a/crates/noirc_frontend/src/ast/expression.rs b/crates/noirc_frontend/src/ast/expression.rs index 6c29c89051f..1a829bd0ce7 100644 --- a/crates/noirc_frontend/src/ast/expression.rs +++ b/crates/noirc_frontend/src/ast/expression.rs @@ -377,7 +377,7 @@ pub enum FunctionReturnType { /// Returns type is not specified. Default(Span), /// Everything else. - Ty(UnresolvedType, Span), + Ty(UnresolvedType), } /// Describes the types of smart contract functions that are allowed. @@ -692,7 +692,7 @@ impl FunctionReturnType { pub fn get_type(&self) -> &UnresolvedTypeData { match self { FunctionReturnType::Default(_span) => &UnresolvedTypeData::Unit, - FunctionReturnType::Ty(typ, _span) => &typ.typ, + FunctionReturnType::Ty(typ) => &typ.typ, } } } @@ -701,7 +701,7 @@ impl Display for FunctionReturnType { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { FunctionReturnType::Default(_) => f.write_str(""), - FunctionReturnType::Ty(ty, _) => write!(f, "{ty}"), + FunctionReturnType::Ty(ty) => write!(f, "{ty}"), } } } diff --git a/crates/noirc_frontend/src/ast/function.rs b/crates/noirc_frontend/src/ast/function.rs index ea6d92f0afd..9f200f87bd1 100644 --- a/crates/noirc_frontend/src/ast/function.rs +++ b/crates/noirc_frontend/src/ast/function.rs @@ -47,7 +47,7 @@ impl NoirFunction { FunctionReturnType::Default(_) => { UnresolvedType::without_span(UnresolvedTypeData::Unit) } - FunctionReturnType::Ty(ty, _) => ty.clone(), + FunctionReturnType::Ty(ty) => ty.clone(), } } pub fn name(&self) -> &str { diff --git a/crates/noirc_frontend/src/hir/def_collector/dc_crate.rs b/crates/noirc_frontend/src/hir/def_collector/dc_crate.rs index bc0d8d6cfc0..389e6038775 100644 --- a/crates/noirc_frontend/src/hir/def_collector/dc_crate.rs +++ b/crates/noirc_frontend/src/hir/def_collector/dc_crate.rs @@ -440,7 +440,7 @@ fn resolve_trait_methods( let arguments = vecmap(parameters, |param| resolver.resolve_type(param.1.clone())); let resolved_return_type = match return_type { FunctionReturnType::Default(_) => None, - FunctionReturnType::Ty(unresolved_type, _span) => { + FunctionReturnType::Ty(unresolved_type) => { Some(resolver.resolve_type(unresolved_type.clone())) } }; diff --git a/crates/noirc_frontend/src/hir/type_check/errors.rs b/crates/noirc_frontend/src/hir/type_check/errors.rs index cd8d87435c9..3190c7a24a2 100644 --- a/crates/noirc_frontend/src/hir/type_check/errors.rs +++ b/crates/noirc_frontend/src/hir/type_check/errors.rs @@ -205,8 +205,9 @@ impl From for Diagnostic { Source::Comparison => format!("Unsupported types for comparison: {expected} and {actual}"), Source::BinOp => format!("Unsupported types for binary operation: {expected} and {actual}"), Source::Return(ret_ty, expr_span) => { - let ret_ty_span = match ret_ty { - FunctionReturnType::Default(span) | FunctionReturnType::Ty(_, span) => span + let ret_ty_span = match ret_ty.clone() { + FunctionReturnType::Default(span) => span, + FunctionReturnType::Ty(ty) => ty.span.unwrap(), }; let mut diagnostic = Diagnostic::simple_error(format!("expected type {expected}, found type {actual}"), format!("expected {expected} because of return type"), ret_ty_span); diff --git a/crates/noirc_frontend/src/parser/parser.rs b/crates/noirc_frontend/src/parser/parser.rs index 00eba5de3f3..84f1ab0da82 100644 --- a/crates/noirc_frontend/src/parser/parser.rs +++ b/crates/noirc_frontend/src/parser/parser.rs @@ -268,7 +268,7 @@ fn function_return_type() -> impl NoirParser<((Distinctness, Visibility), Functi .then(spanned(parse_type())) .or_not() .map_with_span(|ret, span| match ret { - Some((head, (ty, span))) => (head, FunctionReturnType::Ty(ty, span)), + Some((head, (ty, _))) => (head, FunctionReturnType::Ty(ty)), None => ( (Distinctness::DuplicationAllowed, Visibility::Private), FunctionReturnType::Default(span),