@@ -1567,11 +1567,29 @@ pub fn is_const_fn(cdata: Cmd, id: DefIndex) -> bool {
1567
1567
}
1568
1568
}
1569
1569
1570
- pub fn is_static ( cdata : Cmd , id : DefIndex ) -> bool {
1571
- let item_doc = cdata. lookup_item ( id) ;
1572
- match item_family ( item_doc) {
1570
+ pub fn is_extern_item ( cdata : Cmd , id : DefIndex , tcx : & ty:: ctxt ) -> bool {
1571
+ let item_doc = match cdata. get_item ( id) {
1572
+ Some ( doc) => doc,
1573
+ None => return false ,
1574
+ } ;
1575
+ let applicable = match item_family ( item_doc) {
1573
1576
ImmStatic | MutStatic => true ,
1577
+ Fn => {
1578
+ let ty:: TypeScheme { generics, ty } = get_type ( cdata, id, tcx) ;
1579
+ let no_generics = generics. types . is_empty ( ) ;
1580
+ match ty. sty {
1581
+ ty:: TyBareFn ( _, fn_ty) if fn_ty. abi != Abi :: Rust => return no_generics,
1582
+ _ => no_generics,
1583
+ }
1584
+ } ,
1574
1585
_ => false ,
1586
+ } ;
1587
+
1588
+ if applicable {
1589
+ attr:: contains_extern_indicator ( tcx. sess . diagnostic ( ) ,
1590
+ & get_attributes ( item_doc) )
1591
+ } else {
1592
+ false
1575
1593
}
1576
1594
}
1577
1595
@@ -1693,22 +1711,6 @@ pub fn get_imported_filemaps(metadata: &[u8]) -> Vec<codemap::FileMap> {
1693
1711
} ) . collect ( )
1694
1712
}
1695
1713
1696
- pub fn is_extern_fn ( cdata : Cmd , id : DefIndex , tcx : & ty:: ctxt ) -> bool {
1697
- let item_doc = match cdata. get_item ( id) {
1698
- Some ( doc) => doc,
1699
- None => return false ,
1700
- } ;
1701
- if let Fn = item_family ( item_doc) {
1702
- let ty:: TypeScheme { generics, ty } = get_type ( cdata, id, tcx) ;
1703
- generics. types . is_empty ( ) && match ty. sty {
1704
- ty:: TyBareFn ( _, fn_ty) => fn_ty. abi != Abi :: Rust ,
1705
- _ => false ,
1706
- }
1707
- } else {
1708
- false
1709
- }
1710
- }
1711
-
1712
1714
pub fn closure_kind ( cdata : Cmd , closure_id : DefIndex ) -> ty:: ClosureKind {
1713
1715
let closure_doc = cdata. lookup_item ( closure_id) ;
1714
1716
let closure_kind_doc = reader:: get_doc ( closure_doc, tag_items_closure_kind) ;
0 commit comments