Skip to content

Commit

Permalink
fix: remove unneeded span
Browse files Browse the repository at this point in the history
  • Loading branch information
alexvitkov committed Sep 4, 2023
1 parent 5f78772 commit 1545441
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions crates/noirc_frontend/src/ast/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
}
}
}
Expand All @@ -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}"),
}
}
}
2 changes: 1 addition & 1 deletion crates/noirc_frontend/src/ast/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion crates/noirc_frontend/src/hir/def_collector/dc_crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
}
};
Expand Down
5 changes: 3 additions & 2 deletions crates/noirc_frontend/src/hir/type_check/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,9 @@ impl From<TypeCheckError> 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);
Expand Down
2 changes: 1 addition & 1 deletion crates/noirc_frontend/src/parser/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 1545441

Please sign in to comment.