Skip to content

Commit 8d89700

Browse files
committed
Clean up AST dumping
This adds labels to each thing that gets printed for each AST node, and uses a range for indent iteration rather than an index variable.
1 parent 6b285e6 commit 8d89700

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

libbindgen/src/clang.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,21 +1235,23 @@ pub fn type_to_str(x: Enum_CXTypeKind) -> String {
12351235
/// Dump the Clang AST to stdout for debugging purposes.
12361236
pub fn ast_dump(c: &Cursor, depth: isize) -> Enum_CXVisitorResult {
12371237
fn print_indent(depth: isize, s: &str) {
1238-
let mut i = 0;
1239-
while i < depth {
1238+
for _ in 0..depth {
12401239
print!("\t");
1241-
i += 1;
12421240
}
12431241
println!("{}", s);
12441242
}
1245-
let ct = c.cur_type().kind();
1243+
12461244
print_indent(depth,
1247-
&format!("({} {} {}",
1245+
&format!("(kind: {}, spelling: {}, type: {}",
12481246
kind_to_str(c.kind()),
12491247
c.spelling(),
1250-
type_to_str(ct)));
1248+
type_to_str(c.cur_type().kind())));
1249+
1250+
// Recurse.
12511251
c.visit(|s| ast_dump(&s, depth + 1));
1252+
12521253
print_indent(depth, ")");
1254+
12531255
CXChildVisit_Continue
12541256
}
12551257

0 commit comments

Comments
 (0)