mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-24 18:52:58 +03:00
cargo fmt
This commit is contained in:
parent
0a4069fe39
commit
ecc1fff7fd
@ -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 => {
|
||||
|
@ -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);
|
||||
|
@ -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};
|
||||
|
@ -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};
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user