Fix clippy::explicit_iter_loop (pedantic)

“it is more concise to loop over references to containers instead of
using explicit iteration methods”

https://rust-lang.github.io/rust-clippy/master/index.html#explicit_iter_loop

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
Anders Kaseorg
2022-11-21 17:44:40 -08:00
committed by Charlie Marsh
parent 6b935121a7
commit 3dd6522b4f
6 changed files with 9 additions and 9 deletions

View File

@@ -2648,7 +2648,7 @@ impl<'a> Checker<'a> {
let mut unused: BTreeMap<(ImportKind, usize, Option<usize>), Vec<&str>> =
BTreeMap::new();
for (name, binding) in scope.values.iter() {
for (name, binding) in &scope.values {
if !matches!(
binding.kind,
BindingKind::Importation(..)

View File

@@ -51,7 +51,7 @@ pub fn check_boolean_default_value_in_function_definition(
checker: &mut Checker,
arguments: &Arguments,
) {
for arg in arguments.defaults.iter() {
for arg in &arguments.defaults {
add_if_boolean(
checker,
arg,

View File

@@ -31,7 +31,7 @@ where
}
ExprKind::Lambda { args, body } => {
visitor::walk_expr(self, body);
for arg in args.args.iter() {
for arg in &args.args {
self.names.remove(arg.node.arg.as_str());
}
}

View File

@@ -437,13 +437,13 @@ pub fn format_imports(
let mut is_first_statement = true;
// Format `StmtKind::Import` statements.
for (alias, comments) in import_block.import.iter() {
for (alias, comments) in &import_block.import {
output.append(&format::format_import(alias, comments, is_first_statement));
is_first_statement = false;
}
// Format `StmtKind::ImportFrom` statements.
for (import_from, comments, aliases) in import_block.import_from.iter() {
for (import_from, comments, aliases) in &import_block.import_from {
output.append(&format::format_import_from(
import_from,
comments,

View File

@@ -63,7 +63,7 @@ pub fn unused_variables(scope: &Scope, dummy_variable_rgx: &Regex) -> Vec<Check>
return checks;
}
for (&name, binding) in scope.values.iter() {
for (&name, binding) in &scope.values {
if binding.used.is_none()
&& matches!(binding.kind, BindingKind::Assignment)
&& !dummy_variable_rgx.is_match(name)

View File

@@ -129,14 +129,14 @@ impl Hash for Settings {
fn hash<H: Hasher>(&self, state: &mut H) {
// Add base properties in alphabetical order.
self.dummy_variable_rgx.as_str().hash(state);
for value in self.enabled.iter() {
for value in &self.enabled {
value.hash(state);
}
for value in self.fixable.iter() {
for value in &self.fixable {
value.hash(state);
}
self.line_length.hash(state);
for value in self.per_file_ignores.iter() {
for value in &self.per_file_ignores {
value.hash(state);
}
self.show_source.hash(state);