Skip to content

Fix if_not_else lint #3022

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
Show file tree
Hide file tree
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
12 changes: 6 additions & 6 deletions bindgen/clang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@ impl Cursor {
})
.or_else(|| {
let canonical = self.canonical();
if canonical != *self {
canonical.num_template_args()
} else {
if canonical == *self {
None
} else {
canonical.num_template_args()
}
})
}
Expand Down Expand Up @@ -1447,10 +1447,10 @@ impl Type {
/// elements.
pub(crate) fn num_elements(&self) -> Option<usize> {
let num_elements_returned = unsafe { clang_getNumElements(self.x) };
if num_elements_returned != -1 {
Some(num_elements_returned as usize)
} else {
if num_elements_returned == -1 {
None
} else {
Some(num_elements_returned as usize)
}
}

Expand Down
12 changes: 6 additions & 6 deletions bindgen/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2777,13 +2777,13 @@ impl CodeGenerator for CompInfo {
item,
&ty_for_impl,
) {
let partialeq_bounds = if !generic_param_names.is_empty() {
let partialeq_bounds = if generic_param_names.is_empty() {
quote! {}
} else {
let bounds = generic_param_names.iter().map(|t| {
quote! { #t: PartialEq }
});
quote! { where #( #bounds ),* }
} else {
quote! {}
};

let prefix = ctx.trait_prefix();
Expand Down Expand Up @@ -3444,10 +3444,10 @@ impl<'a> EnumBuilder<'a> {
emitted_any_variants,
..
} => {
let variants = if !emitted_any_variants {
quote!(__bindgen_cannot_repr_c_on_empty_enum = 0)
} else {
let variants = if emitted_any_variants {
tokens
} else {
quote!(__bindgen_cannot_repr_c_on_empty_enum = 0)
};

quote! {
Expand Down
2 changes: 1 addition & 1 deletion bindgen/ir/analysis/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,6 @@ pub(crate) fn as_cannot_derive_set(
) -> HashSet<ItemId> {
can_derive
.into_iter()
.filter_map(|(k, v)| if v != CanDerive::Yes { Some(k) } else { None })
.filter_map(|(k, v)| if v == CanDerive::Yes { None } else { Some(k) })
.collect()
}
6 changes: 3 additions & 3 deletions bindgen/ir/analysis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,10 @@ mod tests {
}

let new_size = self.reachable[&node].len();
if original_size != new_size {
ConstrainResult::Changed
} else {
if original_size == new_size {
ConstrainResult::Same
} else {
ConstrainResult::Changed
}
}

Expand Down
6 changes: 3 additions & 3 deletions bindgen/ir/analysis/template_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,10 +570,10 @@ impl<'ctx> MonotoneFramework for UsedTemplateParameters<'ctx> {
self.used.insert(id, Some(used_by_this_id));
extra_assert!(self.used.values().all(|v| v.is_some()));

if new_len != original_len {
ConstrainResult::Changed
} else {
if new_len == original_len {
ConstrainResult::Same
} else {
ConstrainResult::Changed
}
}

Expand Down
6 changes: 3 additions & 3 deletions bindgen/ir/annotations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,10 @@ impl Annotations {
"derive" => self.derives.push(attr.value),
"attribute" => self.attributes.push(attr.value),
"private" => {
self.visibility_kind = if attr.value != "false" {
Some(FieldVisibilityKind::Private)
} else {
self.visibility_kind = if attr.value == "false" {
Some(FieldVisibilityKind::Public)
} else {
Some(FieldVisibilityKind::Private)
};
}
"accessor" => {
Expand Down
6 changes: 3 additions & 3 deletions bindgen/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1123,10 +1123,10 @@ fn parse(context: &mut BindgenContext) -> Result<(), BindgenError> {

if context.options().emit_ast {
fn dump_if_not_builtin(cur: &clang::Cursor) -> CXChildVisitResult {
if !cur.is_builtin() {
clang::ast_dump(cur, 0)
} else {
if cur.is_builtin() {
CXChildVisit_Continue
} else {
clang::ast_dump(cur, 0)
}
}
cursor.visit(|cur| dump_if_not_builtin(&cur));
Expand Down
Loading