Skip to content

Commit

Permalink
Linting semicolons
Browse files Browse the repository at this point in the history
```
cargo clippy --workspace --fix --all-targets -- -A clippy::all -W clippy::semicolon_if_nothing_returned
```
  • Loading branch information
nyurik authored and pvdrz committed Dec 1, 2024
1 parent fab3026 commit 6f0b754
Show file tree
Hide file tree
Showing 24 changed files with 61 additions and 60 deletions.
2 changes: 1 addition & 1 deletion bindgen-cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub fn main() {

std::panic::set_hook(Box::new(move |info| {
if verbose {
print_verbose_err()
print_verbose_err();
}
eprintln!("{info}");
}));
Expand Down
4 changes: 4 additions & 0 deletions bindgen-tests/tests/expectations/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ objc = "0.2"
# deprecated = "allow"
# invalid-value = "allow"
# unsupported_calling_conventions = "allow"
dead_code = "allow"
non-snake-case = "allow"
non_camel_case_types = "allow"
non_upper_case_globals = "allow"
unexpected-cfgs = "allow"

[lints.clippy]
Expand All @@ -30,6 +33,7 @@ manual-c-str-literals = "allow"
missing-safety-doc = "allow"
op-ref = "allow"
ptr-offset-with-cast = "allow"
semicolon_if_nothing_returned = "allow"
too-many-arguments = "allow"
transmute-int-to-bool = "allow"
unnecessary-cast = "allow"
Expand Down
3 changes: 0 additions & 3 deletions bindgen-tests/tests/expectations/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
#![allow(dead_code)]
#![allow(non_camel_case_types)]
#![allow(non_upper_case_globals)]
2 changes: 1 addition & 1 deletion bindgen-tests/tests/quickchecking/src/bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,5 @@ fn main() {
let generate_range = *matches.get_one::<usize>("range").unwrap();
let tests = *matches.get_one::<u64>("count").unwrap();

quickchecking::test_bindgen(generate_range, tests, output_path)
quickchecking::test_bindgen(generate_range, tests, output_path);
}
2 changes: 1 addition & 1 deletion bindgen-tests/tests/quickchecking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,5 @@ pub fn test_bindgen(
QuickCheck::new()
.tests(tests)
.gen(Gen::new(generate_range))
.quickcheck(bindgen_prop as fn(fuzzers::HeaderC) -> TestResult)
.quickcheck(bindgen_prop as fn(fuzzers::HeaderC) -> TestResult);
}
2 changes: 1 addition & 1 deletion bindgen/clang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,7 @@ impl Eq for Cursor {}

impl Hash for Cursor {
fn hash<H: Hasher>(&self, state: &mut H) {
unsafe { clang_hashCursor(self.x) }.hash(state)
unsafe { clang_hashCursor(self.x) }.hash(state);
}
}

Expand Down
22 changes: 11 additions & 11 deletions bindgen/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ impl CodeGenerator for Type {
// it to BindgenContext::compute_allowlisted_and_codegen_items.
}
TypeKind::TemplateInstantiation(ref inst) => {
inst.codegen(ctx, result, item)
inst.codegen(ctx, result, item);
}
TypeKind::BlockPointer(inner) => {
if !ctx.options().generate_block {
Expand Down Expand Up @@ -1141,7 +1141,7 @@ impl CodeGenerator for Type {
result.saw_objc();
}
TypeKind::ObjCInterface(ref interface) => {
interface.codegen(ctx, result, item)
interface.codegen(ctx, result, item);
}
ref u @ TypeKind::UnresolvedTypeRef(..) => {
unreachable!("Should have been resolved after parsing {u:?}!")
Expand Down Expand Up @@ -1228,7 +1228,7 @@ impl CodeGenerator for Vtable<'_> {
pub struct #name {
#( #methods ),*
}
})
});
} else {
// For the cases we don't support, simply generate an empty struct.
let void = helpers::ast_ty::c_void(ctx);
Expand Down Expand Up @@ -2321,7 +2321,7 @@ impl CodeGenerator for CompInfo {
let ty = helpers::blob(layout);
fields.push(quote! {
pub bindgen_union_field: #ty ,
})
});
}
}

Expand Down Expand Up @@ -2470,7 +2470,7 @@ impl CodeGenerator for CompInfo {
derives.extend(custom_derives.iter().map(|s| s.as_str()));

if !derives.is_empty() {
attributes.push(attributes::derives(&derives))
attributes.push(attributes::derives(&derives));
}

attributes.extend(
Expand Down Expand Up @@ -3094,7 +3094,7 @@ impl Method {
quote! {
__bindgen_tmp
}
})
});
}

let block = ctx.wrap_unsafe_ops(quote! ( #( #stmts );*));
Expand Down Expand Up @@ -4754,7 +4754,7 @@ fn unsupported_abi_diagnostic(
}
}

diag.display()
diag.display();
}
}

Expand Down Expand Up @@ -4791,7 +4791,7 @@ fn variadic_fn_diagnostic(
}
}

diag.display()
diag.display();
}
}

Expand Down Expand Up @@ -5221,10 +5221,10 @@ pub(crate) mod utils {
}
match ty.kind() {
TypeKind::Alias(type_id_alias) => {
type_id = *type_id_alias
type_id = *type_id_alias;
}
TypeKind::ResolvedTypeRef(type_id_typedef) => {
type_id = *type_id_typedef
type_id = *type_id_typedef;
}
_ => break,
}
Expand Down Expand Up @@ -5705,7 +5705,7 @@ pub(crate) mod utils {
.collect::<Vec<_>>();

if is_variadic {
args.push(quote! { ... })
args.push(quote! { ... });
}

args
Expand Down
6 changes: 3 additions & 3 deletions bindgen/codegen/postprocessing/merge_extern_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ use syn::{
};

pub(super) fn merge_extern_blocks(file: &mut File) {
Visitor.visit_file_mut(file)
Visitor.visit_file_mut(file);
}

struct Visitor;

impl VisitMut for Visitor {
fn visit_file_mut(&mut self, file: &mut File) {
visit_items(&mut file.items);
visit_file_mut(self, file)
visit_file_mut(self, file);
}

fn visit_item_mod_mut(&mut self, item_mod: &mut ItemMod) {
if let Some((_, ref mut items)) = item_mod.content {
visit_items(items);
}
visit_item_mod_mut(self, item_mod)
visit_item_mod_mut(self, item_mod);
}
}

Expand Down
6 changes: 3 additions & 3 deletions bindgen/codegen/postprocessing/sort_semantically.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ use syn::{
};

pub(super) fn sort_semantically(file: &mut File) {
Visitor.visit_file_mut(file)
Visitor.visit_file_mut(file);
}

struct Visitor;

impl VisitMut for Visitor {
fn visit_file_mut(&mut self, file: &mut File) {
visit_items(&mut file.items);
visit_file_mut(self, file)
visit_file_mut(self, file);
}

fn visit_item_mod_mut(&mut self, item_mod: &mut ItemMod) {
if let Some((_, ref mut items)) = item_mod.content {
visit_items(items);
}
visit_item_mod_mut(self, item_mod)
visit_item_mod_mut(self, item_mod);
}
}

Expand Down
14 changes: 7 additions & 7 deletions bindgen/codegen/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,13 @@ impl<'a> CSerialize<'a> for Type {
if self.is_const() {
write!(writer, "const ")?;
}
write!(writer, "void")?
write!(writer, "void")?;
}
TypeKind::NullPtr => {
if self.is_const() {
write!(writer, "const ")?;
}
write!(writer, "nullptr_t")?
write!(writer, "nullptr_t")?;
}
TypeKind::Int(int_kind) => {
if self.is_const() {
Expand Down Expand Up @@ -285,7 +285,7 @@ impl<'a> CSerialize<'a> for Type {
FloatKind::Float => write!(writer, "float complex")?,
FloatKind::Double => write!(writer, "double complex")?,
FloatKind::LongDouble => {
write!(writer, "long double complex")?
write!(writer, "long double complex")?;
}
FloatKind::Float128 => write!(writer, "__complex128")?,
}
Expand All @@ -303,7 +303,7 @@ impl<'a> CSerialize<'a> for Type {
}
TypeKind::Array(type_id, length) => {
type_id.serialize(ctx, (), stack, writer)?;
write!(writer, " [{length}]")?
write!(writer, " [{length}]")?;
}
TypeKind::Function(signature) => {
if self.is_const() {
Expand Down Expand Up @@ -341,22 +341,22 @@ impl<'a> CSerialize<'a> for Type {
type_id.serialize(ctx, (), &mut stack, buf)
},
)?;
write!(writer, ")")?
write!(writer, ")")?;
}
}
TypeKind::ResolvedTypeRef(type_id) => {
if self.is_const() {
write!(writer, "const ")?;
}
type_id.serialize(ctx, (), stack, writer)?
type_id.serialize(ctx, (), stack, writer)?;
}
TypeKind::Pointer(type_id) => {
if self.is_const() {
stack.push("*const ".to_owned());
} else {
stack.push("*".to_owned());
}
type_id.serialize(ctx, (), stack, writer)?
type_id.serialize(ctx, (), stack, writer)?;
}
TypeKind::Comp(comp_info) => {
if self.is_const() {
Expand Down
2 changes: 1 addition & 1 deletion bindgen/ir/analysis/has_vtable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl ops::BitOr for HasVtableResult {

impl ops::BitOrAssign for HasVtableResult {
fn bitor_assign(&mut self, rhs: HasVtableResult) {
*self = self.join(rhs)
*self = self.join(rhs);
}
}

Expand Down
2 changes: 1 addition & 1 deletion bindgen/ir/analysis/sizedness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl ops::BitOr for SizednessResult {

impl ops::BitOrAssign for SizednessResult {
fn bitor_assign(&mut self, rhs: SizednessResult) {
*self = self.join(rhs)
*self = self.join(rhs);
}
}

Expand Down
2 changes: 1 addition & 1 deletion bindgen/ir/analysis/template_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ impl<'ctx> MonotoneFramework for UsedTemplateParameters<'ctx> {
extra_assert!(dependencies.contains_key(&sub_item));
},
&(),
)
);
}
}

Expand Down
4 changes: 2 additions & 2 deletions bindgen/ir/annotations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ impl Annotations {
"replaces" => {
self.use_instead_of = Some(
attr.value.split("::").map(Into::into).collect(),
)
);
}
"derive" => self.derives.push(attr.value),
"attribute" => self.attributes.push(attr.value),
Expand All @@ -239,7 +239,7 @@ impl Annotations {
};
}
"accessor" => {
self.accessor_kind = Some(parse_accessor(&attr.value))
self.accessor_kind = Some(parse_accessor(&attr.value));
}
"constant" => self.constify_enum_variant = true,
_ => {}
Expand Down
2 changes: 1 addition & 1 deletion bindgen/ir/comp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1698,7 +1698,7 @@ impl CompInfo {
layout: Option<&Layout>,
) {
let packed = self.is_packed(ctx, layout);
self.fields.compute_bitfield_units(ctx, packed)
self.fields.compute_bitfield_units(ctx, packed);
}

/// Assign for each anonymous field a generated name.
Expand Down
6 changes: 3 additions & 3 deletions bindgen/ir/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2238,7 +2238,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
let mut module_name = None;
let spelling = cursor.spelling();
if !spelling.is_empty() {
module_name = Some(spelling)
module_name = Some(spelling);
}

let mut kind = ModuleKind::Normal;
Expand Down Expand Up @@ -2621,7 +2621,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"

/// Call if a bindgen complex is generated
pub(crate) fn generated_bindgen_complex(&self) {
self.generated_bindgen_complex.set(true)
self.generated_bindgen_complex.set(true);
}

/// Whether we need to generate the bindgen complex type
Expand All @@ -2631,7 +2631,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"

/// Call if a bindgen float16 is generated
pub(crate) fn generated_bindgen_float16(&self) {
self.generated_bindgen_float16.set(true)
self.generated_bindgen_float16.set(true);
}

/// Whether we need to generate the bindgen float16 type
Expand Down
2 changes: 1 addition & 1 deletion bindgen/ir/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,6 @@ impl ops::BitOr for CanDerive {

impl ops::BitOrAssign for CanDerive {
fn bitor_assign(&mut self, rhs: Self) {
*self = self.join(rhs)
*self = self.join(rhs);
}
}
4 changes: 2 additions & 2 deletions bindgen/ir/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ impl ClangSubItemParser for Module {
let module_id = ctx.module(cursor);
ctx.with_module(module_id, |ctx| {
cursor.visit_sorted(ctx, |ctx, child| {
parse_one(ctx, child, Some(module_id.into()))
})
parse_one(ctx, child, Some(module_id.into()));
});
});

Ok(ParseResult::AlreadyResolved(module_id.into()))
Expand Down
2 changes: 1 addition & 1 deletion bindgen/ir/objc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ impl ObjCMethod {
let arg = arg.to_string();
let name_and_sig: Vec<&str> = arg.split(' ').collect();
let name = name_and_sig[0];
args_without_types.push(Ident::new(name, Span::call_site()))
args_without_types.push(Ident::new(name, Span::call_site()));
}

let args = split_name.into_iter().zip(args_without_types).map(
Expand Down
4 changes: 2 additions & 2 deletions bindgen/ir/traversal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ where
F: FnMut(ItemId, EdgeKind),
{
fn visit_kind(&mut self, item: ItemId, kind: EdgeKind) {
(*self)(item, kind)
(*self)(item, kind);
}
}

Expand Down Expand Up @@ -437,7 +437,7 @@ where
let is_newly_discovered =
self.seen.add(self.currently_traversing, item);
if is_newly_discovered {
self.queue.push(item)
self.queue.push(item);
}
}
}
Expand Down
Loading

0 comments on commit 6f0b754

Please sign in to comment.