@@ -866,8 +866,8 @@ pub fn need_invoke(bcx: block) -> bool {
866866 // Walk the scopes to look for cleanups
867867 let mut cur = bcx;
868868 loop {
869- match cur. kind {
870- block_scope( ref inf) => {
869+ match * cur. kind {
870+ block_scope( ref mut inf) => {
871871 for vec:: each( ( * inf) . cleanups) |cleanup| {
872872 match * cleanup {
873873 clean( _, cleanup_type) | clean_temp( _, _, cleanup_type) => {
@@ -898,16 +898,21 @@ pub fn have_cached_lpad(bcx: block) -> bool {
898898 return res;
899899}
900900
901- pub fn in_lpad_scope_cx ( bcx : block , f : fn ( scope_info ) ) {
901+ pub fn in_lpad_scope_cx ( bcx : block , f : fn ( & mut scope_info ) ) {
902902 let mut bcx = bcx;
903903 loop {
904- match bcx. kind {
905- block_scope( ref inf) => {
906- if ( * inf) . cleanups . len ( ) > 0 u || bcx. parent . is_none ( ) {
907- f ( ( * inf) ) ; return ;
904+ {
905+ // XXX: Borrow check bug workaround.
906+ let kind: & mut block_kind = & mut * bcx. kind ;
907+ match * kind {
908+ block_scope( ref mut inf) => {
909+ if inf. cleanups . len ( ) > 0 u || bcx. parent . is_none ( ) {
910+ f ( inf) ;
911+ return ;
912+ }
913+ }
914+ _ => ( )
908915 }
909- }
910- _ => ( )
911916 }
912917 bcx = block_parent ( bcx) ;
913918 }
@@ -1157,7 +1162,7 @@ pub fn trans_stmt(cx: block, s: ast::stmt) -> block {
11571162 }
11581163 }
11591164 }
1160- ast:: decl_item( i) => trans_item ( cx. fcx . ccx , * i)
1165+ ast:: decl_item( i) => trans_item ( * cx. fcx . ccx , * i)
11611166 }
11621167 }
11631168 ast:: stmt_mac( * ) => cx. tcx ( ) . sess . bug ( ~"unexpanded macro")
@@ -1198,9 +1203,9 @@ pub fn simple_block_scope() -> block_kind {
11981203 block_scope ( scope_info {
11991204 loop_break : None ,
12001205 loop_label : None ,
1201- mut cleanups : ~[ ] ,
1202- mut cleanup_paths : ~[ ] ,
1203- mut landing_pad : None
1206+ cleanups : ~[ ] ,
1207+ cleanup_paths : ~[ ] ,
1208+ landing_pad : None
12041209 } )
12051210}
12061211
@@ -1226,9 +1231,9 @@ pub fn loop_scope_block(bcx: block,
12261231 return new_block ( bcx. fcx , Some ( bcx) , block_scope ( scope_info {
12271232 loop_break : Some ( loop_break) ,
12281233 loop_label : loop_label,
1229- mut cleanups : ~[ ] ,
1230- mut cleanup_paths : ~[ ] ,
1231- mut landing_pad : None
1234+ cleanups : ~[ ] ,
1235+ cleanup_paths : ~[ ] ,
1236+ landing_pad : None
12321237 } ) , bcx. is_lpad , n, opt_node_info) ;
12331238}
12341239
@@ -1301,23 +1306,30 @@ pub fn cleanup_and_leave(bcx: block,
13011306 @fmt ! ( "cleanup_and_leave(%s)" , cur. to_str( ) ) ) ;
13021307 }
13031308
1304- match cur. kind {
1305- block_scope( ref inf) if !inf. cleanups . is_empty ( ) => {
1306- for vec:: find( ( * inf) . cleanup_paths,
1307- |cp| cp. target == leave) . each |cp| {
1308- Br ( bcx, cp. dest) ;
1309- return ;
1309+ {
1310+ // XXX: Borrow check bug workaround.
1311+ let kind: & mut block_kind = & mut * cur. kind ;
1312+ match * kind {
1313+ block_scope( ref mut inf) if !inf. cleanups . is_empty ( ) => {
1314+ for vec:: find( ( * inf) . cleanup_paths,
1315+ |cp| cp. target == leave) . each |cp| {
1316+ Br ( bcx, cp. dest) ;
1317+ return ;
1318+ }
1319+ let sub_cx = sub_block( bcx, ~"cleanup") ;
1320+ Br ( bcx, sub_cx. llbb) ;
1321+ inf. cleanup_paths. push( cleanup_path {
1322+ target : leave,
1323+ dest : sub_cx. llbb
1324+ } ) ;
1325+ bcx = trans_block_cleanups_( sub_cx,
1326+ block_cleanups( cur) ,
1327+ is_lpad) ;
1328+ }
1329+ _ => ( )
13101330 }
1311- let sub_cx = sub_block( bcx, ~"cleanup") ;
1312- Br ( bcx, sub_cx. llbb) ;
1313- ( * inf) . cleanup_paths. push( cleanup_path {
1314- target : leave,
1315- dest : sub_cx. llbb
1316- } ) ;
1317- bcx = trans_block_cleanups_( sub_cx, block_cleanups( cur) , is_lpad) ;
1318- }
1319- _ => ( )
13201331 }
1332+
13211333 match upto {
13221334 Some ( bb) => { if cur. llbb == bb { break ; } }
13231335 _ => ( )
@@ -1572,25 +1584,25 @@ pub fn new_fn_ctxt_w_id(ccx: @CrateContext,
15721584 param_substs: Option<@param_substs>,
15731585 sp: Option<span>) -> fn_ctxt {
15741586 let llbbs = mk_standard_basic_blocks(llfndecl);
1575- return @fn_ctxt_ {
1587+ return @mut fn_ctxt_ {
15761588 llfn: llfndecl,
15771589 llenv: unsafe { llvm::LLVMGetParam(llfndecl, 1u as c_uint) },
15781590 llretptr: unsafe { llvm::LLVMGetParam(llfndecl, 0u as c_uint) },
1579- mut llstaticallocas: llbbs.sa,
1580- mut llloadenv: None,
1581- mut llreturn: llbbs.rt,
1582- mut llself: None,
1583- mut personality: None,
1584- mut loop_ret: None,
1585- llargs: HashMap(),
1586- lllocals: HashMap(),
1587- llupvars: HashMap(),
1591+ llstaticallocas: llbbs.sa,
1592+ llloadenv: None,
1593+ llreturn: llbbs.rt,
1594+ llself: None,
1595+ personality: None,
1596+ loop_ret: None,
1597+ llargs: @ HashMap(),
1598+ lllocals: @ HashMap(),
1599+ llupvars: @ HashMap(),
15881600 id: id,
15891601 impl_id: impl_id,
15901602 param_substs: param_substs,
15911603 span: sp,
15921604 path: path,
1593- ccx: ccx
1605+ ccx: @ ccx
15941606 };
15951607}
15961608
@@ -1780,7 +1792,7 @@ pub fn trans_closure(ccx: @CrateContext,
17801792 llvm:: LLVMSetGC ( fcx. llfn , strategy) ;
17811793 }
17821794 }
1783- ccx. uses_gc = true ;
1795+ * ccx. uses_gc = true ;
17841796 }
17851797
17861798 // Create the first basic block in the function and keep a handle on it to
@@ -2803,7 +2815,7 @@ pub fn trap(bcx: block) {
28032815}
28042816
28052817pub fn decl_gc_metadata(ccx: @CrateContext, llmod_id: ~str) {
2806- if !ccx.sess.opts.gc || !ccx.uses_gc {
2818+ if !ccx.sess.opts.gc || !* ccx.uses_gc {
28072819 return;
28082820 }
28092821
@@ -3038,7 +3050,7 @@ pub fn trans_crate(sess: session::Session,
30383050 discrims: HashMap(),
30393051 discrim_symbols: HashMap(),
30403052 tydescs: ty::new_ty_hash(),
3041- mut finished_tydescs: false,
3053+ finished_tydescs: @mut false,
30423054 external: HashMap(),
30433055 monomorphized: HashMap(),
30443056 monomorphizing: HashMap(),
@@ -3080,9 +3092,9 @@ pub fn trans_crate(sess: session::Session,
30803092 builder: BuilderRef_res(unsafe { llvm::LLVMCreateBuilder() }),
30813093 shape_cx: mk_ctxt(llmod),
30823094 crate_map: crate_map,
3083- mut uses_gc: false,
3095+ uses_gc: @mut false,
30843096 dbg_cx: dbg_cx,
3085- mut do_not_commit_warning_issued: false
3097+ do_not_commit_warning_issued: @mut false
30863098 };
30873099
30883100 {
0 commit comments