Skip to content

Commit a900f8f

Browse files
authored
Merge pull request #2291 from ferrous-systems/fix-clippy-lints
Address clippy lints
2 parents 15aef5e + cebdedc commit a900f8f

File tree

6 files changed

+14
-18
lines changed

6 files changed

+14
-18
lines changed

src/codegen/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3439,7 +3439,7 @@ impl std::str::FromStr for AliasVariation {
34393439
}
34403440

34413441
/// Enum for how non-Copy unions should be translated.
3442-
#[derive(Copy, Clone, PartialEq, Debug)]
3442+
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
34433443
pub enum NonCopyUnionStyle {
34443444
/// Wrap members in a type generated by bindgen.
34453445
BindgenWrapper,

src/ir/enum_ty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ impl Enum {
165165
return false;
166166
}
167167

168-
self.variants().iter().any(|v| enums.matches(&v.name()))
168+
self.variants().iter().any(|v| enums.matches(v.name()))
169169
}
170170

171171
/// Returns the final representation of the enum.

src/ir/var.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,7 @@ impl ClangSubItemParser for Var {
325325

326326
let mut val = cursor.evaluate().and_then(|v| v.as_int());
327327
if val.is_none() || !kind.signedness_matches(val.unwrap()) {
328-
let tu = ctx.translation_unit();
329-
val = get_integer_literal_from_cursor(&cursor, tu);
328+
val = get_integer_literal_from_cursor(&cursor);
330329
}
331330

332331
val.map(|val| {
@@ -391,10 +390,7 @@ fn parse_int_literal_tokens(cursor: &clang::Cursor) -> Option<i64> {
391390
}
392391
}
393392

394-
fn get_integer_literal_from_cursor(
395-
cursor: &clang::Cursor,
396-
unit: &clang::TranslationUnit,
397-
) -> Option<i64> {
393+
fn get_integer_literal_from_cursor(cursor: &clang::Cursor) -> Option<i64> {
398394
use clang_sys::*;
399395
let mut value = None;
400396
cursor.visit(|c| {
@@ -403,7 +399,7 @@ fn get_integer_literal_from_cursor(
403399
value = parse_int_literal_tokens(&c);
404400
}
405401
CXCursor_UnexposedExpr => {
406-
value = get_integer_literal_from_cursor(&c, unit);
402+
value = get_integer_literal_from_cursor(&c);
407403
}
408404
_ => (),
409405
}

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2647,7 +2647,7 @@ impl Bindings {
26472647
.as_ref()
26482648
.and_then(|f| f.to_str())
26492649
{
2650-
cmd.args(&["--config-path", path]);
2650+
cmd.args(["--config-path", path]);
26512651
}
26522652

26532653
let mut child = cmd.spawn()?;

src/options.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ where
3939
.help("The default style of code used to generate enums.")
4040
.value_name("variant")
4141
.default_value("consts")
42-
.possible_values(&[
42+
.possible_values([
4343
"consts",
4444
"moduleconsts",
4545
"bitfield",
@@ -98,14 +98,14 @@ where
9898
.help("The default signed/unsigned type for C macro constants.")
9999
.value_name("variant")
100100
.default_value("unsigned")
101-
.possible_values(&["signed", "unsigned"])
101+
.possible_values(["signed", "unsigned"])
102102
.multiple_occurrences(false),
103103
Arg::new("default-alias-style")
104104
.long("default-alias-style")
105105
.help("The default style of code used to generate typedefs.")
106106
.value_name("variant")
107107
.default_value("type_alias")
108-
.possible_values(&[
108+
.possible_values([
109109
"type_alias",
110110
"new_type",
111111
"new_type_deref",
@@ -147,7 +147,7 @@ where
147147
)
148148
.value_name("style")
149149
.default_value("bindgen_wrapper")
150-
.possible_values(&[
150+
.possible_values([
151151
"bindgen_wrapper",
152152
"manually_drop",
153153
])

tests/tests.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn rustfmt(source: String) -> (String, String) {
3131

3232
let mut rustfmt = {
3333
let mut p = process::Command::new("rustup");
34-
p.args(&["run", "nightly", "rustfmt", "--version"]);
34+
p.args(["run", "nightly", "rustfmt", "--version"]);
3535
p
3636
};
3737

@@ -59,13 +59,13 @@ The latest `rustfmt` is required to run the `bindgen` test suite. Install
5959
Some(r) => process::Command::new(r),
6060
None => {
6161
let mut p = process::Command::new("rustup");
62-
p.args(&["run", "nightly", "rustfmt"]);
62+
p.args(["run", "nightly", "rustfmt"]);
6363
p
6464
}
6565
};
6666

6767
let mut child = child
68-
.args(&[
68+
.args([
6969
"--config-path",
7070
concat!(env!("CARGO_MANIFEST_DIR"), "/tests/rustfmt.toml"),
7171
])
@@ -164,7 +164,7 @@ fn error_diff_mismatch(
164164
let mut actual_result_file = fs::File::create(&actual_result_path)?;
165165
actual_result_file.write_all(actual.as_bytes())?;
166166
std::process::Command::new(var)
167-
.args(&[filename, &actual_result_path])
167+
.args([filename, &actual_result_path])
168168
.output()?;
169169
}
170170

0 commit comments

Comments
 (0)