cargo fmt

This commit is contained in:
collin 2022-07-02 14:08:17 -07:00
parent 0a4069fe39
commit ecc1fff7fd
5 changed files with 11 additions and 22 deletions

View File

@ -395,7 +395,6 @@ impl<'a> ExpressionVisitor<'a> for TypeChecker<'a> {
}
}
fn visit_unary(&mut self, input: &'a UnaryExpression, destination: &Self::AdditionalInput) -> Self::Output {
match input.op {
UnaryOperation::Abs => {

View File

@ -18,8 +18,8 @@ use crate::{Declaration, TypeChecker, VariableSymbol};
use leo_ast::*;
use leo_errors::TypeCheckerError;
use std::collections::HashSet;
use leo_span::sym;
use std::collections::HashSet;
impl<'a> ProgramVisitor<'a> for TypeChecker<'a> {
fn visit_function(&mut self, input: &'a Function) {
@ -54,12 +54,11 @@ impl<'a> ProgramVisitor<'a> for TypeChecker<'a> {
// Check for conflicting circuit member names.
let mut used = HashSet::new();
if !input.members.iter().all(|member| used.insert(member.name())) {
self.handler
.emit_err(if input.is_record {
TypeCheckerError::duplicate_record_variable(input.name(), input.span()).into()
} else {
TypeCheckerError::duplicate_circuit_member(input.name(), input.span()).into()
});
self.handler.emit_err(if input.is_record {
TypeCheckerError::duplicate_record_variable(input.name(), input.span()).into()
} else {
TypeCheckerError::duplicate_circuit_member(input.name(), input.span()).into()
});
}
// For records, enforce presence of `owner: Address` and `balance: u64` members.
@ -67,22 +66,16 @@ impl<'a> ProgramVisitor<'a> for TypeChecker<'a> {
let check_has_field = |need, expected_ty: Type| match input
.members
.iter()
.find_map(|CircuitMember::CircuitVariable(v, t) | (v.name == need).then(|| (v, t)))
.find_map(|CircuitMember::CircuitVariable(v, t)| (v.name == need).then(|| (v, t)))
{
Some((_, actual_ty)) if expected_ty.eq_flat(actual_ty) => {} // All good, found + right type!
Some((field, _)) => {
self.handler.emit_err(TypeCheckerError::record_var_wrong_type(
field,
expected_ty,
input.span(),
).into());
self.handler
.emit_err(TypeCheckerError::record_var_wrong_type(field, expected_ty, input.span()).into());
}
None => {
self.handler.emit_err(TypeCheckerError::required_record_variable(
need,
expected_ty,
input.span(),
).into());
self.handler
.emit_err(TypeCheckerError::required_record_variable(need, expected_ty, input.span()).into());
}
};
check_has_field(sym::owner, Type::Address);

View File

@ -16,7 +16,6 @@
// Copyright Rust project developers under MIT or APACHE-2.0.
use core::alloc::Layout;
use core::cell::{Cell, RefCell};
use core::mem::{self, MaybeUninit};

View File

@ -14,7 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
//! Defines the `Span` type used to track where code comes from.
use core::ops::{Add, Sub};

View File

@ -14,7 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::dropless::DroplessArena;
use crate::source_map::SourceMap;