Skip to content

Commit

Permalink
chore: run clippy (#4810)
Browse files Browse the repository at this point in the history
# Description

## Problem\*

Resolves <!-- Link to GitHub Issue -->

## Summary\*

I'm fixing some clippy warnings which are popping up in my IDE.

This PR also runs the nightly version of clippy and fixes some of the
issues where appropriate.

## Additional Context



## Documentation\*

Check one:
- [ ] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[For Experimental Features]** Documentation to be submitted in a
separate PR.

# PR Checklist\*

- [ ] I have tested the changes locally.
- [ ] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
  • Loading branch information
TomAFrench authored Apr 16, 2024
1 parent 0adeb08 commit 1fa510a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
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 @@ -1587,7 +1587,7 @@ mod test {

#[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 @@ mod test {
"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 @@ mod test {
];

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

0 comments on commit 1fa510a

Please sign in to comment.