diff --git a/bindgen/codegen/impl_partialeq.rs b/bindgen/codegen/impl_partialeq.rs index 42fabf6ad0..6c7b43959b 100644 --- a/bindgen/codegen/impl_partialeq.rs +++ b/bindgen/codegen/impl_partialeq.rs @@ -23,7 +23,7 @@ pub(crate) fn gen_partialeq_impl( &self.bindgen_union_field[..] == &other.bindgen_union_field[..] }); } else { - for base in comp_info.base_members().iter() { + for base in comp_info.base_members() { if !base.requires_storage(ctx) { continue; } diff --git a/bindgen/codegen/mod.rs b/bindgen/codegen/mod.rs index c58237c17b..67c329ca18 100644 --- a/bindgen/codegen/mod.rs +++ b/bindgen/codegen/mod.rs @@ -3653,7 +3653,7 @@ impl CodeGenerator for Enum { DerivableTraits::EQ, ); let mut derives: Vec<_> = derives.into(); - for derive in item.annotations().derives().iter() { + for derive in item.annotations().derives() { if !derives.contains(&derive.as_str()) { derives.push(derive); } @@ -4944,7 +4944,7 @@ impl CodeGenerator for ObjCInterface { }; result.push(struct_block); let mut protocol_set: HashSet = Default::default(); - for protocol_id in self.conforms_to.iter() { + for protocol_id in &self.conforms_to { protocol_set.insert(*protocol_id); let protocol_name = ctx.rust_ident( ctx.resolve_type(protocol_id.expect_type_id(ctx)) @@ -4989,7 +4989,7 @@ impl CodeGenerator for ObjCInterface { } }; result.push(impl_trait); - for protocol_id in parent.conforms_to.iter() { + for protocol_id in &parent.conforms_to { if protocol_set.insert(*protocol_id) { let protocol_name = ctx.rust_ident( ctx.resolve_type(protocol_id.expect_type_id(ctx)) diff --git a/bindgen/ir/analysis/mod.rs b/bindgen/ir/analysis/mod.rs index 731080cb4e..cd47c4b141 100644 --- a/bindgen/ir/analysis/mod.rs +++ b/bindgen/ir/analysis/mod.rs @@ -280,9 +280,9 @@ mod tests { fn reverse(&self) -> Graph { let mut reversed = Graph::default(); - for (node, edges) in self.0.iter() { + for (node, edges) in &self.0 { reversed.0.entry(*node).or_insert_with(Vec::new); - for referent in edges.iter() { + for referent in edges { reversed .0 .entry(*referent) @@ -331,7 +331,7 @@ mod tests { let original_size = self.reachable.entry(node).or_default().len(); - for sub_node in self.graph.0[&node].iter() { + for sub_node in &self.graph.0[&node] { self.reachable.get_mut(&node).unwrap().insert(*sub_node); let sub_reachable = @@ -354,7 +354,7 @@ mod tests { where F: FnMut(Node), { - for dep in self.reversed.0[&node].iter() { + for dep in &self.reversed.0[&node] { f(*dep); } } diff --git a/bindgen/ir/analysis/template_params.rs b/bindgen/ir/analysis/template_params.rs index 778a515d4c..309cddf73f 100644 --- a/bindgen/ir/analysis/template_params.rs +++ b/bindgen/ir/analysis/template_params.rs @@ -464,7 +464,7 @@ impl<'ctx> MonotoneFramework for UsedTemplateParameters<'ctx> { // (This is so that every item we call `constrain` on is guaranteed // to have a set of template parameters, and we can allow // blocklisted templates to use all of their parameters). - for item in allowlisted_items.iter() { + for item in &allowlisted_items { extra_assert!(used.contains_key(item)); extra_assert!(dependencies.contains_key(item)); item.trace( diff --git a/bindgen/ir/comp.rs b/bindgen/ir/comp.rs index 68884bd20a..b3c72cd8e1 100644 --- a/bindgen/ir/comp.rs +++ b/bindgen/ir/comp.rs @@ -1162,14 +1162,14 @@ impl CompInfo { match self.fields { CompFields::Error => {} CompFields::After { ref fields, .. } => { - for field in fields.iter() { + for field in fields { if let Some(layout) = field.layout(ctx) { callback(layout); } } } CompFields::Before(ref raw_fields) => { - for field in raw_fields.iter() { + for field in raw_fields { let field_ty = ctx.resolve_type(field.0.ty); if let Some(layout) = field_ty.layout(ctx) { callback(layout); @@ -1673,7 +1673,7 @@ impl CompInfo { pub(crate) fn already_packed(&self, ctx: &BindgenContext) -> Option { let mut total_size: usize = 0; - for field in self.fields().iter() { + for field in self.fields() { let layout = field.layout(ctx)?; if layout.align != 0 && total_size % layout.align != 0 { diff --git a/bindgen/ir/context.rs b/bindgen/ir/context.rs index d8bcaba1d4..8a4d8dbd22 100644 --- a/bindgen/ir/context.rs +++ b/bindgen/ir/context.rs @@ -2062,7 +2062,7 @@ If you encounter an error missing from this list, please file an issue or a PR!" let mut header_names_to_compile = Vec::new(); let mut header_paths = Vec::new(); let mut header_contents = String::new(); - for input_header in self.options.input_headers.iter() { + for input_header in &self.options.input_headers { let path = Path::new(input_header.as_ref()); if let Some(header_path) = path.parent() { if header_path == Path::new("") { diff --git a/bindgen/ir/objc.rs b/bindgen/ir/objc.rs index 6d83095924..81560da4d1 100644 --- a/bindgen/ir/objc.rs +++ b/bindgen/ir/objc.rs @@ -301,7 +301,7 @@ impl ObjCMethod { // Get arguments without type signatures to pass to `msg_send!` let mut args_without_types = vec![]; - for arg in args.iter() { + for arg in args { let arg = arg.to_string(); let name_and_sig: Vec<&str> = arg.split(' ').collect(); let name = name_and_sig[0]; diff --git a/bindgen/lib.rs b/bindgen/lib.rs index e599f759c7..57eb537434 100644 --- a/bindgen/lib.rs +++ b/bindgen/lib.rs @@ -928,7 +928,7 @@ impl Bindings { )?; } - for line in self.options.raw_lines.iter() { + for line in &self.options.raw_lines { writer.write_all(line.as_bytes())?; writer.write_all(NL.as_bytes())?; } @@ -1103,7 +1103,7 @@ fn parse(context: &mut BindgenContext) -> Result<(), BindgenError> { use clang_sys::*; let mut error = None; - for d in context.translation_unit().diags().iter() { + for d in &context.translation_unit().diags() { let msg = d.format(); let is_err = d.severity() >= CXDiagnostic_Error; if is_err { diff --git a/bindgen/options/mod.rs b/bindgen/options/mod.rs index 4e68dfb7cd..6bf652d4e1 100644 --- a/bindgen/options/mod.rs +++ b/bindgen/options/mod.rs @@ -1143,7 +1143,7 @@ options! { }, as_args: |module_lines, args| { for (module, lines) in module_lines { - for line in lines.iter() { + for line in lines { args.push("--module-raw-line".to_owned()); args.push(module.clone().into()); args.push(line.clone().into()); diff --git a/bindgen/regex_set.rs b/bindgen/regex_set.rs index be0041dcfa..17e9708385 100644 --- a/bindgen/regex_set.rs +++ b/bindgen/regex_set.rs @@ -128,7 +128,7 @@ impl RegexSet { if !matches.matched_any() { return false; } - for i in matches.iter() { + for i in &matches { self.matched[i].set(true); }