summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poveda Ruiz <31802960+pvdrz@users.noreply.github.com>2022-11-02 13:32:32 -0500
committerGitHub <noreply@github.com>2022-11-02 13:32:32 -0500
commit83426897af20d938fb4dca879d54de456ab96d6b (patch)
tree0aaa72e7d417aced81b5727e7038b5c103925d3f
parenta2fe04cbafaf0c7b40979e1cc505a90d76f4d099 (diff)
Fix clippy warnings (#2331)
-rw-r--r--bindgen/codegen/mod.rs10
-rw-r--r--bindgen/ir/context.rs18
-rw-r--r--bindgen/ir/enum_ty.rs2
-rw-r--r--bindgen/ir/item.rs2
-rw-r--r--bindgen/lib.rs22
5 files changed, 26 insertions, 28 deletions
diff --git a/bindgen/codegen/mod.rs b/bindgen/codegen/mod.rs
index 7e0d7aa0..bf0b3356 100644
--- a/bindgen/codegen/mod.rs
+++ b/bindgen/codegen/mod.rs
@@ -85,7 +85,7 @@ fn root_import(
let mut path = top_level_path(ctx, module);
let root = ctx.root_module().canonical_name(ctx);
- let root_ident = ctx.rust_ident(&root);
+ let root_ident = ctx.rust_ident(root);
path.push(quote! { #root_ident });
let mut tokens = quote! {};
@@ -797,7 +797,7 @@ impl CodeGenerator for Type {
}
};
- let rust_name = ctx.rust_ident(&name);
+ let rust_name = ctx.rust_ident(name);
let mut tokens = if let Some(comment) = item.comment(ctx) {
attributes::doc(comment)
@@ -1076,7 +1076,7 @@ impl<'a> CodeGenerator for Vtable<'a> {
) {
assert_eq!(item.id(), self.item_id);
debug_assert!(item.is_enabled_for_codegen(ctx));
- let name = ctx.rust_ident(&self.canonical_name(ctx));
+ let name = ctx.rust_ident(self.canonical_name(ctx));
// For now, we will only generate vtables for classes that:
// - do not inherit from others (compilers merge VTable from primary parent class).
@@ -1582,7 +1582,7 @@ impl<'a> FieldCodegen<'a> for BitfieldUnit {
{
let align_field_name = format!("_bitfield_align_{}", self.nth());
- let align_field_ident = ctx.rust_ident(&align_field_name);
+ let align_field_ident = ctx.rust_ident(align_field_name);
let align_ty = match self.layout().align {
n if n >= 8 => quote! { u64 },
4 => quote! { u32 },
@@ -3875,7 +3875,7 @@ impl TryToRustTy for Type {
}
TypeKind::TypeParam => {
let name = item.canonical_name(ctx);
- let ident = ctx.rust_ident(&name);
+ let ident = ctx.rust_ident(name);
Ok(quote! {
#ident
})
diff --git a/bindgen/ir/context.rs b/bindgen/ir/context.rs
index ba2db112..d987534d 100644
--- a/bindgen/ir/context.rs
+++ b/bindgen/ir/context.rs
@@ -2076,7 +2076,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
self.in_codegen_phase(),
"You're not supposed to call this yet"
);
- self.options.opaque_types.matches(&path[1..].join("::"))
+ self.options.opaque_types.matches(path[1..].join("::"))
}
/// Get the options used to configure this bindgen context.
@@ -2314,7 +2314,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
if self
.options()
.allowlisted_files
- .matches(&filename)
+ .matches(filename)
{
return true;
}
@@ -2389,7 +2389,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
);
let name = prefix_path[1..].join("::");
prefix_path.pop().unwrap();
- self.options().allowlisted_vars.matches(&name)
+ self.options().allowlisted_vars.matches(name)
})
}
}
@@ -2671,37 +2671,37 @@ If you encounter an error missing from this list, please file an issue or a PR!"
/// Check if `--no-partialeq` flag is enabled for this item.
pub fn no_partialeq_by_name(&self, item: &Item) -> bool {
let name = item.path_for_allowlisting(self)[1..].join("::");
- self.options().no_partialeq_types.matches(&name)
+ self.options().no_partialeq_types.matches(name)
}
/// Check if `--no-copy` flag is enabled for this item.
pub fn no_copy_by_name(&self, item: &Item) -> bool {
let name = item.path_for_allowlisting(self)[1..].join("::");
- self.options().no_copy_types.matches(&name)
+ self.options().no_copy_types.matches(name)
}
/// Check if `--no-debug` flag is enabled for this item.
pub fn no_debug_by_name(&self, item: &Item) -> bool {
let name = item.path_for_allowlisting(self)[1..].join("::");
- self.options().no_debug_types.matches(&name)
+ self.options().no_debug_types.matches(name)
}
/// Check if `--no-default` flag is enabled for this item.
pub fn no_default_by_name(&self, item: &Item) -> bool {
let name = item.path_for_allowlisting(self)[1..].join("::");
- self.options().no_default_types.matches(&name)
+ self.options().no_default_types.matches(name)
}
/// Check if `--no-hash` flag is enabled for this item.
pub fn no_hash_by_name(&self, item: &Item) -> bool {
let name = item.path_for_allowlisting(self)[1..].join("::");
- self.options().no_hash_types.matches(&name)
+ self.options().no_hash_types.matches(name)
}
/// Check if `--must-use-type` flag is enabled for this item.
pub fn must_use_type_by_name(&self, item: &Item) -> bool {
let name = item.path_for_allowlisting(self)[1..].join("::");
- self.options().must_use_types.matches(&name)
+ self.options().must_use_types.matches(name)
}
}
diff --git a/bindgen/ir/enum_ty.rs b/bindgen/ir/enum_ty.rs
index 123d1d79..059ee012 100644
--- a/bindgen/ir/enum_ty.rs
+++ b/bindgen/ir/enum_ty.rs
@@ -156,7 +156,7 @@ impl Enum {
let path = item.path_for_allowlisting(ctx);
let enum_ty = item.expect_type();
- if enums.matches(&path[1..].join("::")) {
+ if enums.matches(path[1..].join("::")) {
return true;
}
diff --git a/bindgen/ir/item.rs b/bindgen/ir/item.rs
index 3b15cd6e..1f4ac154 100644
--- a/bindgen/ir/item.rs
+++ b/bindgen/ir/item.rs
@@ -650,7 +650,7 @@ impl Item {
if let Some(location) = &self.location {
let (file, _, _, _) = location.location();
if let Some(filename) = file.name() {
- if ctx.options().blocklisted_files.matches(&filename) {
+ if ctx.options().blocklisted_files.matches(filename) {
return true;
}
}
diff --git a/bindgen/lib.rs b/bindgen/lib.rs
index 3551ecbc..4d72df0b 100644
--- a/bindgen/lib.rs
+++ b/bindgen/lib.rs
@@ -1640,7 +1640,7 @@ impl Builder {
wrapper_file.write_all(wrapper_contents.as_bytes())?;
}
- let mut cmd = Command::new(&clang.path);
+ let mut cmd = Command::new(clang.path);
cmd.arg("-save-temps")
.arg("-E")
.arg("-C")
@@ -2516,22 +2516,21 @@ impl Bindings {
let path = Path::new(h);
if let Ok(md) = std::fs::metadata(path) {
if md.is_dir() {
- return GenerateResult::Err(
- BindgenError::FolderAsHeader(path.into()).into(),
- );
+ return GenerateResult::Err(BindgenError::FolderAsHeader(
+ path.into(),
+ ));
}
if !can_read(&md.permissions()) {
return GenerateResult::Err(
- BindgenError::InsufficientPermissions(path.into())
- .into(),
+ BindgenError::InsufficientPermissions(path.into()),
);
}
let h = h.clone();
options.clang_args.push(h);
} else {
- return GenerateResult::Err(
- BindgenError::NotExist(path.into()).into(),
- );
+ return GenerateResult::Err(BindgenError::NotExist(
+ path.into(),
+ ));
}
}
@@ -2855,11 +2854,10 @@ pub fn clang_version() -> ClangVersion {
/// Looks for the env var `var_${TARGET}`, and falls back to just `var` when it is not found.
fn get_target_dependent_env_var(var: &str) -> Option<String> {
if let Ok(target) = env::var("TARGET") {
- if let Ok(v) = env::var(&format!("{}_{}", var, target)) {
+ if let Ok(v) = env::var(format!("{}_{}", var, target)) {
return Some(v);
}
- if let Ok(v) =
- env::var(&format!("{}_{}", var, target.replace('-', "_")))
+ if let Ok(v) = env::var(format!("{}_{}", var, target.replace('-', "_")))
{
return Some(v);
}