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: clippy fixes #2897

Merged
merged 3 commits into from
Sep 29, 2023
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
4 changes: 2 additions & 2 deletions .github/workflows/formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
timeout-minutes: 30
env:
RUSTFLAGS: -Dwarnings

strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:
name: eslint
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-nargo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
- name: Test built artifact
if: matrix.target == 'x86_64-apple-darwin'
run: |
cp ./target/${{ matrix.target }}/release/nargo ~/.cargo/bin/
cp ./target/${{ matrix.target }}/release/nargo ~/.cargo/bin/
yarn workspace release-tests test

- name: Upload binaries to release tag
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-noir_wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ jobs:
cp -r ./compiler/wasm/downloaded/nodejs ./compiler/wasm
cp -r ./compiler/wasm/downloaded/web ./compiler/wasm
yarn workspace @noir-lang/source-resolver build

- name: Run node tests
run: yarn workspace @noir-lang/noir_wasm test:node

Expand Down
2 changes: 1 addition & 1 deletion acvm-repo/acir/src/circuit/black_box_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ mod tests {
fn consistent_function_names() {
for bb_func in BlackBoxFunc::iter() {
let resolved_func = BlackBoxFunc::lookup(bb_func.name()).unwrap_or_else(|| {
panic!("BlackBoxFunc::lookup couldn't find black box function {}", bb_func)
panic!("BlackBoxFunc::lookup couldn't find black box function {bb_func}")
});
assert_eq!(
resolved_func, bb_func,
Expand Down
2 changes: 1 addition & 1 deletion acvm-repo/acir_field/src/generic_ark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ impl<F: PrimeField> FieldElement<F> {

let and_byte_arr: Vec<_> = lhs_bytes
.into_iter()
.zip(rhs_bytes.into_iter())
.zip(rhs_bytes)
.map(|(lhs, rhs)| if is_xor { lhs ^ rhs } else { lhs & rhs })
.collect();

Expand Down
2 changes: 1 addition & 1 deletion acvm-repo/acvm/src/compiler/optimizers/general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn simplify_mul_terms(mut gate: Expression) -> Expression {

// Canonicalize the ordering of the multiplication, lets just order by variable name
for (scale, w_l, w_r) in gate.mul_terms.clone().into_iter() {
let mut pair = vec![w_l, w_r];
let mut pair = [w_l, w_r];
// Sort using rust sort algorithm
pair.sort();

Expand Down
2 changes: 1 addition & 1 deletion acvm-repo/acvm/src/pwg/blackbox/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
use acir::{circuit::opcodes::FunctionInput, native_types::WitnessMap};

pub(super) fn solve_range_opcode(
initial_witness: &mut WitnessMap,
initial_witness: &WitnessMap,
input: &FunctionInput,
) -> Result<(), OpcodeResolutionError> {
let w_value = witness_to_value(initial_witness, input.witness)?;
Expand Down
2 changes: 1 addition & 1 deletion compiler/fm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ mod tests {
// - dir/lib.nr
// - dir/sub_dir.nr
// - dir/sub_dir/foo.nr
create_dummy_file(&dir, Path::new(&format!("{}.nr", sub_dir_name)));
create_dummy_file(&dir, Path::new(&format!("{sub_dir_name}.nr")));

// First check for the sub_dir.nr file and add it to the FileManager
let sub_dir_file_id = fm.find_module(file_id, sub_dir_name).unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl BlockVariables {
/// Returns all non-constant variables that have not been removed at this point.
pub(crate) fn get_available_variables(
&self,
function_context: &mut FunctionContext,
function_context: &FunctionContext,
) -> Vec<RegisterOrMemory> {
self.available_variables
.iter()
Expand Down Expand Up @@ -95,8 +95,7 @@ impl BlockVariables {
} else {
assert!(
self.available_variables.contains(&value_id),
"ICE: ValueId {:?} is not available",
value_id
"ICE: ValueId {value_id:?} is not available"
);

*function_context
Expand Down
2 changes: 1 addition & 1 deletion compiler/noirc_frontend/src/graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ mod tests {
let mut vec_ids = Vec::with_capacity(n);
for i in 0..n {
let mut pth = PathBuf::new();
pth.push(format!("{}", i));
pth.push(format!("{i}"));
pth.set_extension(FILE_EXTENSION);
vec_ids.push(fm.add_file(pth.into(), String::new()));
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ fn collect_impls(

fn collect_trait_impl_methods(
interner: &mut NodeInterner,
def_maps: &mut BTreeMap<CrateId, CrateDefMap>,
def_maps: &BTreeMap<CrateId, CrateDefMap>,
crate_id: CrateId,
trait_id: TraitId,
trait_impl: &mut UnresolvedTraitImpl,
Expand Down
10 changes: 5 additions & 5 deletions compiler/noirc_frontend/src/hir/resolution/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1761,7 +1761,7 @@ mod test {
let errors = resolve_src_code(src, vec!["main"]);

// There should only be one error
assert!(errors.len() == 1, "Expected 1 error, got: {:?}", errors);
assert!(errors.len() == 1, "Expected 1 error, got: {errors:?}");

// It should be regarding the unused variable
match &errors[0] {
Expand Down Expand Up @@ -1831,7 +1831,7 @@ mod test {
"#;

let errors = resolve_src_code(src, vec!["main"]);
assert!(errors.len() == 3, "Expected 3 errors, got: {:?}", errors);
assert!(errors.len() == 3, "Expected 3 errors, got: {errors:?}");

// Errors are:
// `a` is undeclared
Expand Down Expand Up @@ -1907,7 +1907,7 @@ mod test {
"#;
let errors = resolve_src_code(src, vec!["main", "foo"]);
if !errors.is_empty() {
println!("Unexpected errors: {:?}", errors);
println!("Unexpected errors: {errors:?}");
unreachable!("there should be no errors");
}
}
Expand Down Expand Up @@ -1979,7 +1979,7 @@ mod test {
let errors = resolve_src_code(src, vec!["main", "foo"]);
assert!(errors.is_empty());
if !errors.is_empty() {
println!("Unexpected errors: {:?}", errors);
println!("Unexpected errors: {errors:?}");
unreachable!("there should be no errors");
}

Expand Down Expand Up @@ -2021,7 +2021,7 @@ mod test {
"#;

let errors = resolve_src_code(src, vec!["main", "println"]);
assert!(errors.len() == 2, "Expected 2 errors, got: {:?}", errors);
assert!(errors.len() == 2, "Expected 2 errors, got: {errors:?}");

for err in errors {
match &err {
Expand Down
8 changes: 4 additions & 4 deletions compiler/noirc_frontend/src/lexer/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,8 @@ pub enum Attribute {
impl fmt::Display for Attribute {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Attribute::Function(attribute) => write!(f, "{}", attribute),
Attribute::Secondary(attribute) => write!(f, "{}", attribute),
Attribute::Function(attribute) => write!(f, "{attribute}"),
Attribute::Secondary(attribute) => write!(f, "{attribute}"),
}
}
}
Expand Down Expand Up @@ -527,7 +527,7 @@ impl FunctionAttribute {
impl fmt::Display for FunctionAttribute {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
FunctionAttribute::Test(scope) => write!(f, "#[test{}]", scope),
FunctionAttribute::Test(scope) => write!(f, "#[test{scope}]"),
FunctionAttribute::Foreign(ref k) => write!(f, "#[foreign({k})]"),
FunctionAttribute::Builtin(ref k) => write!(f, "#[builtin({k})]"),
FunctionAttribute::Oracle(ref k) => write!(f, "#[oracle({k})]"),
Expand Down Expand Up @@ -730,7 +730,7 @@ mod keywords {
for keyword in Keyword::iter() {
let resolved_token =
Keyword::lookup_keyword(&format!("{keyword}")).unwrap_or_else(|| {
panic!("Keyword::lookup_keyword couldn't find Keyword {}", keyword)
panic!("Keyword::lookup_keyword couldn't find Keyword {keyword}")
});

assert_eq!(
Expand Down
5 changes: 2 additions & 3 deletions compiler/noirc_frontend/src/parser/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1631,7 +1631,7 @@ mod test {
P: NoirParser<T>,
{
vecmap(programs, move |program| {
let message = format!("Failed to parse:\n{}", program);
let message = format!("Failed to parse:\n{program}");
let (op_t, diagnostics) = parse_recover(&parser, program);
diagnostics.iter().for_each(|diagnostic| {
if diagnostic.is_error() {
Expand Down Expand Up @@ -2356,8 +2356,7 @@ mod test {
let num_errors = errors.len();
let shown_errors = show_errors(errors);
eprintln!(
"\nExpected {} error(s) and got {}:\n\n{}\n\nFrom input: {}\nExpected AST: {}\nActual AST: {}\n",
expected_errors, num_errors, shown_errors, src, expected_result, actual);
"\nExpected {expected_errors} error(s) and got {num_errors}:\n\n{shown_errors}\n\nFrom input: {src}\nExpected AST: {expected_result}\nActual AST: {actual}\n");
}
result
});
Expand Down
2 changes: 1 addition & 1 deletion compiler/wasm/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ fn add_noir_lib(context: &mut Context, library_name: &str) {
context
.crate_graph
.add_dep(crate_id, library_name.parse().unwrap(), library_crate_id)
.unwrap_or_else(|_| panic!("ICE: Cyclic error triggered by {} library", library_name));
.unwrap_or_else(|_| panic!("ICE: Cyclic error triggered by {library_name} library"));
}
}

Expand Down
14 changes: 4 additions & 10 deletions tooling/lsp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ fn on_tests_request(
// We can reconsider this when we can build a file without the need for a Nargo.toml file to resolve deps
let _ = state.client.log_message(LogMessageParams {
typ: MessageType::WARNING,
message: format!("{}", err),
message: err.to_string(),
});
return future::ready(Ok(None));
}
Expand All @@ -318,10 +318,7 @@ fn on_tests_request(
Ok(workspace) => workspace,
Err(err) => {
// If we found a manifest, but the workspace is invalid, we raise an error about it
return future::ready(Err(ResponseError::new(
ErrorCode::REQUEST_FAILED,
format!("{}", err),
)));
return future::ready(Err(ResponseError::new(ErrorCode::REQUEST_FAILED, err)));
}
};

Expand Down Expand Up @@ -382,7 +379,7 @@ fn on_code_lens_request(
// We can reconsider this when we can build a file without the need for a Nargo.toml file to resolve deps
let _ = state.client.log_message(LogMessageParams {
typ: MessageType::WARNING,
message: format!("{err}"),
message: err.to_string(),
});
return future::ready(Ok(None));
}
Expand All @@ -391,10 +388,7 @@ fn on_code_lens_request(
Ok(workspace) => workspace,
Err(err) => {
// If we found a manifest, but the workspace is invalid, we raise an error about it
return future::ready(Err(ResponseError::new(
ErrorCode::REQUEST_FAILED,
format!("{err}"),
)));
return future::ready(Err(ResponseError::new(ErrorCode::REQUEST_FAILED, err)));
}
};

Expand Down
2 changes: 1 addition & 1 deletion tooling/nargo_cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ fn generate_compile_success_empty_tests(test_file: &mut File, test_data_dir: &Pa
r#"
#[test]
fn compile_success_empty_{test_name}() {{

// We use a mocked backend for this test as we do not rely on the returned circuit size
// but we must call a backend as part of querying the number of opcodes in the circuit.

Expand Down