Skip to content

Commit 8342689

Browse files
authored
Fix clippy warnings (#2331)
1 parent a2fe04c commit 8342689

File tree

5 files changed

+26
-28
lines changed

5 files changed

+26
-28
lines changed

bindgen/codegen/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ fn root_import(
8585
let mut path = top_level_path(ctx, module);
8686

8787
let root = ctx.root_module().canonical_name(ctx);
88-
let root_ident = ctx.rust_ident(&root);
88+
let root_ident = ctx.rust_ident(root);
8989
path.push(quote! { #root_ident });
9090

9191
let mut tokens = quote! {};
@@ -797,7 +797,7 @@ impl CodeGenerator for Type {
797797
}
798798
};
799799

800-
let rust_name = ctx.rust_ident(&name);
800+
let rust_name = ctx.rust_ident(name);
801801

802802
let mut tokens = if let Some(comment) = item.comment(ctx) {
803803
attributes::doc(comment)
@@ -1076,7 +1076,7 @@ impl<'a> CodeGenerator for Vtable<'a> {
10761076
) {
10771077
assert_eq!(item.id(), self.item_id);
10781078
debug_assert!(item.is_enabled_for_codegen(ctx));
1079-
let name = ctx.rust_ident(&self.canonical_name(ctx));
1079+
let name = ctx.rust_ident(self.canonical_name(ctx));
10801080

10811081
// For now, we will only generate vtables for classes that:
10821082
// - do not inherit from others (compilers merge VTable from primary parent class).
@@ -1582,7 +1582,7 @@ impl<'a> FieldCodegen<'a> for BitfieldUnit {
15821582

15831583
{
15841584
let align_field_name = format!("_bitfield_align_{}", self.nth());
1585-
let align_field_ident = ctx.rust_ident(&align_field_name);
1585+
let align_field_ident = ctx.rust_ident(align_field_name);
15861586
let align_ty = match self.layout().align {
15871587
n if n >= 8 => quote! { u64 },
15881588
4 => quote! { u32 },
@@ -3875,7 +3875,7 @@ impl TryToRustTy for Type {
38753875
}
38763876
TypeKind::TypeParam => {
38773877
let name = item.canonical_name(ctx);
3878-
let ident = ctx.rust_ident(&name);
3878+
let ident = ctx.rust_ident(name);
38793879
Ok(quote! {
38803880
#ident
38813881
})

bindgen/ir/context.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -2076,7 +2076,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
20762076
self.in_codegen_phase(),
20772077
"You're not supposed to call this yet"
20782078
);
2079-
self.options.opaque_types.matches(&path[1..].join("::"))
2079+
self.options.opaque_types.matches(path[1..].join("::"))
20802080
}
20812081

20822082
/// 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!"
23142314
if self
23152315
.options()
23162316
.allowlisted_files
2317-
.matches(&filename)
2317+
.matches(filename)
23182318
{
23192319
return true;
23202320
}
@@ -2389,7 +2389,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
23892389
);
23902390
let name = prefix_path[1..].join("::");
23912391
prefix_path.pop().unwrap();
2392-
self.options().allowlisted_vars.matches(&name)
2392+
self.options().allowlisted_vars.matches(name)
23932393
})
23942394
}
23952395
}
@@ -2671,37 +2671,37 @@ If you encounter an error missing from this list, please file an issue or a PR!"
26712671
/// Check if `--no-partialeq` flag is enabled for this item.
26722672
pub fn no_partialeq_by_name(&self, item: &Item) -> bool {
26732673
let name = item.path_for_allowlisting(self)[1..].join("::");
2674-
self.options().no_partialeq_types.matches(&name)
2674+
self.options().no_partialeq_types.matches(name)
26752675
}
26762676

26772677
/// Check if `--no-copy` flag is enabled for this item.
26782678
pub fn no_copy_by_name(&self, item: &Item) -> bool {
26792679
let name = item.path_for_allowlisting(self)[1..].join("::");
2680-
self.options().no_copy_types.matches(&name)
2680+
self.options().no_copy_types.matches(name)
26812681
}
26822682

26832683
/// Check if `--no-debug` flag is enabled for this item.
26842684
pub fn no_debug_by_name(&self, item: &Item) -> bool {
26852685
let name = item.path_for_allowlisting(self)[1..].join("::");
2686-
self.options().no_debug_types.matches(&name)
2686+
self.options().no_debug_types.matches(name)
26872687
}
26882688

26892689
/// Check if `--no-default` flag is enabled for this item.
26902690
pub fn no_default_by_name(&self, item: &Item) -> bool {
26912691
let name = item.path_for_allowlisting(self)[1..].join("::");
2692-
self.options().no_default_types.matches(&name)
2692+
self.options().no_default_types.matches(name)
26932693
}
26942694

26952695
/// Check if `--no-hash` flag is enabled for this item.
26962696
pub fn no_hash_by_name(&self, item: &Item) -> bool {
26972697
let name = item.path_for_allowlisting(self)[1..].join("::");
2698-
self.options().no_hash_types.matches(&name)
2698+
self.options().no_hash_types.matches(name)
26992699
}
27002700

27012701
/// Check if `--must-use-type` flag is enabled for this item.
27022702
pub fn must_use_type_by_name(&self, item: &Item) -> bool {
27032703
let name = item.path_for_allowlisting(self)[1..].join("::");
2704-
self.options().must_use_types.matches(&name)
2704+
self.options().must_use_types.matches(name)
27052705
}
27062706
}
27072707

bindgen/ir/enum_ty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ impl Enum {
156156
let path = item.path_for_allowlisting(ctx);
157157
let enum_ty = item.expect_type();
158158

159-
if enums.matches(&path[1..].join("::")) {
159+
if enums.matches(path[1..].join("::")) {
160160
return true;
161161
}
162162

bindgen/ir/item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ impl Item {
650650
if let Some(location) = &self.location {
651651
let (file, _, _, _) = location.location();
652652
if let Some(filename) = file.name() {
653-
if ctx.options().blocklisted_files.matches(&filename) {
653+
if ctx.options().blocklisted_files.matches(filename) {
654654
return true;
655655
}
656656
}

bindgen/lib.rs

+10-12
Original file line numberDiff line numberDiff line change
@@ -1640,7 +1640,7 @@ impl Builder {
16401640
wrapper_file.write_all(wrapper_contents.as_bytes())?;
16411641
}
16421642

1643-
let mut cmd = Command::new(&clang.path);
1643+
let mut cmd = Command::new(clang.path);
16441644
cmd.arg("-save-temps")
16451645
.arg("-E")
16461646
.arg("-C")
@@ -2516,22 +2516,21 @@ impl Bindings {
25162516
let path = Path::new(h);
25172517
if let Ok(md) = std::fs::metadata(path) {
25182518
if md.is_dir() {
2519-
return GenerateResult::Err(
2520-
BindgenError::FolderAsHeader(path.into()).into(),
2521-
);
2519+
return GenerateResult::Err(BindgenError::FolderAsHeader(
2520+
path.into(),
2521+
));
25222522
}
25232523
if !can_read(&md.permissions()) {
25242524
return GenerateResult::Err(
2525-
BindgenError::InsufficientPermissions(path.into())
2526-
.into(),
2525+
BindgenError::InsufficientPermissions(path.into()),
25272526
);
25282527
}
25292528
let h = h.clone();
25302529
options.clang_args.push(h);
25312530
} else {
2532-
return GenerateResult::Err(
2533-
BindgenError::NotExist(path.into()).into(),
2534-
);
2531+
return GenerateResult::Err(BindgenError::NotExist(
2532+
path.into(),
2533+
));
25352534
}
25362535
}
25372536

@@ -2855,11 +2854,10 @@ pub fn clang_version() -> ClangVersion {
28552854
/// Looks for the env var `var_${TARGET}`, and falls back to just `var` when it is not found.
28562855
fn get_target_dependent_env_var(var: &str) -> Option<String> {
28572856
if let Ok(target) = env::var("TARGET") {
2858-
if let Ok(v) = env::var(&format!("{}_{}", var, target)) {
2857+
if let Ok(v) = env::var(format!("{}_{}", var, target)) {
28592858
return Some(v);
28602859
}
2861-
if let Ok(v) =
2862-
env::var(&format!("{}_{}", var, target.replace('-', "_")))
2860+
if let Ok(v) = env::var(format!("{}_{}", var, target.replace('-', "_")))
28632861
{
28642862
return Some(v);
28652863
}

0 commit comments

Comments
 (0)