Skip to content

Commit 313846f

Browse files
committed
Run cargo fmt on the main crate.
1 parent 95c4017 commit 313846f

File tree

6 files changed

+35
-22
lines changed

6 files changed

+35
-22
lines changed

src/clang.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -543,10 +543,10 @@ impl Cursor {
543543
let kind = cur.kind();
544544
found_attr = clang_kind.map_or(false, |k| k == kind) ||
545545
(kind == CXCursor_UnexposedAttr &&
546-
cur.tokens().iter().any(|t| {
547-
t.kind == CXToken_Identifier &&
548-
t.spelling() == name.as_bytes()
549-
}));
546+
cur.tokens().iter().any(|t| {
547+
t.kind == CXToken_Identifier &&
548+
t.spelling() == name.as_bytes()
549+
}));
550550

551551
if found_attr {
552552
CXChildVisit_Break
@@ -733,7 +733,9 @@ impl Cursor {
733733
if file.is_null() {
734734
None
735735
} else {
736-
Some(unsafe { cxstring_into_string(clang_sys::clang_getFileName(file)) })
736+
Some(unsafe {
737+
cxstring_into_string(clang_sys::clang_getFileName(file))
738+
})
737739
}
738740
}
739741
}

src/ir/context.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -553,8 +553,8 @@ impl BindgenContext {
553553
clang_sys::CXTranslationUnit_DetailedPreprocessingRecord;
554554

555555
let translation_unit = {
556-
let _t = Timer::new("translation_unit")
557-
.with_output(options.time_phases);
556+
let _t =
557+
Timer::new("translation_unit").with_output(options.time_phases);
558558
let clang_args = if explicit_target {
559559
Cow::Borrowed(&options.clang_args)
560560
} else {

src/ir/dot.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,7 @@ where
3838
&mut dot_file,
3939
r#"{} [fontname="courier", color={}, label=< <table border="0" align="left">"#,
4040
id.as_usize(),
41-
if is_whitelisted {
42-
"black"
43-
} else {
44-
"gray"
45-
}
41+
if is_whitelisted { "black" } else { "gray" }
4642
)?;
4743
item.dot_attributes(ctx, &mut dot_file)?;
4844
writeln!(&mut dot_file, r#"</table> >];"#)?;

src/main.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ pub fn main() {
3838
None
3939
};
4040

41-
info!("Clang Version: {}, parsed: {:?}", version.full, version.parsed);
41+
info!(
42+
"Clang Version: {}, parsed: {:?}",
43+
version.full, version.parsed
44+
);
4245

4346
if expected_version.is_some() {
4447
assert_eq!(version.parsed, version.parsed);

src/options.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
use bindgen::{builder, Builder, CodegenConfig, EnumVariation, RustTarget, RUST_TARGET_STRINGS};
1+
use bindgen::{
2+
builder, Builder, CodegenConfig, EnumVariation, RustTarget,
3+
RUST_TARGET_STRINGS,
4+
};
25
use clap::{App, Arg};
36
use std::fs::File;
47
use std::io::{self, stderr, Error, ErrorKind, Write};
58
use std::path::PathBuf;
69
use std::str::FromStr;
710

811
/// Construct a new [`Builder`](./struct.Builder.html) from command line flags.
9-
pub fn builder_from_flags<I>(args: I) -> Result<(Builder, Box<dyn io::Write>, bool), io::Error>
12+
pub fn builder_from_flags<I>(
13+
args: I,
14+
) -> Result<(Builder, Box<dyn io::Write>, bool), io::Error>
1015
where
1116
I: Iterator<Item = String>,
1217
{

tests/tests.rs

+14-7
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,14 @@ The latest `rustfmt` is required to run the `bindgen` test suite. Install
6868
// Write to stdin in a new thread, so that we can read from stdout on this
6969
// thread. This keeps the child from blocking on writing to its stdout which
7070
// might block us from writing to its stdin.
71-
let stdin_handle = ::std::thread::spawn(move || stdin.write_all(source.as_bytes()));
71+
let stdin_handle =
72+
::std::thread::spawn(move || stdin.write_all(source.as_bytes()));
7273

7374
// Read stderr on a new thread for similar reasons.
7475
let stderr_handle = ::std::thread::spawn(move || {
7576
let mut output = vec![];
76-
io::copy(&mut stderr, &mut output).map(|_| String::from_utf8_lossy(&output).to_string())
77+
io::copy(&mut stderr, &mut output)
78+
.map(|_| String::from_utf8_lossy(&output).to_string())
7779
});
7880

7981
let mut output = vec![];
@@ -88,7 +90,8 @@ The latest `rustfmt` is required to run the `bindgen` test suite. Install
8890
.expect("writer thread should not have panicked")
8991
.expect("should have written to child rustfmt's stdin OK");
9092

91-
let bindings = String::from_utf8(output).expect("rustfmt should only emit valid utf-8");
93+
let bindings = String::from_utf8(output)
94+
.expect("rustfmt should only emit valid utf-8");
9295

9396
let stderr = stderr_handle
9497
.join()
@@ -98,7 +101,10 @@ The latest `rustfmt` is required to run the `bindgen` test suite. Install
98101
(bindings, stderr)
99102
}
100103

101-
fn compare_generated_header(header: &PathBuf, builder: Builder) -> Result<(), Error> {
104+
fn compare_generated_header(
105+
header: &PathBuf,
106+
builder: Builder,
107+
) -> Result<(), Error> {
102108
let file_name = header.file_name().ok_or(Error::new(
103109
ErrorKind::Other,
104110
"compare_generated_header expects a file",
@@ -256,8 +262,8 @@ fn create_bindgen_builder(header: &PathBuf) -> Result<Option<Builder>, Error> {
256262
.map(ToString::to_string)
257263
.chain(flags)
258264
.collect();
259-
} else if line.contains("bindgen-generate-bindings-on-linux-only")
260-
&& !cfg!(target_os = "linux")
265+
} else if line.contains("bindgen-generate-bindings-on-linux-only") &&
266+
!cfg!(target_os = "linux")
261267
{
262268
return Ok(None);
263269
}
@@ -442,7 +448,8 @@ fn no_system_header_includes() {
442448

443449
#[test]
444450
fn dump_preprocessed_input() {
445-
let arg_keyword = concat!(env!("CARGO_MANIFEST_DIR"), "/tests/headers/arg_keyword.hpp");
451+
let arg_keyword =
452+
concat!(env!("CARGO_MANIFEST_DIR"), "/tests/headers/arg_keyword.hpp");
446453
let empty_layout = concat!(
447454
env!("CARGO_MANIFEST_DIR"),
448455
"/tests/headers/cpp-empty-layout.hpp"

0 commit comments

Comments
 (0)