@@ -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
@@ -846,8 +845,8 @@ impl SourceLocation {
846
845
& mut col,
847
846
& mut off) ;
848
847
( File {
849
- x : file,
850
- } ,
848
+ x : file,
849
+ } ,
851
850
line as usize ,
852
851
col as usize ,
853
852
off as usize )
@@ -1282,17 +1281,32 @@ pub fn ast_dump(c: &Cursor, depth: isize) -> CXChildVisitResult {
1282
1281
1283
1282
fn print_cursor < S : AsRef < str > > ( depth : isize , prefix : S , c : & Cursor ) {
1284
1283
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( ) ) ) ;
1287
1288
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( ) ) ) ;
1292
1303
1293
1304
let templ_kind = c. template_kind ( ) ;
1294
1305
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) ) ) ;
1296
1310
}
1297
1311
if let Some ( usr) = c. usr ( ) {
1298
1312
print_indent ( depth, format ! ( " {}usr = \" {}\" " , prefix, usr) ) ;
@@ -1301,38 +1315,53 @@ pub fn ast_dump(c: &Cursor, depth: isize) -> CXChildVisitResult {
1301
1315
print_indent ( depth, format ! ( " {}number-of-args = {}" , prefix, num) ) ;
1302
1316
}
1303
1317
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) ) ;
1305
1322
}
1306
1323
if let Some ( width) = c. bit_width ( ) {
1307
1324
print_indent ( depth, format ! ( " {}bit-width = {}" , prefix, width) ) ;
1308
1325
}
1309
1326
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( ) ) ) ) ;
1311
1331
}
1312
1332
if let Some ( val) = c. enum_val_signed ( ) {
1313
1333
print_indent ( depth, format ! ( " {}enum-val = {}" , prefix, val) ) ;
1314
1334
}
1315
1335
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( ) ) ) ) ;
1317
1340
}
1318
1341
1319
1342
if let Some ( refd) = c. referenced ( ) {
1320
1343
if refd != * c {
1321
1344
println ! ( ) ;
1322
- print_cursor ( depth, String :: from ( prefix) + "referenced." , & refd) ;
1345
+ print_cursor ( depth,
1346
+ String :: from ( prefix) + "referenced." ,
1347
+ & refd) ;
1323
1348
}
1324
1349
}
1325
1350
1326
1351
let canonical = c. canonical ( ) ;
1327
1352
if canonical != * c {
1328
1353
println ! ( ) ;
1329
- print_cursor ( depth, String :: from ( prefix) + "canonical." , & canonical) ;
1354
+ print_cursor ( depth,
1355
+ String :: from ( prefix) + "canonical." ,
1356
+ & canonical) ;
1330
1357
}
1331
1358
1332
1359
if let Some ( specialized) = c. specialized ( ) {
1333
1360
if specialized != * c {
1334
1361
println ! ( ) ;
1335
- print_cursor ( depth, String :: from ( prefix) + "specialized." , & specialized) ;
1362
+ print_cursor ( depth,
1363
+ String :: from ( prefix) + "specialized." ,
1364
+ & specialized) ;
1336
1365
}
1337
1366
}
1338
1367
}
@@ -1346,19 +1375,22 @@ pub fn ast_dump(c: &Cursor, depth: isize) -> CXChildVisitResult {
1346
1375
return ;
1347
1376
}
1348
1377
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 ) } ;
1353
1382
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) ) ;
1357
1387
}
1358
1388
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) ) ;
1360
1391
}
1361
- print_indent ( depth, format ! ( " {}is-variadic? {}" , prefix, ty. is_variadic( ) ) ) ;
1392
+ print_indent ( depth,
1393
+ format ! ( " {}is-variadic? {}" , prefix, ty. is_variadic( ) ) ) ;
1362
1394
1363
1395
let canonical = ty. canonical_type ( ) ;
1364
1396
if canonical != * ty {
@@ -1449,14 +1481,12 @@ impl EvalResult {
1449
1481
// unexposed type. Our solution is to just flat out ban all
1450
1482
// `CXType_Unexposed` from evaluation.
1451
1483
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
1460
1490
} ) ;
1461
1491
if found_cant_eval {
1462
1492
return None ;
0 commit comments