@@ -321,6 +321,46 @@ where
321
321
}
322
322
}
323
323
324
+ fn mark_foreign_fixed < ' tcx > (
325
+ gacx : & mut GlobalAnalysisCtxt < ' tcx > ,
326
+ gasn : & mut GlobalAssignment ,
327
+ tcx : TyCtxt < ' tcx > ,
328
+ ) {
329
+ // 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)
344
+ }
345
+ }
346
+
347
+ // FIX the fields of structs mentioned in extern blocks
348
+ for adt_did in & gacx. adt_metadata . struct_dids {
349
+ if gacx. foreign_mentioned_tys . contains ( adt_did) {
350
+ let adt_def = tcx. adt_def ( adt_did) ;
351
+ let fields = adt_def. all_fields ( ) ;
352
+ for field in fields {
353
+ let field_lty = gacx. field_ltys [ & field. did ] ;
354
+ eprintln ! (
355
+ "adding FIXED permission for {adt_did:?} field {:?}" ,
356
+ field. did
357
+ ) ;
358
+ make_ty_fixed ( gasn, field_lty) ;
359
+ }
360
+ }
361
+ }
362
+ }
363
+
324
364
fn run ( tcx : TyCtxt ) {
325
365
let mut gacx = GlobalAnalysisCtxt :: new ( tcx) ;
326
366
let mut func_info = HashMap :: new ( ) ;
@@ -529,21 +569,7 @@ fn run(tcx: TyCtxt) {
529
569
}
530
570
}
531
571
532
- // FIX the fields of structs mentioned in extern blocks
533
- for adt_did in & gacx. adt_metadata . struct_dids {
534
- if gacx. foreign_mentioned_tys . contains ( adt_did) {
535
- let adt_def = tcx. adt_def ( adt_did) ;
536
- let fields = adt_def. all_fields ( ) ;
537
- for field in fields {
538
- let field_lty = gacx. field_ltys [ & field. did ] ;
539
- eprintln ! (
540
- "adding FIXED permission for {adt_did:?} field {:?}" ,
541
- field. did
542
- ) ;
543
- make_ty_fixed ( & mut gasn, field_lty) ;
544
- }
545
- }
546
- }
572
+ mark_foreign_fixed ( & mut gacx, & mut gasn, tcx) ;
547
573
548
574
for info in func_info. values_mut ( ) {
549
575
let num_pointers = info. acx_data . num_pointers ( ) ;
0 commit comments