@@ -1425,14 +1425,28 @@ pub fn is_const_fn(cdata: Cmd, id: DefIndex) -> bool {
1425
1425
}
1426
1426
}
1427
1427
1428
- pub fn is_extern_static ( cdata : Cmd , id : DefIndex ) -> bool {
1429
- let item_doc = cdata. lookup_item ( id) ;
1430
- match item_family ( item_doc) {
1431
- ImmStatic | MutStatic => {
1432
- let attrs = get_attributes ( item_doc) ;
1433
- attr:: contains_name ( & attrs, "no_mangle" )
1428
+ pub fn is_extern_item ( cdata : Cmd , id : DefIndex , tcx : & ty:: ctxt ) -> bool {
1429
+ let item_doc = match cdata. get_item ( id) {
1430
+ Some ( doc) => doc,
1431
+ None => return false ,
1432
+ } ;
1433
+ let applicable = match item_family ( item_doc) {
1434
+ ImmStatic | MutStatic => true ,
1435
+ Fn => {
1436
+ let ty:: TypeScheme { generics, ty } = get_type ( cdata, id, tcx) ;
1437
+ let no_generics = generics. types . is_empty ( ) ;
1438
+ match ty. sty {
1439
+ ty:: TyBareFn ( _, fn_ty) if fn_ty. abi != abi:: Rust => return no_generics,
1440
+ _ => no_generics,
1441
+ }
1434
1442
} ,
1435
1443
_ => false ,
1444
+ } ;
1445
+
1446
+ if applicable {
1447
+ attr:: contains_extern_indicator ( & get_attributes ( item_doc) )
1448
+ } else {
1449
+ false
1436
1450
}
1437
1451
}
1438
1452
@@ -1552,22 +1566,6 @@ pub fn get_imported_filemaps(metadata: &[u8]) -> Vec<codemap::FileMap> {
1552
1566
} ) . collect ( )
1553
1567
}
1554
1568
1555
- pub fn is_extern_fn ( cdata : Cmd , id : DefIndex , tcx : & ty:: ctxt ) -> bool {
1556
- let item_doc = match cdata. get_item ( id) {
1557
- Some ( doc) => doc,
1558
- None => return false ,
1559
- } ;
1560
- if let Fn = item_family ( item_doc) {
1561
- let ty:: TypeScheme { generics, ty } = get_type ( cdata, id, tcx) ;
1562
- generics. types . is_empty ( ) && match ty. sty {
1563
- ty:: TyBareFn ( _, fn_ty) => fn_ty. abi != abi:: Rust ,
1564
- _ => false ,
1565
- }
1566
- } else {
1567
- false
1568
- }
1569
- }
1570
-
1571
1569
pub fn closure_kind ( cdata : Cmd , closure_id : DefIndex ) -> ty:: ClosureKind {
1572
1570
let closure_doc = cdata. lookup_item ( closure_id) ;
1573
1571
let closure_kind_doc = reader:: get_doc ( closure_doc, tag_items_closure_kind) ;
0 commit comments