@@ -321,26 +321,35 @@ where
321
321
}
322
322
}
323
323
324
+ fn gather_foreign_sigs < ' tcx > ( gacx : & mut GlobalAnalysisCtxt < ' tcx > , tcx : TyCtxt < ' tcx > ) {
325
+ for did in tcx
326
+ . hir_crate_items ( ( ) )
327
+ . foreign_items ( )
328
+ . map ( |item| item. def_id . to_def_id ( ) )
329
+ . filter ( |did| matches ! ( tcx. def_kind( did) , DefKind :: Fn | DefKind :: AssocFn ) )
330
+ {
331
+ let sig = tcx. erase_late_bound_regions ( tcx. fn_sig ( did) ) ;
332
+ let inputs = sig
333
+ . inputs ( )
334
+ . iter ( )
335
+ . map ( |& ty| gacx. assign_pointer_ids_with_info ( ty, PointerInfo :: ANNOTATED ) )
336
+ . collect :: < Vec < _ > > ( ) ;
337
+ let inputs = gacx. lcx . mk_slice ( & inputs) ;
338
+ let output = gacx. assign_pointer_ids_with_info ( sig. output ( ) , PointerInfo :: ANNOTATED ) ;
339
+ let lsig = LFnSig { inputs, output } ;
340
+ gacx. fn_sigs . insert ( did, lsig) ;
341
+ }
342
+ }
343
+
324
344
fn mark_foreign_fixed < ' tcx > (
325
345
gacx : & mut GlobalAnalysisCtxt < ' tcx > ,
326
346
gasn : & mut GlobalAssignment ,
327
347
tcx : TyCtxt < ' tcx > ,
328
348
) {
329
349
// FIX the inputs and outputs of function declarations in extern blocks
330
- for did in gacx. foreign_mentioned_tys . clone ( ) {
331
- if let DefKind :: Fn = tcx. def_kind ( did) {
332
- let sig = tcx. erase_late_bound_regions ( tcx. fn_sig ( did) ) ;
333
- let inputs = sig
334
- . inputs ( )
335
- . iter ( )
336
- . map ( |& ty| gacx. assign_pointer_ids_with_info ( ty, PointerInfo :: ANNOTATED ) )
337
- . collect :: < Vec < _ > > ( ) ;
338
- for input in inputs {
339
- make_ty_fixed ( gasn, input) ;
340
- }
341
-
342
- let output = gacx. assign_pointer_ids_with_info ( sig. output ( ) , PointerInfo :: ANNOTATED ) ;
343
- make_ty_fixed ( gasn, output)
350
+ for ( did, lsig) in gacx. fn_sigs . iter ( ) {
351
+ if tcx. is_foreign_item ( did) {
352
+ make_sig_fixed ( gasn, lsig) ;
344
353
}
345
354
}
346
355
@@ -560,6 +569,7 @@ fn run(tcx: TyCtxt) {
560
569
// track all types mentioned in extern blocks, we
561
570
// don't want to rewrite those
562
571
gacx. foreign_mentioned_tys = foreign_mentioned_tys ( tcx) ;
572
+ gather_foreign_sigs ( & mut gacx, tcx) ;
563
573
564
574
let mut gasn =
565
575
GlobalAssignment :: new ( gacx. num_pointers ( ) , PermissionSet :: UNIQUE , FlagSet :: empty ( ) ) ;
0 commit comments