Skip to content

Fix explicit_iter_loop lint #3020

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

Merged
merged 1 commit into from
Dec 1, 2024
Merged
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
2 changes: 1 addition & 1 deletion bindgen/codegen/impl_partialeq.rs
Original file line number Diff line number Diff line change
@@ -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;
}
6 changes: 3 additions & 3 deletions bindgen/codegen/mod.rs
Original file line number Diff line number Diff line change
@@ -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<ItemId> = 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))
8 changes: 4 additions & 4 deletions bindgen/ir/analysis/mod.rs
Original file line number Diff line number Diff line change
@@ -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);
}
}
2 changes: 1 addition & 1 deletion bindgen/ir/analysis/template_params.rs
Original file line number Diff line number Diff line change
@@ -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(
6 changes: 3 additions & 3 deletions bindgen/ir/comp.rs
Original file line number Diff line number Diff line change
@@ -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<bool> {
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 {
2 changes: 1 addition & 1 deletion bindgen/ir/context.rs
Original file line number Diff line number Diff line change
@@ -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("") {
2 changes: 1 addition & 1 deletion bindgen/ir/objc.rs
Original file line number Diff line number Diff line change
@@ -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];
4 changes: 2 additions & 2 deletions bindgen/lib.rs
Original file line number Diff line number Diff line change
@@ -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 {
2 changes: 1 addition & 1 deletion bindgen/options/mod.rs
Original file line number Diff line number Diff line change
@@ -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());
2 changes: 1 addition & 1 deletion bindgen/regex_set.rs
Original file line number Diff line number Diff line change
@@ -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);
}

Loading