Skip to content

Commit

Permalink
fix: apply cargo clippy suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
alehander92 committed Jul 20, 2023
1 parent 2de4113 commit a0e395e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
5 changes: 2 additions & 3 deletions crates/noirc_frontend/src/hir/resolution/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ impl<'a> Resolver<'a> {
// If this was a fresh capture, we added it to the end of
// the captures vector:
self.lambda_stack[lambda_index].captures.len() - 1,
))
));
}
}
}
Expand Down Expand Up @@ -1062,8 +1062,7 @@ impl<'a> Resolver<'a> {
ExpressionKind::Lambda(lambda) => self.in_new_scope(|this| {
let scope_index = this.scopes.current_scope_index();

this.lambda_stack
.push(LambdaContext { captures: Vec::new(), scope_index: scope_index });
this.lambda_stack.push(LambdaContext { captures: Vec::new(), scope_index });

let parameters = vecmap(lambda.parameters, |(pattern, typ)| {
let parameter = DefinitionKind::Local(None);
Expand Down
8 changes: 3 additions & 5 deletions crates/noirc_frontend/src/hir/type_check/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,8 @@ impl<'interner> TypeChecker<'interner> {
Type::Tuple(vecmap(&elements, |elem| self.check_expression(elem)))
}
HirExpression::Lambda(lambda) => {
let captured_vars = vecmap(lambda.captures, |capture| {
let typ = self.interner.id_type(capture.ident.id);
typ
});
let captured_vars =
vecmap(lambda.captures, |capture| self.interner.id_type(capture.ident.id));

let env_type = Type::Tuple(captured_vars);
let mut params = vec![env_type];
Expand Down Expand Up @@ -829,7 +827,7 @@ impl<'interner> TypeChecker<'interner> {
}
Type::Closure(closure) => match closure.as_ref() {
Type::Function(parameters, ret) => {
if parameters.len() < 1 {
if parameters.is_empty() {
unreachable!("Closure type should always contain the captured variables tuple type: {}", closure.as_ref());
}
self.bind_function_type_impl(
Expand Down
4 changes: 2 additions & 2 deletions crates/noirc_frontend/src/monomorphization/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ impl<'interner> Monomorphizer<'interner> {
match func.as_ref() {
HirType::Function(arguments, return_type) => {
let converted_args = vecmap(arguments, Self::convert_type);
let converted_ret = Box::new(Self::convert_type(&return_type));
let converted_ret = Box::new(Self::convert_type(return_type));
let fn_type = ast::Type::Function(converted_args, converted_ret);
let env_type = ast::Type::Tuple(vec![]); // TODO compute this
ast::Type::Tuple(vec![env_type, fn_type])
Expand Down Expand Up @@ -784,7 +784,7 @@ impl<'interner> Monomorphizer<'interner> {
let return_type = Self::convert_type(&return_type);
let location = call.location;

let is_closure = self.is_function_closure(&*original_func);
let is_closure = self.is_function_closure(&original_func);

let func = if is_closure {
Box::new(ast::Expression::ExtractTupleField(Box::new((*original_func).clone()), 1usize))
Expand Down

0 comments on commit a0e395e

Please sign in to comment.