Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: run clippy #4810

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions compiler/noirc_frontend/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,29 +97,30 @@ where
/// Sequence the two parsers.
/// Fails if the first parser fails, otherwise forces
/// the second parser to succeed while logging any errors.
fn then_commit<'a, P1, P2, T1, T2: 'a>(
fn then_commit<'a, P1, P2, T1, T2>(
first_parser: P1,
second_parser: P2,
) -> impl NoirParser<(T1, T2)> + 'a
where
P1: NoirParser<T1> + 'a,
P2: NoirParser<T2> + 'a,
T2: Clone + Recoverable,
T2: Clone + Recoverable + 'a,
{
let second_parser = skip_then_retry_until(second_parser)
.map_with_span(|option, span| option.unwrap_or_else(|| Recoverable::error(span)));

first_parser.then(second_parser)
}

fn then_commit_ignore<'a, P1, P2, T1: 'a, T2: 'a>(
fn then_commit_ignore<'a, P1, P2, T1, T2>(
first_parser: P1,
second_parser: P2,
) -> impl NoirParser<T1> + 'a
where
P1: NoirParser<T1> + 'a,
P2: NoirParser<T2> + 'a,
T2: Clone,
T1: 'a,
T2: Clone + 'a,
{
let second_parser = skip_then_retry_until(second_parser);
first_parser.then_ignore(second_parser)
Expand All @@ -140,10 +141,10 @@ where
first_parser.ignore_then(second_parser)
}

fn skip_then_retry_until<'a, P, T: 'a>(parser: P) -> impl NoirParser<Option<T>> + 'a
fn skip_then_retry_until<'a, P, T>(parser: P) -> impl NoirParser<Option<T>> + 'a
where
P: NoirParser<T> + 'a,
T: Clone,
T: Clone + 'a,
{
let terminators = [
Token::EOF,
Expand Down
8 changes: 4 additions & 4 deletions compiler/noirc_frontend/src/parser/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

use chumsky::prelude::*;
use iter_extended::vecmap;
use lalrpop_util::lalrpop_mod;

Check warning on line 50 in compiler/noirc_frontend/src/parser/parser.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (lalrpop)

Check warning on line 50 in compiler/noirc_frontend/src/parser/parser.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (lalrpop)
use noirc_errors::{Span, Spanned};

mod assertion;
Expand All @@ -60,8 +60,8 @@
mod structs;
mod traits;

// synthesized by LALRPOP

Check warning on line 63 in compiler/noirc_frontend/src/parser/parser.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (LALRPOP)
lalrpop_mod!(pub noir_parser);

Check warning on line 64 in compiler/noirc_frontend/src/parser/parser.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (lalrpop)

#[cfg(test)]
mod test_helpers;
Expand All @@ -85,12 +85,12 @@

if cfg!(feature = "experimental_parser") {
for parsed_item in &parsed_module.items {
if lalrpop_parser_supports_kind(&parsed_item.kind) {

Check warning on line 88 in compiler/noirc_frontend/src/parser/parser.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (lalrpop)
match &parsed_item.kind {
ItemKind::Import(parsed_use_tree) => {
prototype_parse_use_tree(Some(parsed_use_tree), source_program);
}
// other kinds prevented by lalrpop_parser_supports_kind

Check warning on line 93 in compiler/noirc_frontend/src/parser/parser.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (lalrpop)
_ => unreachable!(),
}
}
Expand All @@ -107,7 +107,7 @@
}

let mut lexer = Lexer::new(input);
lexer = lexer.skip_whitespaces(false);

Check warning on line 110 in compiler/noirc_frontend/src/parser/parser.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (whitespaces)
let mut errors = Vec::new();

// NOTE: this is a hack to get the references working
Expand Down Expand Up @@ -1587,7 +1587,7 @@

#[test]
fn parse_use() {
let mut valid_use_statements = vec![
let valid_use_statements = [
"use std::hash",
"use std",
"use foo::bar as hello",
Expand All @@ -1600,7 +1600,7 @@
"use dep::{std::println, bar::baz}",
];

let mut invalid_use_statements = vec![
let invalid_use_statements = [
"use std as ;",
"use foobar as as;",
"use hello:: as foo;",
Expand All @@ -1610,9 +1610,9 @@
];

let use_statements = valid_use_statements
.iter_mut()
.into_iter()
.map(|valid_str| (valid_str, true))
.chain(invalid_use_statements.iter_mut().map(|invalid_str| (invalid_str, false)));
.chain(invalid_use_statements.into_iter().map(|invalid_str| (invalid_str, false)));

for (use_statement_str, expect_valid) in use_statements {
let mut use_statement_str = use_statement_str.to_string();
Expand Down
2 changes: 1 addition & 1 deletion tooling/noirc_abi/src/input_parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl InputValue {
if map.len() > fields.len() {
let expected_fields: HashSet<String> =
fields.iter().map(|(field, _)| field.to_string()).collect();
let extra_field = map.keys().cloned().find(|key| !expected_fields.contains(key)).expect("`map` is larger than the expected type's `fields` so it must contain an unexpected field");
let extra_field = map.keys().find(|&key| !expected_fields.contains(key)).cloned().expect("`map` is larger than the expected type's `fields` so it must contain an unexpected field");
return Err(InputTypecheckingError::UnexpectedField {
path,
typ: abi_param.clone(),
Expand Down
Loading