mirror of
https://gitee.com/openharmony/third_party_rust_bindgen
synced 2025-01-31 19:52:59 +00:00
address clippy lints
This commit is contained in:
parent
15aef5e43b
commit
cebdedcc40
@ -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,
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
@ -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()?;
|
||||
|
@ -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",
|
||||
])
|
||||
|
@ -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()?;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user