Skip to content

Commit c006d5e

Browse files
dtolnayemilio
authored andcommitted
Flatten cursor.kind() matching in Item::parse down to one match
1 parent 4f9fa49 commit c006d5e

File tree

1 file changed

+41
-43
lines changed

1 file changed

+41
-43
lines changed

bindgen/ir/item.rs

+41-43
Original file line numberDiff line numberDiff line change
@@ -1432,57 +1432,55 @@ impl Item {
14321432
}
14331433
}
14341434

1435-
// Guess how does clang treat extern "C" blocks?
1436-
if cursor.kind() == CXCursor_UnexposedDecl {
1437-
Err(ParseError::Recurse)
1438-
} else {
1435+
match cursor.kind() {
1436+
// Guess how does clang treat extern "C" blocks?
1437+
CXCursor_UnexposedDecl => Err(ParseError::Recurse),
1438+
14391439
// We allowlist cursors here known to be unhandled, to prevent being
14401440
// too noisy about this.
1441-
match cursor.kind() {
1442-
CXCursor_MacroDefinition |
1443-
CXCursor_MacroExpansion |
1444-
CXCursor_UsingDeclaration |
1445-
CXCursor_UsingDirective |
1446-
CXCursor_StaticAssert |
1447-
CXCursor_FunctionTemplate => {
1448-
debug!(
1449-
"Unhandled cursor kind {:?}: {:?}",
1450-
cursor.kind(),
1451-
cursor
1452-
);
1453-
}
1454-
CXCursor_InclusionDirective => {
1455-
let file = cursor.get_included_file_name();
1456-
match file {
1457-
None => {
1458-
warn!(
1459-
"Inclusion of a nameless file in {:?}",
1460-
cursor
1461-
);
1462-
}
1463-
Some(included_file) => {
1464-
for cb in &ctx.options().parse_callbacks {
1465-
cb.include_file(&included_file);
1466-
}
1441+
CXCursor_MacroDefinition |
1442+
CXCursor_MacroExpansion |
1443+
CXCursor_UsingDeclaration |
1444+
CXCursor_UsingDirective |
1445+
CXCursor_StaticAssert |
1446+
CXCursor_FunctionTemplate => {
1447+
debug!(
1448+
"Unhandled cursor kind {:?}: {:?}",
1449+
cursor.kind(),
1450+
cursor
1451+
);
1452+
Err(ParseError::Continue)
1453+
}
14671454

1468-
ctx.add_dep(included_file.into_boxed_str());
1469-
}
1455+
CXCursor_InclusionDirective => {
1456+
let file = cursor.get_included_file_name();
1457+
match file {
1458+
None => {
1459+
warn!("Inclusion of a nameless file in {:?}", cursor);
14701460
}
1471-
}
1472-
_ => {
1473-
// ignore toplevel operator overloads
1474-
let spelling = cursor.spelling();
1475-
if !spelling.starts_with("operator") {
1476-
warn!(
1477-
"Unhandled cursor kind {:?}: {:?}",
1478-
cursor.kind(),
1479-
cursor
1480-
);
1461+
Some(included_file) => {
1462+
for cb in &ctx.options().parse_callbacks {
1463+
cb.include_file(&included_file);
1464+
}
1465+
1466+
ctx.add_dep(included_file.into_boxed_str());
14811467
}
14821468
}
1469+
Err(ParseError::Continue)
14831470
}
14841471

1485-
Err(ParseError::Continue)
1472+
_ => {
1473+
// ignore toplevel operator overloads
1474+
let spelling = cursor.spelling();
1475+
if !spelling.starts_with("operator") {
1476+
warn!(
1477+
"Unhandled cursor kind {:?}: {:?}",
1478+
cursor.kind(),
1479+
cursor
1480+
);
1481+
}
1482+
Err(ParseError::Continue)
1483+
}
14861484
}
14871485
}
14881486

0 commit comments

Comments
 (0)