Skip to content

Commit 8f21aa6

Browse files
nyurikpvdrz
authored andcommitted
Fix explicit_iter_loop lint
``` cargo clippy --fix --workspace --exclude bindgen-integration --exclude tests_expectations -- -W clippy::explicit_iter_loop ```
1 parent 4eb99c7 commit 8f21aa6

File tree

10 files changed

+18
-18
lines changed

10 files changed

+18
-18
lines changed

bindgen/codegen/impl_partialeq.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub(crate) fn gen_partialeq_impl(
2323
&self.bindgen_union_field[..] == &other.bindgen_union_field[..]
2424
});
2525
} else {
26-
for base in comp_info.base_members().iter() {
26+
for base in comp_info.base_members() {
2727
if !base.requires_storage(ctx) {
2828
continue;
2929
}

bindgen/codegen/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3653,7 +3653,7 @@ impl CodeGenerator for Enum {
36533653
DerivableTraits::EQ,
36543654
);
36553655
let mut derives: Vec<_> = derives.into();
3656-
for derive in item.annotations().derives().iter() {
3656+
for derive in item.annotations().derives() {
36573657
if !derives.contains(&derive.as_str()) {
36583658
derives.push(derive);
36593659
}
@@ -4944,7 +4944,7 @@ impl CodeGenerator for ObjCInterface {
49444944
};
49454945
result.push(struct_block);
49464946
let mut protocol_set: HashSet<ItemId> = Default::default();
4947-
for protocol_id in self.conforms_to.iter() {
4947+
for protocol_id in &self.conforms_to {
49484948
protocol_set.insert(*protocol_id);
49494949
let protocol_name = ctx.rust_ident(
49504950
ctx.resolve_type(protocol_id.expect_type_id(ctx))
@@ -4989,7 +4989,7 @@ impl CodeGenerator for ObjCInterface {
49894989
}
49904990
};
49914991
result.push(impl_trait);
4992-
for protocol_id in parent.conforms_to.iter() {
4992+
for protocol_id in &parent.conforms_to {
49934993
if protocol_set.insert(*protocol_id) {
49944994
let protocol_name = ctx.rust_ident(
49954995
ctx.resolve_type(protocol_id.expect_type_id(ctx))

bindgen/ir/analysis/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,9 @@ mod tests {
280280

281281
fn reverse(&self) -> Graph {
282282
let mut reversed = Graph::default();
283-
for (node, edges) in self.0.iter() {
283+
for (node, edges) in &self.0 {
284284
reversed.0.entry(*node).or_insert_with(Vec::new);
285-
for referent in edges.iter() {
285+
for referent in edges {
286286
reversed
287287
.0
288288
.entry(*referent)
@@ -331,7 +331,7 @@ mod tests {
331331

332332
let original_size = self.reachable.entry(node).or_default().len();
333333

334-
for sub_node in self.graph.0[&node].iter() {
334+
for sub_node in &self.graph.0[&node] {
335335
self.reachable.get_mut(&node).unwrap().insert(*sub_node);
336336

337337
let sub_reachable =
@@ -354,7 +354,7 @@ mod tests {
354354
where
355355
F: FnMut(Node),
356356
{
357-
for dep in self.reversed.0[&node].iter() {
357+
for dep in &self.reversed.0[&node] {
358358
f(*dep);
359359
}
360360
}

bindgen/ir/analysis/template_params.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ impl<'ctx> MonotoneFramework for UsedTemplateParameters<'ctx> {
464464
// (This is so that every item we call `constrain` on is guaranteed
465465
// to have a set of template parameters, and we can allow
466466
// blocklisted templates to use all of their parameters).
467-
for item in allowlisted_items.iter() {
467+
for item in &allowlisted_items {
468468
extra_assert!(used.contains_key(item));
469469
extra_assert!(dependencies.contains_key(item));
470470
item.trace(

bindgen/ir/comp.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,14 +1162,14 @@ impl CompInfo {
11621162
match self.fields {
11631163
CompFields::Error => {}
11641164
CompFields::After { ref fields, .. } => {
1165-
for field in fields.iter() {
1165+
for field in fields {
11661166
if let Some(layout) = field.layout(ctx) {
11671167
callback(layout);
11681168
}
11691169
}
11701170
}
11711171
CompFields::Before(ref raw_fields) => {
1172-
for field in raw_fields.iter() {
1172+
for field in raw_fields {
11731173
let field_ty = ctx.resolve_type(field.0.ty);
11741174
if let Some(layout) = field_ty.layout(ctx) {
11751175
callback(layout);
@@ -1672,7 +1672,7 @@ impl CompInfo {
16721672
pub(crate) fn already_packed(&self, ctx: &BindgenContext) -> Option<bool> {
16731673
let mut total_size: usize = 0;
16741674

1675-
for field in self.fields().iter() {
1675+
for field in self.fields() {
16761676
let layout = field.layout(ctx)?;
16771677

16781678
if layout.align != 0 && total_size % layout.align != 0 {

bindgen/ir/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2055,7 +2055,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
20552055
let mut header_names_to_compile = Vec::new();
20562056
let mut header_paths = Vec::new();
20572057
let mut header_contents = String::new();
2058-
for input_header in self.options.input_headers.iter() {
2058+
for input_header in &self.options.input_headers {
20592059
let path = Path::new(input_header.as_ref());
20602060
if let Some(header_path) = path.parent() {
20612061
if header_path == Path::new("") {

bindgen/ir/objc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ impl ObjCMethod {
301301

302302
// Get arguments without type signatures to pass to `msg_send!`
303303
let mut args_without_types = vec![];
304-
for arg in args.iter() {
304+
for arg in args {
305305
let arg = arg.to_string();
306306
let name_and_sig: Vec<&str> = arg.split(' ').collect();
307307
let name = name_and_sig[0];

bindgen/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ impl Bindings {
929929
)?;
930930
}
931931

932-
for line in self.options.raw_lines.iter() {
932+
for line in &self.options.raw_lines {
933933
writer.write_all(line.as_bytes())?;
934934
writer.write_all(NL.as_bytes())?;
935935
}
@@ -1104,7 +1104,7 @@ fn parse(context: &mut BindgenContext) -> Result<(), BindgenError> {
11041104
use clang_sys::*;
11051105

11061106
let mut error = None;
1107-
for d in context.translation_unit().diags().iter() {
1107+
for d in &context.translation_unit().diags() {
11081108
let msg = d.format();
11091109
let is_err = d.severity() >= CXDiagnostic_Error;
11101110
if is_err {

bindgen/options/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,7 @@ options! {
11431143
},
11441144
as_args: |module_lines, args| {
11451145
for (module, lines) in module_lines {
1146-
for line in lines.iter() {
1146+
for line in lines {
11471147
args.push("--module-raw-line".to_owned());
11481148
args.push(module.clone().into());
11491149
args.push(line.clone().into());

bindgen/regex_set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl RegexSet {
128128
if !matches.matched_any() {
129129
return false;
130130
}
131-
for i in matches.iter() {
131+
for i in &matches {
132132
self.matched[i].set(true);
133133
}
134134

0 commit comments

Comments
 (0)