diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2019-10-11 16:17:21 +0200 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2019-10-14 14:15:46 +0200 |
commit | d6a419796da2d349e89e6239deb432383d54ea39 (patch) | |
tree | 52688e864e2b1ad6b71e18d485a2a730b40b4164 | |
parent | 94b0af83e6d9bc37021aa0ea84ee164030748dfc (diff) |
Run `cargo fmt` on the main crate.
-rw-r--r-- | src/clang.rs | 12 | ||||
-rw-r--r-- | src/ir/context.rs | 4 | ||||
-rw-r--r-- | src/ir/dot.rs | 6 | ||||
-rw-r--r-- | src/main.rs | 5 | ||||
-rw-r--r-- | src/options.rs | 9 | ||||
-rw-r--r-- | tests/tests.rs | 21 |
6 files changed, 35 insertions, 22 deletions
diff --git a/src/clang.rs b/src/clang.rs index efb53074..4bcc4b4a 100644 --- a/src/clang.rs +++ b/src/clang.rs @@ -543,10 +543,10 @@ impl Cursor { let kind = cur.kind(); found_attr = clang_kind.map_or(false, |k| k == kind) || (kind == CXCursor_UnexposedAttr && - cur.tokens().iter().any(|t| { - t.kind == CXToken_Identifier && - t.spelling() == name.as_bytes() - })); + cur.tokens().iter().any(|t| { + t.kind == CXToken_Identifier && + t.spelling() == name.as_bytes() + })); if found_attr { CXChildVisit_Break @@ -733,7 +733,9 @@ impl Cursor { if file.is_null() { None } else { - Some(unsafe { cxstring_into_string(clang_sys::clang_getFileName(file)) }) + Some(unsafe { + cxstring_into_string(clang_sys::clang_getFileName(file)) + }) } } } diff --git a/src/ir/context.rs b/src/ir/context.rs index 6158d02d..127c0a24 100644 --- a/src/ir/context.rs +++ b/src/ir/context.rs @@ -553,8 +553,8 @@ impl BindgenContext { clang_sys::CXTranslationUnit_DetailedPreprocessingRecord; let translation_unit = { - let _t = Timer::new("translation_unit") - .with_output(options.time_phases); + let _t = + Timer::new("translation_unit").with_output(options.time_phases); let clang_args = if explicit_target { Cow::Borrowed(&options.clang_args) } else { diff --git a/src/ir/dot.rs b/src/ir/dot.rs index d5690232..6bf75bfa 100644 --- a/src/ir/dot.rs +++ b/src/ir/dot.rs @@ -38,11 +38,7 @@ where &mut dot_file, r#"{} [fontname="courier", color={}, label=< <table border="0" align="left">"#, id.as_usize(), - if is_whitelisted { - "black" - } else { - "gray" - } + if is_whitelisted { "black" } else { "gray" } )?; item.dot_attributes(ctx, &mut dot_file)?; writeln!(&mut dot_file, r#"</table> >];"#)?; diff --git a/src/main.rs b/src/main.rs index 2c32d3cb..ad0915e4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -38,7 +38,10 @@ pub fn main() { None }; - info!("Clang Version: {}, parsed: {:?}", version.full, version.parsed); + info!( + "Clang Version: {}, parsed: {:?}", + version.full, version.parsed + ); if expected_version.is_some() { assert_eq!(version.parsed, version.parsed); diff --git a/src/options.rs b/src/options.rs index 6ead9241..d244aafb 100644 --- a/src/options.rs +++ b/src/options.rs @@ -1,4 +1,7 @@ -use bindgen::{builder, Builder, CodegenConfig, EnumVariation, RustTarget, RUST_TARGET_STRINGS}; +use bindgen::{ + builder, Builder, CodegenConfig, EnumVariation, RustTarget, + RUST_TARGET_STRINGS, +}; use clap::{App, Arg}; use std::fs::File; use std::io::{self, stderr, Error, ErrorKind, Write}; @@ -6,7 +9,9 @@ use std::path::PathBuf; use std::str::FromStr; /// Construct a new [`Builder`](./struct.Builder.html) from command line flags. -pub fn builder_from_flags<I>(args: I) -> Result<(Builder, Box<dyn io::Write>, bool), io::Error> +pub fn builder_from_flags<I>( + args: I, +) -> Result<(Builder, Box<dyn io::Write>, bool), io::Error> where I: Iterator<Item = String>, { diff --git a/tests/tests.rs b/tests/tests.rs index a6c8f4a0..01e90be8 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -68,12 +68,14 @@ The latest `rustfmt` is required to run the `bindgen` test suite. Install // Write to stdin in a new thread, so that we can read from stdout on this // thread. This keeps the child from blocking on writing to its stdout which // might block us from writing to its stdin. - let stdin_handle = ::std::thread::spawn(move || stdin.write_all(source.as_bytes())); + let stdin_handle = + ::std::thread::spawn(move || stdin.write_all(source.as_bytes())); // Read stderr on a new thread for similar reasons. let stderr_handle = ::std::thread::spawn(move || { let mut output = vec![]; - io::copy(&mut stderr, &mut output).map(|_| String::from_utf8_lossy(&output).to_string()) + io::copy(&mut stderr, &mut output) + .map(|_| String::from_utf8_lossy(&output).to_string()) }); let mut output = vec![]; @@ -88,7 +90,8 @@ The latest `rustfmt` is required to run the `bindgen` test suite. Install .expect("writer thread should not have panicked") .expect("should have written to child rustfmt's stdin OK"); - let bindings = String::from_utf8(output).expect("rustfmt should only emit valid utf-8"); + let bindings = String::from_utf8(output) + .expect("rustfmt should only emit valid utf-8"); let stderr = stderr_handle .join() @@ -98,7 +101,10 @@ The latest `rustfmt` is required to run the `bindgen` test suite. Install (bindings, stderr) } -fn compare_generated_header(header: &PathBuf, builder: Builder) -> Result<(), Error> { +fn compare_generated_header( + header: &PathBuf, + builder: Builder, +) -> Result<(), Error> { let file_name = header.file_name().ok_or(Error::new( ErrorKind::Other, "compare_generated_header expects a file", @@ -256,8 +262,8 @@ fn create_bindgen_builder(header: &PathBuf) -> Result<Option<Builder>, Error> { .map(ToString::to_string) .chain(flags) .collect(); - } else if line.contains("bindgen-generate-bindings-on-linux-only") - && !cfg!(target_os = "linux") + } else if line.contains("bindgen-generate-bindings-on-linux-only") && + !cfg!(target_os = "linux") { return Ok(None); } @@ -442,7 +448,8 @@ fn no_system_header_includes() { #[test] fn dump_preprocessed_input() { - let arg_keyword = concat!(env!("CARGO_MANIFEST_DIR"), "/tests/headers/arg_keyword.hpp"); + let arg_keyword = + concat!(env!("CARGO_MANIFEST_DIR"), "/tests/headers/arg_keyword.hpp"); let empty_layout = concat!( env!("CARGO_MANIFEST_DIR"), "/tests/headers/cpp-empty-layout.hpp" |