@@ -1567,11 +1567,29 @@ pub fn is_const_fn(cdata: Cmd, id: DefIndex) -> bool {
15671567 }
15681568}
15691569
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) {
15731576 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+ } ,
15741585 _ => false ,
1586+ } ;
1587+
1588+ if applicable {
1589+ attr:: contains_extern_indicator ( tcx. sess . diagnostic ( ) ,
1590+ & get_attributes ( item_doc) )
1591+ } else {
1592+ false
15751593 }
15761594}
15771595
@@ -1693,22 +1711,6 @@ pub fn get_imported_filemaps(metadata: &[u8]) -> Vec<codemap::FileMap> {
16931711 } ) . collect ( )
16941712}
16951713
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-
17121714pub fn closure_kind ( cdata : Cmd , closure_id : DefIndex ) -> ty:: ClosureKind {
17131715 let closure_doc = cdata. lookup_item ( closure_id) ;
17141716 let closure_kind_doc = reader:: get_doc ( closure_doc, tag_items_closure_kind) ;
0 commit comments