Skip to content

Commit 58b3ed1

Browse files
committed
Run cargo fmt
1 parent 4c45407 commit 58b3ed1

File tree

19 files changed

+273
-224
lines changed

19 files changed

+273
-224
lines changed

src/chooser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! A public API for more fine-grained customization of bindgen behavior.
22
3+
pub use ir::enum_ty::{EnumVariantCustomBehavior, EnumVariantValue};
34
pub use ir::int::IntKind;
4-
pub use ir::enum_ty::{EnumVariantValue, EnumVariantCustomBehavior};
55
use std::fmt;
66

77
/// A trait to allow configuring different kinds of types in different

src/clang.rs

Lines changed: 70 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ impl Cursor {
208208
/// Is the referent a fully specialized template specialization without any
209209
/// remaining free template arguments?
210210
pub fn is_fully_specialized_template(&self) -> bool {
211-
self.is_template_specialization() && self.num_template_args().unwrap_or(0) > 0
211+
self.is_template_specialization() &&
212+
self.num_template_args().unwrap_or(0) > 0
212213
}
213214

214215
/// Is the referent a template specialization that still has remaining free
@@ -349,13 +350,11 @@ impl Cursor {
349350
pub fn contains_cursor(&self, kind: CXCursorKind) -> bool {
350351
let mut found = false;
351352

352-
self.visit(|c| {
353-
if c.kind() == kind {
354-
found = true;
355-
CXChildVisit_Break
356-
} else {
357-
CXChildVisit_Continue
358-
}
353+
self.visit(|c| if c.kind() == kind {
354+
found = true;
355+
CXChildVisit_Break
356+
} else {
357+
CXChildVisit_Continue
359358
});
360359

361360
found
@@ -846,8 +845,8 @@ impl SourceLocation {
846845
&mut col,
847846
&mut off);
848847
(File {
849-
x: file,
850-
},
848+
x: file,
849+
},
851850
line as usize,
852851
col as usize,
853852
off as usize)
@@ -1282,17 +1281,32 @@ pub fn ast_dump(c: &Cursor, depth: isize) -> CXChildVisitResult {
12821281

12831282
fn print_cursor<S: AsRef<str>>(depth: isize, prefix: S, c: &Cursor) {
12841283
let prefix = prefix.as_ref();
1285-
print_indent(depth, format!(" {}kind = {}", prefix, kind_to_str(c.kind())));
1286-
print_indent(depth, format!(" {}spelling = \"{}\"", prefix, c.spelling()));
1284+
print_indent(depth,
1285+
format!(" {}kind = {}", prefix, kind_to_str(c.kind())));
1286+
print_indent(depth,
1287+
format!(" {}spelling = \"{}\"", prefix, c.spelling()));
12871288
print_indent(depth, format!(" {}location = {}", prefix, c.location()));
1288-
print_indent(depth, format!(" {}is-definition? {}", prefix, c.is_definition()));
1289-
print_indent(depth, format!(" {}is-declaration? {}", prefix, c.is_declaration()));
1290-
print_indent(depth, format!(" {}is-anonymous? {}", prefix, c.is_anonymous()));
1291-
print_indent(depth, format!(" {}is-inlined-function? {}", prefix, c.is_inlined_function()));
1289+
print_indent(depth,
1290+
format!(" {}is-definition? {}",
1291+
prefix,
1292+
c.is_definition()));
1293+
print_indent(depth,
1294+
format!(" {}is-declaration? {}",
1295+
prefix,
1296+
c.is_declaration()));
1297+
print_indent(depth,
1298+
format!(" {}is-anonymous? {}", prefix, c.is_anonymous()));
1299+
print_indent(depth,
1300+
format!(" {}is-inlined-function? {}",
1301+
prefix,
1302+
c.is_inlined_function()));
12921303

12931304
let templ_kind = c.template_kind();
12941305
if templ_kind != CXCursor_NoDeclFound {
1295-
print_indent(depth, format!(" {}template-kind = {}", prefix, kind_to_str(templ_kind)));
1306+
print_indent(depth,
1307+
format!(" {}template-kind = {}",
1308+
prefix,
1309+
kind_to_str(templ_kind)));
12961310
}
12971311
if let Some(usr) = c.usr() {
12981312
print_indent(depth, format!(" {}usr = \"{}\"", prefix, usr));
@@ -1301,38 +1315,53 @@ pub fn ast_dump(c: &Cursor, depth: isize) -> CXChildVisitResult {
13011315
print_indent(depth, format!(" {}number-of-args = {}", prefix, num));
13021316
}
13031317
if let Some(num) = c.num_template_args() {
1304-
print_indent(depth, format!(" {}number-of-template-args = {}", prefix, num));
1318+
print_indent(depth,
1319+
format!(" {}number-of-template-args = {}",
1320+
prefix,
1321+
num));
13051322
}
13061323
if let Some(width) = c.bit_width() {
13071324
print_indent(depth, format!(" {}bit-width = {}", prefix, width));
13081325
}
13091326
if let Some(ty) = c.enum_type() {
1310-
print_indent(depth, format!(" {}enum-type = {}", prefix, type_to_str(ty.kind())));
1327+
print_indent(depth,
1328+
format!(" {}enum-type = {}",
1329+
prefix,
1330+
type_to_str(ty.kind())));
13111331
}
13121332
if let Some(val) = c.enum_val_signed() {
13131333
print_indent(depth, format!(" {}enum-val = {}", prefix, val));
13141334
}
13151335
if let Some(ty) = c.typedef_type() {
1316-
print_indent(depth, format!(" {}typedef-type = {}", prefix, type_to_str(ty.kind())));
1336+
print_indent(depth,
1337+
format!(" {}typedef-type = {}",
1338+
prefix,
1339+
type_to_str(ty.kind())));
13171340
}
13181341

13191342
if let Some(refd) = c.referenced() {
13201343
if refd != *c {
13211344
println!();
1322-
print_cursor(depth, String::from(prefix) + "referenced.", &refd);
1345+
print_cursor(depth,
1346+
String::from(prefix) + "referenced.",
1347+
&refd);
13231348
}
13241349
}
13251350

13261351
let canonical = c.canonical();
13271352
if canonical != *c {
13281353
println!();
1329-
print_cursor(depth, String::from(prefix) + "canonical.", &canonical);
1354+
print_cursor(depth,
1355+
String::from(prefix) + "canonical.",
1356+
&canonical);
13301357
}
13311358

13321359
if let Some(specialized) = c.specialized() {
13331360
if specialized != *c {
13341361
println!();
1335-
print_cursor(depth, String::from(prefix) + "specialized.", &specialized);
1362+
print_cursor(depth,
1363+
String::from(prefix) + "specialized.",
1364+
&specialized);
13361365
}
13371366
}
13381367
}
@@ -1346,19 +1375,22 @@ pub fn ast_dump(c: &Cursor, depth: isize) -> CXChildVisitResult {
13461375
return;
13471376
}
13481377

1349-
print_indent(depth, format!(" {}spelling = \"{}\"", prefix, ty.spelling()));
1350-
let num_template_args = unsafe {
1351-
clang_Type_getNumTemplateArguments(ty.x)
1352-
};
1378+
print_indent(depth,
1379+
format!(" {}spelling = \"{}\"", prefix, ty.spelling()));
1380+
let num_template_args =
1381+
unsafe { clang_Type_getNumTemplateArguments(ty.x) };
13531382
if num_template_args >= 0 {
1354-
print_indent(depth, format!(" {}number-of-template-args = {}",
1355-
prefix,
1356-
num_template_args));
1383+
print_indent(depth,
1384+
format!(" {}number-of-template-args = {}",
1385+
prefix,
1386+
num_template_args));
13571387
}
13581388
if let Some(num) = ty.num_elements() {
1359-
print_indent(depth, format!(" {}number-of-elements = {}", prefix, num));
1389+
print_indent(depth,
1390+
format!(" {}number-of-elements = {}", prefix, num));
13601391
}
1361-
print_indent(depth, format!(" {}is-variadic? {}", prefix, ty.is_variadic()));
1392+
print_indent(depth,
1393+
format!(" {}is-variadic? {}", prefix, ty.is_variadic()));
13621394

13631395
let canonical = ty.canonical_type();
13641396
if canonical != *ty {
@@ -1449,14 +1481,12 @@ impl EvalResult {
14491481
// unexposed type. Our solution is to just flat out ban all
14501482
// `CXType_Unexposed` from evaluation.
14511483
let mut found_cant_eval = false;
1452-
cursor.visit(|c| {
1453-
if c.kind() == CXCursor_TypeRef &&
1454-
c.cur_type().kind() == CXType_Unexposed {
1455-
found_cant_eval = true;
1456-
CXChildVisit_Break
1457-
} else {
1458-
CXChildVisit_Recurse
1459-
}
1484+
cursor.visit(|c| if c.kind() == CXCursor_TypeRef &&
1485+
c.cur_type().kind() == CXType_Unexposed {
1486+
found_cant_eval = true;
1487+
CXChildVisit_Break
1488+
} else {
1489+
CXChildVisit_Recurse
14601490
});
14611491
if found_cant_eval {
14621492
return None;

0 commit comments

Comments
 (0)