Skip to content

Commit f4b1309

Browse files
author
bors-servo
authored
Auto merge of #471 - fitzgen:refmt, r=fitzgen
Run `cargo fmt` It's been a while, and we have a lot of reformatting with the latest version of `rustfmt`.
2 parents eede09e + 58b3ed1 commit f4b1309

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
@@ -848,8 +847,8 @@ impl SourceLocation {
848847
&mut col,
849848
&mut off);
850849
(File {
851-
x: file,
852-
},
850+
x: file,
851+
},
853852
line as usize,
854853
col as usize,
855854
off as usize)
@@ -1284,17 +1283,32 @@ pub fn ast_dump(c: &Cursor, depth: isize) -> CXChildVisitResult {
12841283

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

12951306
let templ_kind = c.template_kind();
12961307
if templ_kind != CXCursor_NoDeclFound {
1297-
print_indent(depth, format!(" {}template-kind = {}", prefix, kind_to_str(templ_kind)));
1308+
print_indent(depth,
1309+
format!(" {}template-kind = {}",
1310+
prefix,
1311+
kind_to_str(templ_kind)));
12981312
}
12991313
if let Some(usr) = c.usr() {
13001314
print_indent(depth, format!(" {}usr = \"{}\"", prefix, usr));
@@ -1303,38 +1317,53 @@ pub fn ast_dump(c: &Cursor, depth: isize) -> CXChildVisitResult {
13031317
print_indent(depth, format!(" {}number-of-args = {}", prefix, num));
13041318
}
13051319
if let Some(num) = c.num_template_args() {
1306-
print_indent(depth, format!(" {}number-of-template-args = {}", prefix, num));
1320+
print_indent(depth,
1321+
format!(" {}number-of-template-args = {}",
1322+
prefix,
1323+
num));
13071324
}
13081325
if let Some(width) = c.bit_width() {
13091326
print_indent(depth, format!(" {}bit-width = {}", prefix, width));
13101327
}
13111328
if let Some(ty) = c.enum_type() {
1312-
print_indent(depth, format!(" {}enum-type = {}", prefix, type_to_str(ty.kind())));
1329+
print_indent(depth,
1330+
format!(" {}enum-type = {}",
1331+
prefix,
1332+
type_to_str(ty.kind())));
13131333
}
13141334
if let Some(val) = c.enum_val_signed() {
13151335
print_indent(depth, format!(" {}enum-val = {}", prefix, val));
13161336
}
13171337
if let Some(ty) = c.typedef_type() {
1318-
print_indent(depth, format!(" {}typedef-type = {}", prefix, type_to_str(ty.kind())));
1338+
print_indent(depth,
1339+
format!(" {}typedef-type = {}",
1340+
prefix,
1341+
type_to_str(ty.kind())));
13191342
}
13201343

13211344
if let Some(refd) = c.referenced() {
13221345
if refd != *c {
13231346
println!();
1324-
print_cursor(depth, String::from(prefix) + "referenced.", &refd);
1347+
print_cursor(depth,
1348+
String::from(prefix) + "referenced.",
1349+
&refd);
13251350
}
13261351
}
13271352

13281353
let canonical = c.canonical();
13291354
if canonical != *c {
13301355
println!();
1331-
print_cursor(depth, String::from(prefix) + "canonical.", &canonical);
1356+
print_cursor(depth,
1357+
String::from(prefix) + "canonical.",
1358+
&canonical);
13321359
}
13331360

13341361
if let Some(specialized) = c.specialized() {
13351362
if specialized != *c {
13361363
println!();
1337-
print_cursor(depth, String::from(prefix) + "specialized.", &specialized);
1364+
print_cursor(depth,
1365+
String::from(prefix) + "specialized.",
1366+
&specialized);
13381367
}
13391368
}
13401369
}
@@ -1348,19 +1377,22 @@ pub fn ast_dump(c: &Cursor, depth: isize) -> CXChildVisitResult {
13481377
return;
13491378
}
13501379

1351-
print_indent(depth, format!(" {}spelling = \"{}\"", prefix, ty.spelling()));
1352-
let num_template_args = unsafe {
1353-
clang_Type_getNumTemplateArguments(ty.x)
1354-
};
1380+
print_indent(depth,
1381+
format!(" {}spelling = \"{}\"", prefix, ty.spelling()));
1382+
let num_template_args =
1383+
unsafe { clang_Type_getNumTemplateArguments(ty.x) };
13551384
if num_template_args >= 0 {
1356-
print_indent(depth, format!(" {}number-of-template-args = {}",
1357-
prefix,
1358-
num_template_args));
1385+
print_indent(depth,
1386+
format!(" {}number-of-template-args = {}",
1387+
prefix,
1388+
num_template_args));
13591389
}
13601390
if let Some(num) = ty.num_elements() {
1361-
print_indent(depth, format!(" {}number-of-elements = {}", prefix, num));
1391+
print_indent(depth,
1392+
format!(" {}number-of-elements = {}", prefix, num));
13621393
}
1363-
print_indent(depth, format!(" {}is-variadic? {}", prefix, ty.is_variadic()));
1394+
print_indent(depth,
1395+
format!(" {}is-variadic? {}", prefix, ty.is_variadic()));
13641396

13651397
let canonical = ty.canonical_type();
13661398
if canonical != *ty {
@@ -1451,14 +1483,12 @@ impl EvalResult {
14511483
// unexposed type. Our solution is to just flat out ban all
14521484
// `CXType_Unexposed` from evaluation.
14531485
let mut found_cant_eval = false;
1454-
cursor.visit(|c| {
1455-
if c.kind() == CXCursor_TypeRef &&
1456-
c.cur_type().kind() == CXType_Unexposed {
1457-
found_cant_eval = true;
1458-
CXChildVisit_Break
1459-
} else {
1460-
CXChildVisit_Recurse
1461-
}
1486+
cursor.visit(|c| if c.kind() == CXCursor_TypeRef &&
1487+
c.cur_type().kind() == CXType_Unexposed {
1488+
found_cant_eval = true;
1489+
CXChildVisit_Break
1490+
} else {
1491+
CXChildVisit_Recurse
14621492
});
14631493
if found_cant_eval {
14641494
return None;

0 commit comments

Comments
 (0)