summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poveda <31802960+pvdrz@users.noreply.github.com>2022-10-03 14:23:56 -0500
committerGitHub <noreply@github.com>2022-10-03 14:23:56 -0500
commita900f8f863d1313ad76603234aaeea22bb9ba7b3 (patch)
tree04254cf657b17ab8de1883bfcfde821bc6ebbe8c
parent15aef5e43b9ad756887e4329b87908da638bcc60 (diff)
parentcebdedcc40f55d85d1370455c9d596a7c4ac1a19 (diff)
Merge pull request #2291 from ferrous-systems/fix-clippy-lints
Address clippy lints
-rw-r--r--src/codegen/mod.rs2
-rw-r--r--src/ir/enum_ty.rs2
-rw-r--r--src/ir/var.rs10
-rw-r--r--src/lib.rs2
-rw-r--r--src/options.rs8
-rw-r--r--tests/tests.rs8
6 files changed, 14 insertions, 18 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs
index a8a7b076..7e0d7aa0 100644
--- a/src/codegen/mod.rs
+++ b/src/codegen/mod.rs
@@ -3439,7 +3439,7 @@ impl std::str::FromStr for AliasVariation {
}
/// Enum for how non-Copy unions should be translated.
-#[derive(Copy, Clone, PartialEq, Debug)]
+#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum NonCopyUnionStyle {
/// Wrap members in a type generated by bindgen.
BindgenWrapper,
diff --git a/src/ir/enum_ty.rs b/src/ir/enum_ty.rs
index 2b039a4f..123d1d79 100644
--- a/src/ir/enum_ty.rs
+++ b/src/ir/enum_ty.rs
@@ -165,7 +165,7 @@ impl Enum {
return false;
}
- self.variants().iter().any(|v| enums.matches(&v.name()))
+ self.variants().iter().any(|v| enums.matches(v.name()))
}
/// Returns the final representation of the enum.
diff --git a/src/ir/var.rs b/src/ir/var.rs
index e44d57af..eecca4df 100644
--- a/src/ir/var.rs
+++ b/src/ir/var.rs
@@ -325,8 +325,7 @@ impl ClangSubItemParser for Var {
let mut val = cursor.evaluate().and_then(|v| v.as_int());
if val.is_none() || !kind.signedness_matches(val.unwrap()) {
- let tu = ctx.translation_unit();
- val = get_integer_literal_from_cursor(&cursor, tu);
+ val = get_integer_literal_from_cursor(&cursor);
}
val.map(|val| {
@@ -391,10 +390,7 @@ fn parse_int_literal_tokens(cursor: &clang::Cursor) -> Option<i64> {
}
}
-fn get_integer_literal_from_cursor(
- cursor: &clang::Cursor,
- unit: &clang::TranslationUnit,
-) -> Option<i64> {
+fn get_integer_literal_from_cursor(cursor: &clang::Cursor) -> Option<i64> {
use clang_sys::*;
let mut value = None;
cursor.visit(|c| {
@@ -403,7 +399,7 @@ fn get_integer_literal_from_cursor(
value = parse_int_literal_tokens(&c);
}
CXCursor_UnexposedExpr => {
- value = get_integer_literal_from_cursor(&c, unit);
+ value = get_integer_literal_from_cursor(&c);
}
_ => (),
}
diff --git a/src/lib.rs b/src/lib.rs
index b2467fbc..6e6fa225 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -2647,7 +2647,7 @@ impl Bindings {
.as_ref()
.and_then(|f| f.to_str())
{
- cmd.args(&["--config-path", path]);
+ cmd.args(["--config-path", path]);
}
let mut child = cmd.spawn()?;
diff --git a/src/options.rs b/src/options.rs
index 29edb78b..1025a36d 100644
--- a/src/options.rs
+++ b/src/options.rs
@@ -39,7 +39,7 @@ where
.help("The default style of code used to generate enums.")
.value_name("variant")
.default_value("consts")
- .possible_values(&[
+ .possible_values([
"consts",
"moduleconsts",
"bitfield",
@@ -98,14 +98,14 @@ where
.help("The default signed/unsigned type for C macro constants.")
.value_name("variant")
.default_value("unsigned")
- .possible_values(&["signed", "unsigned"])
+ .possible_values(["signed", "unsigned"])
.multiple_occurrences(false),
Arg::new("default-alias-style")
.long("default-alias-style")
.help("The default style of code used to generate typedefs.")
.value_name("variant")
.default_value("type_alias")
- .possible_values(&[
+ .possible_values([
"type_alias",
"new_type",
"new_type_deref",
@@ -147,7 +147,7 @@ where
)
.value_name("style")
.default_value("bindgen_wrapper")
- .possible_values(&[
+ .possible_values([
"bindgen_wrapper",
"manually_drop",
])
diff --git a/tests/tests.rs b/tests/tests.rs
index 8dcc5437..ac53d739 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -31,7 +31,7 @@ fn rustfmt(source: String) -> (String, String) {
let mut rustfmt = {
let mut p = process::Command::new("rustup");
- p.args(&["run", "nightly", "rustfmt", "--version"]);
+ p.args(["run", "nightly", "rustfmt", "--version"]);
p
};
@@ -59,13 +59,13 @@ The latest `rustfmt` is required to run the `bindgen` test suite. Install
Some(r) => process::Command::new(r),
None => {
let mut p = process::Command::new("rustup");
- p.args(&["run", "nightly", "rustfmt"]);
+ p.args(["run", "nightly", "rustfmt"]);
p
}
};
let mut child = child
- .args(&[
+ .args([
"--config-path",
concat!(env!("CARGO_MANIFEST_DIR"), "/tests/rustfmt.toml"),
])
@@ -164,7 +164,7 @@ fn error_diff_mismatch(
let mut actual_result_file = fs::File::create(&actual_result_path)?;
actual_result_file.write_all(actual.as_bytes())?;
std::process::Command::new(var)
- .args(&[filename, &actual_result_path])
+ .args([filename, &actual_result_path])
.output()?;
}