From 62659507c56ad97d09ff1edd84de53a026a662fb Mon Sep 17 00:00:00 2001 From: collin <16715212+collinc97@users.noreply.github.com> Date: Fri, 16 Sep 2022 17:48:26 +0200 Subject: [PATCH] clippy --- compiler/parser/src/parser/expression.rs | 4 ++-- compiler/parser/src/parser/file.rs | 6 +++--- compiler/passes/src/type_checking/check_program.rs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/compiler/parser/src/parser/expression.rs b/compiler/parser/src/parser/expression.rs index aced302b61..b252acffda 100644 --- a/compiler/parser/src/parser/expression.rs +++ b/compiler/parser/src/parser/expression.rs @@ -443,7 +443,7 @@ impl ParserContext<'_> { let mut dist = 1; // 0th is `(` so 1st is first gc's start. let first_gc = self.peek_group_coordinate(&mut dist)?; - let check_ahead = |d, token: &_| self.look_ahead(d, |t| (&t.token == token).then(|| t.span)); + let check_ahead = |d, token: &_| self.look_ahead(d, |t| (&t.token == token).then_some(t.span)); // Peek at `,`. check_ahead(dist, &Token::Comma)?; @@ -532,7 +532,7 @@ impl ParserContext<'_> { let suffix_span = self.token.span; let full_span = span + suffix_span; let assert_no_whitespace = |x| assert_no_whitespace(span, suffix_span, &value, x); - match self.eat_any(INT_TYPES).then(|| &self.prev_token.token) { + match self.eat_any(INT_TYPES).then_some(&self.prev_token.token) { // Literal followed by `field`, e.g., `42field`. Some(Token::Field) => { assert_no_whitespace("field")?; diff --git a/compiler/parser/src/parser/file.rs b/compiler/parser/src/parser/file.rs index 240bb59c9a..0ff8a50433 100644 --- a/compiler/parser/src/parser/file.rs +++ b/compiler/parser/src/parser/file.rs @@ -262,9 +262,9 @@ impl ParserContext<'_> { /// Returns a [`ParamMode`] AST node if the next tokens represent a function parameter mode. pub(super) fn parse_mode(&mut self) -> Result { // TODO: Allow explicit "private" mode. - let public = self.eat(&Token::Public).then(|| self.prev_token.span); - let constant = self.eat(&Token::Constant).then(|| self.prev_token.span); - let const_ = self.eat(&Token::Const).then(|| self.prev_token.span); + let public = self.eat(&Token::Public).then_some(self.prev_token.span); + let constant = self.eat(&Token::Constant).then_some(self.prev_token.span); + let const_ = self.eat(&Token::Const).then_some(self.prev_token.span); if let Some(span) = const_ { self.emit_warning(ParserWarning::const_parameter_or_input(span)); diff --git a/compiler/passes/src/type_checking/check_program.rs b/compiler/passes/src/type_checking/check_program.rs index 773bc8adea..520fcfee37 100644 --- a/compiler/passes/src/type_checking/check_program.rs +++ b/compiler/passes/src/type_checking/check_program.rs @@ -51,7 +51,7 @@ 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_some((v, t))) { Some((_, actual_ty)) if expected_ty.eq_flat(actual_ty) => {} // All good, found + right type! Some((field, _)) => {