@@ -5056,12 +5056,18 @@ struct ItemInfoCollector<'a, 'ra, 'tcx> {
5056
5056
}
5057
5057
5058
5058
impl ItemInfoCollector < ' _ , ' _ , ' _ > {
5059
- fn collect_fn_info ( & mut self , sig : & FnSig , id : NodeId , attrs : & [ Attribute ] ) {
5059
+ fn collect_fn_info (
5060
+ & mut self ,
5061
+ header : FnHeader ,
5062
+ decl : & FnDecl ,
5063
+ id : NodeId ,
5064
+ attrs : & [ Attribute ] ,
5065
+ ) {
5060
5066
let sig = DelegationFnSig {
5061
- header : sig . header ,
5062
- param_count : sig . decl . inputs . len ( ) ,
5063
- has_self : sig . decl . has_self ( ) ,
5064
- c_variadic : sig . decl . c_variadic ( ) ,
5067
+ header,
5068
+ param_count : decl. inputs . len ( ) ,
5069
+ has_self : decl. has_self ( ) ,
5070
+ c_variadic : decl. c_variadic ( ) ,
5065
5071
target_feature : attrs. iter ( ) . any ( |attr| attr. has_name ( sym:: target_feature) ) ,
5066
5072
} ;
5067
5073
self . r . delegation_fn_sigs . insert ( self . r . local_def_id ( id) , sig) ;
@@ -5081,7 +5087,7 @@ impl<'ast> Visitor<'ast> for ItemInfoCollector<'_, '_, '_> {
5081
5087
| ItemKind :: Trait ( box Trait { generics, .. } )
5082
5088
| ItemKind :: TraitAlias ( generics, _) => {
5083
5089
if let ItemKind :: Fn ( box Fn { sig, .. } ) = & item. kind {
5084
- self . collect_fn_info ( sig, item. id , & item. attrs ) ;
5090
+ self . collect_fn_info ( sig. header , & sig . decl , item. id , & item. attrs ) ;
5085
5091
}
5086
5092
5087
5093
let def_id = self . r . local_def_id ( item. id ) ;
@@ -5093,8 +5099,21 @@ impl<'ast> Visitor<'ast> for ItemInfoCollector<'_, '_, '_> {
5093
5099
self . r . item_generics_num_lifetimes . insert ( def_id, count) ;
5094
5100
}
5095
5101
5102
+ ItemKind :: ForeignMod ( ForeignMod { extern_span, safety : _, abi, items } ) => {
5103
+ for foreign_item in items {
5104
+ if let ForeignItemKind :: Fn ( box Fn { sig, .. } ) = & foreign_item. kind {
5105
+ let new_header = FnHeader {
5106
+ ext : abi. map_or ( Extern :: Implicit ( * extern_span) , |lit| {
5107
+ Extern :: Explicit ( lit, * extern_span)
5108
+ } ) ,
5109
+ ..sig. header
5110
+ } ;
5111
+ self . collect_fn_info ( new_header, & sig. decl , foreign_item. id , & item. attrs ) ;
5112
+ }
5113
+ }
5114
+ }
5115
+
5096
5116
ItemKind :: Mod ( ..)
5097
- | ItemKind :: ForeignMod ( ..)
5098
5117
| ItemKind :: Static ( ..)
5099
5118
| ItemKind :: Use ( ..)
5100
5119
| ItemKind :: ExternCrate ( ..)
@@ -5114,7 +5133,7 @@ impl<'ast> Visitor<'ast> for ItemInfoCollector<'_, '_, '_> {
5114
5133
5115
5134
fn visit_assoc_item ( & mut self , item : & ' ast AssocItem , ctxt : AssocCtxt ) {
5116
5135
if let AssocItemKind :: Fn ( box Fn { sig, .. } ) = & item. kind {
5117
- self . collect_fn_info ( sig, item. id , & item. attrs ) ;
5136
+ self . collect_fn_info ( sig. header , & sig . decl , item. id , & item. attrs ) ;
5118
5137
}
5119
5138
visit:: walk_assoc_item ( self , item, ctxt) ;
5120
5139
}
0 commit comments