Skip to content

Commit

Permalink
Removed some nightly clippy diagnostics. (#4576)
Browse files Browse the repository at this point in the history
  • Loading branch information
orizi authored Dec 17, 2023
1 parent 51c72c8 commit f4cac86
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 28 deletions.
2 changes: 1 addition & 1 deletion crates/cairo-lang-diagnostics/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ impl<TEntry: DiagnosticEntry> DiagnosticsBuilder<TEntry> {
self.subtrees.push(diagnostics);
}
pub fn build(self) -> Diagnostics<TEntry> {
Diagnostics(Arc::new(self))
Diagnostics(self.into())
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/cairo-lang-lowering/src/destructs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ pub fn add_destructs(
];
lowered.blocks[block_id]
.statements
.splice(insert_index..insert_index, statements.into_iter());
.splice(insert_index..insert_index, statements);
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions crates/cairo-lang-lowering/src/lower/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use cairo_lang_syntax::node::ids::SyntaxStablePtrId;
use cairo_lang_utils::ordered_hash_map::OrderedHashMap;
use cairo_lang_utils::unordered_hash_map::UnorderedHashMap;
use cairo_lang_utils::{extract_matches, try_extract_matches};
use itertools::{chain, zip_eq, Itertools};
use itertools::{chain, izip, zip_eq, Itertools};
use num_bigint::{BigInt, Sign};
use semantic::corelib::{
core_felt252_ty, core_submodule, get_core_function_id, get_core_ty_by_name, get_function_id,
Expand Down Expand Up @@ -408,8 +408,7 @@ fn lower_single_pattern(
})
.collect(),
};
for (var_id, (_, member)) in
generator.add(ctx, &mut builder.statements).into_iter().zip(members.into_iter())
for (var_id, (_, member)) in izip!(generator.add(ctx, &mut builder.statements), members)
{
if let Some(member_pattern) = required_members.remove(&member.id) {
let member_pattern = ctx.function_body.patterns[*member_pattern].clone();
Expand Down
4 changes: 1 addition & 3 deletions crates/cairo-lang-sierra-gas/src/core_libfunc_cost_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,9 +631,7 @@ fn u128_libfunc_cost(libfunc: &Uint128Concrete) -> Vec<BranchCost> {
}
Uint128Concrete::ByteReverse(_) => vec![BranchCost::Regular {
const_cost: ConstCost::steps(24),
pre_cost: PreCost(OrderedHashMap::from_iter(
(vec![(CostTokenType::Bitwise, 4)]).into_iter(),
)),
pre_cost: PreCost(OrderedHashMap::from_iter([(CostTokenType::Bitwise, 4)])),
}],
}
}
Expand Down
9 changes: 3 additions & 6 deletions crates/cairo-lang-sierra-to-casm/src/invocations/ec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,16 +414,13 @@ fn build_ec_state_finalize(
tempvar numerator = y + random_y;
}

let (result_x, result_y) =
add_ec_points_inner(&mut casm_builder, (x, y), random_x, numerator, denominator);
let result_x_y: [Var; 2] =
add_ec_points_inner(&mut casm_builder, (x, y), random_x, numerator, denominator).into();

let failure_handle = get_non_fallthrough_statement_id(&builder);
Ok(builder.build_from_casm_builder(
casm_builder,
[
("Fallthrough", &[&[result_x, result_y]], None),
("SumIsInfinity", &[], Some(failure_handle)),
],
[("Fallthrough", &[&result_x_y], None), ("SumIsInfinity", &[], Some(failure_handle))],
Default::default(),
))
}
Expand Down
14 changes: 5 additions & 9 deletions crates/cairo-lang-sierra/src/simulation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ impl SimulationContext<'_> {
});
}
let mut state = HashMap::<VarId, CoreValue>::from_iter(
izip!(func.params.iter(), inputs.into_iter())
.map(|(param, input)| (param.id.clone(), input)),
izip!(func.params.iter(), inputs).map(|(param, input)| (param.id.clone(), input)),
);
loop {
let statement = self
Expand Down Expand Up @@ -120,13 +119,10 @@ impl SimulationContext<'_> {
current_statement_id,
)?;
let branch_info = &invocation.branches[chosen_branch];
state = put_results(
remaining,
izip!(branch_info.results.iter(), outputs.into_iter()),
)
.map_err(|error| {
SimulationError::EditStateError(error, current_statement_id)
})?;
state = put_results(remaining, izip!(branch_info.results.iter(), outputs))
.map_err(|error| {
SimulationError::EditStateError(error, current_statement_id)
})?;
current_statement_id = current_statement_id.next(&branch_info.target);
}
}
Expand Down
9 changes: 4 additions & 5 deletions crates/cairo-lang-starknet/src/felt252_vec_compression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub fn compress<Result: Extend<BigUintAsHex>>(values: &[BigUintAsHex], result: &
packed_value *= padded_code_size;
packed_value += code[&value.value];
}
result.extend([BigUintAsHex { value: packed_value }].into_iter());
result.extend([BigUintAsHex { value: packed_value }]);
}
}

Expand All @@ -51,10 +51,9 @@ pub fn decompress<Result: Extend<BigUintAsHex>>(
let mut v = packed_value.value.clone();
for _ in 0..curr_words {
let (remaining, code_word) = v.div_mod_floor(&padded_code_size);
result.extend(
[BigUintAsHex { value: code.get(code_word.to_usize().unwrap())?.value.clone() }]
.into_iter(),
);
result.extend([BigUintAsHex {
value: code.get(code_word.to_usize().unwrap())?.value.clone(),
}]);
v = remaining;
}
remaining_unpacked_size -= curr_words;
Expand Down

0 comments on commit f4cac86

Please sign in to comment.