@@ -208,7 +208,8 @@ impl Cursor {
208
208
/// Is the referent a fully specialized template specialization without any
209
209
/// remaining free template arguments?
210
210
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
212
213
}
213
214
214
215
/// Is the referent a template specialization that still has remaining free
@@ -349,13 +350,11 @@ impl Cursor {
349
350
pub fn contains_cursor ( & self , kind : CXCursorKind ) -> bool {
350
351
let mut found = false ;
351
352
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
359
358
} ) ;
360
359
361
360
found
@@ -848,8 +847,8 @@ impl SourceLocation {
848
847
& mut col,
849
848
& mut off) ;
850
849
( File {
851
- x : file,
852
- } ,
850
+ x : file,
851
+ } ,
853
852
line as usize ,
854
853
col as usize ,
855
854
off as usize )
@@ -1284,17 +1283,32 @@ pub fn ast_dump(c: &Cursor, depth: isize) -> CXChildVisitResult {
1284
1283
1285
1284
fn print_cursor < S : AsRef < str > > ( depth : isize , prefix : S , c : & Cursor ) {
1286
1285
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( ) ) ) ;
1289
1290
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( ) ) ) ;
1294
1305
1295
1306
let templ_kind = c. template_kind ( ) ;
1296
1307
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) ) ) ;
1298
1312
}
1299
1313
if let Some ( usr) = c. usr ( ) {
1300
1314
print_indent ( depth, format ! ( " {}usr = \" {}\" " , prefix, usr) ) ;
@@ -1303,38 +1317,53 @@ pub fn ast_dump(c: &Cursor, depth: isize) -> CXChildVisitResult {
1303
1317
print_indent ( depth, format ! ( " {}number-of-args = {}" , prefix, num) ) ;
1304
1318
}
1305
1319
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) ) ;
1307
1324
}
1308
1325
if let Some ( width) = c. bit_width ( ) {
1309
1326
print_indent ( depth, format ! ( " {}bit-width = {}" , prefix, width) ) ;
1310
1327
}
1311
1328
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( ) ) ) ) ;
1313
1333
}
1314
1334
if let Some ( val) = c. enum_val_signed ( ) {
1315
1335
print_indent ( depth, format ! ( " {}enum-val = {}" , prefix, val) ) ;
1316
1336
}
1317
1337
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( ) ) ) ) ;
1319
1342
}
1320
1343
1321
1344
if let Some ( refd) = c. referenced ( ) {
1322
1345
if refd != * c {
1323
1346
println ! ( ) ;
1324
- print_cursor ( depth, String :: from ( prefix) + "referenced." , & refd) ;
1347
+ print_cursor ( depth,
1348
+ String :: from ( prefix) + "referenced." ,
1349
+ & refd) ;
1325
1350
}
1326
1351
}
1327
1352
1328
1353
let canonical = c. canonical ( ) ;
1329
1354
if canonical != * c {
1330
1355
println ! ( ) ;
1331
- print_cursor ( depth, String :: from ( prefix) + "canonical." , & canonical) ;
1356
+ print_cursor ( depth,
1357
+ String :: from ( prefix) + "canonical." ,
1358
+ & canonical) ;
1332
1359
}
1333
1360
1334
1361
if let Some ( specialized) = c. specialized ( ) {
1335
1362
if specialized != * c {
1336
1363
println ! ( ) ;
1337
- print_cursor ( depth, String :: from ( prefix) + "specialized." , & specialized) ;
1364
+ print_cursor ( depth,
1365
+ String :: from ( prefix) + "specialized." ,
1366
+ & specialized) ;
1338
1367
}
1339
1368
}
1340
1369
}
@@ -1348,19 +1377,22 @@ pub fn ast_dump(c: &Cursor, depth: isize) -> CXChildVisitResult {
1348
1377
return ;
1349
1378
}
1350
1379
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 ) } ;
1355
1384
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) ) ;
1359
1389
}
1360
1390
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) ) ;
1362
1393
}
1363
- print_indent ( depth, format ! ( " {}is-variadic? {}" , prefix, ty. is_variadic( ) ) ) ;
1394
+ print_indent ( depth,
1395
+ format ! ( " {}is-variadic? {}" , prefix, ty. is_variadic( ) ) ) ;
1364
1396
1365
1397
let canonical = ty. canonical_type ( ) ;
1366
1398
if canonical != * ty {
@@ -1451,14 +1483,12 @@ impl EvalResult {
1451
1483
// unexposed type. Our solution is to just flat out ban all
1452
1484
// `CXType_Unexposed` from evaluation.
1453
1485
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
1462
1492
} ) ;
1463
1493
if found_cant_eval {
1464
1494
return None ;
0 commit comments