@@ -205,15 +205,21 @@ pub fn get_extern_fn(externs: &mut ExternMap, llmod: ModuleRef, name: &str,
205
205
206
206
fn get_extern_rust_fn ( ccx : & mut CrateContext , inputs : & [ ty:: t ] , output : ty:: t ,
207
207
name : & str , did : ast:: DefId ) -> ValueRef {
208
- match ccx. externs . find_equiv ( & name) {
209
- Some ( n) => return * n,
210
- None => ( )
208
+ {
209
+ let externs = ccx. externs . borrow ( ) ;
210
+ match externs. get ( ) . find_equiv ( & name) {
211
+ Some ( n) => return * n,
212
+ None => ( )
213
+ }
211
214
}
215
+
212
216
let f = decl_rust_fn ( ccx, inputs, output, name) ;
213
217
csearch:: get_item_attrs ( ccx. tcx . cstore , did, |meta_items| {
214
218
set_llvm_fn_attrs ( meta_items. iter ( ) . map ( |& x| attr:: mk_attr ( x) ) . to_owned_vec ( ) , f)
215
219
} ) ;
216
- ccx. externs . insert ( name. to_owned ( ) , f) ;
220
+
221
+ let mut externs = ccx. externs . borrow_mut ( ) ;
222
+ externs. get ( ) . insert ( name. to_owned ( ) , f) ;
217
223
f
218
224
}
219
225
@@ -559,11 +565,15 @@ pub fn get_res_dtor(ccx: @mut CrateContext,
559
565
None ,
560
566
ty:: lookup_item_type ( tcx, parent_id) . ty ) ;
561
567
let llty = type_of_dtor ( ccx, class_ty) ;
562
- get_extern_fn ( & mut ccx. externs ,
563
- ccx. llmod ,
564
- name,
565
- lib:: llvm:: CCallConv ,
566
- llty)
568
+
569
+ {
570
+ let mut externs = ccx. externs . borrow_mut ( ) ;
571
+ get_extern_fn ( externs. get ( ) ,
572
+ ccx. llmod ,
573
+ name,
574
+ lib:: llvm:: CCallConv ,
575
+ llty)
576
+ }
567
577
}
568
578
}
569
579
@@ -865,7 +875,8 @@ pub fn trans_external_path(ccx: &mut CrateContext, did: ast::DefId, t: ty::t) ->
865
875
let c = foreign::llvm_calling_convention(ccx, fn_ty.abis);
866
876
let cconv = c.unwrap_or(lib::llvm::CCallConv);
867
877
let llty = type_of_fn_from_ty(ccx, t);
868
- get_extern_fn(&mut ccx.externs, ccx.llmod, name, cconv, llty)
878
+ let mut externs = ccx.externs.borrow_mut();
879
+ get_extern_fn(externs.get(), ccx.llmod, name, cconv, llty)
869
880
}
870
881
}
871
882
}
@@ -874,7 +885,8 @@ pub fn trans_external_path(ccx: &mut CrateContext, did: ast::DefId, t: ty::t) ->
874
885
}
875
886
_ => {
876
887
let llty = type_of(ccx, t);
877
- get_extern_const(&mut ccx.externs, ccx.llmod, name, llty)
888
+ let mut externs = ccx.externs.borrow_mut();
889
+ get_extern_const(externs.get(), ccx.llmod, name, llty)
878
890
}
879
891
}
880
892
}
0 commit comments