Skip to content

Commit

Permalink
Merge pull request #2291 from ferrous-systems/fix-clippy-lints
Browse files Browse the repository at this point in the history
Address clippy lints
  • Loading branch information
pvdrz authored Oct 3, 2022
2 parents 15aef5e + cebdedc commit a900f8f
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/ir/enum_ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 3 additions & 7 deletions src/ir/var.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down Expand Up @@ -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| {
Expand All @@ -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);
}
_ => (),
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?;
Expand Down
8 changes: 4 additions & 4 deletions src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -147,7 +147,7 @@ where
)
.value_name("style")
.default_value("bindgen_wrapper")
.possible_values(&[
.possible_values([
"bindgen_wrapper",
"manually_drop",
])
Expand Down
8 changes: 4 additions & 4 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down Expand Up @@ -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"),
])
Expand Down Expand Up @@ -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()?;
}

Expand Down

0 comments on commit a900f8f

Please sign in to comment.