@@ -50,6 +50,7 @@ import type_of::type_of; // Issue #1873
5050import syntax:: ast_map:: { path, path_mod, path_name} ;
5151
5252import std:: smallintmap;
53+ import option:: is_none;
5354
5455// Destinations
5556
@@ -1207,7 +1208,8 @@ fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: uint,
12071208 }
12081209}
12091210
1210- fn call_tydesc_glue_full ( cx : block , v : ValueRef , tydesc : ValueRef ,
1211+ // See [Note-arg-mode]
1212+ fn call_tydesc_glue_full ( ++cx : block , v : ValueRef , tydesc : ValueRef ,
12111213 field : uint , static_ti : option < @tydesc_info > ) {
12121214 let _icx = cx. insn_ctxt ( "call_tydesc_glue_full" ) ;
12131215 lazily_emit_tydesc_glue ( cx. ccx ( ) , field, static_ti) ;
@@ -1245,8 +1247,9 @@ fn call_tydesc_glue_full(cx: block, v: ValueRef, tydesc: ValueRef,
12451247 C_null ( T_ptr ( T_ptr ( cx. ccx ( ) . tydesc_type ) ) ) , llrawptr] ) ;
12461248}
12471249
1248- fn call_tydesc_glue ( cx : block , v : ValueRef , t : ty:: t , field : uint ) ->
1249- block {
1250+ // See [Note-arg-mode]
1251+ fn call_tydesc_glue ( ++cx : block , v : ValueRef , t : ty:: t , field : uint )
1252+ -> block {
12501253 let _icx = cx. insn_ctxt ( "call_tydesc_glue" ) ;
12511254 let mut ti = none;
12521255 let td = get_tydesc ( cx. ccx ( ) , t, ti) ;
@@ -3111,8 +3114,9 @@ fn body_contains_ret(body: ast::blk) -> bool {
31113114 cx. found
31123115}
31133116
3117+ // See [Note-arg-mode]
31143118fn trans_call_inner (
3115- in_cx : block ,
3119+ ++ in_cx : block ,
31163120 call_info : option < node_info > ,
31173121 fn_expr_ty : ty:: t ,
31183122 ret_ty : ty:: t ,
@@ -3240,8 +3244,8 @@ fn need_invoke(bcx: block) -> bool {
32403244 _ { }
32413245 }
32423246 cur = alt cur. parent {
3243- parent_some ( next) { next }
3244- parent_none { ret false; }
3247+ some ( next) { next }
3248+ none { ret false; }
32453249 }
32463250 }
32473251}
@@ -3262,7 +3266,7 @@ fn in_lpad_scope_cx(bcx: block, f: fn(scope_info)) {
32623266 loop {
32633267 alt bcx. kind {
32643268 block_scope ( inf) {
3265- if inf. cleanups . len ( ) > 0 u || bcx. parent == parent_none {
3269+ if inf. cleanups . len ( ) > 0 u || is_none ( bcx. parent ) {
32663270 f ( inf) ; ret;
32673271 }
32683272 }
@@ -3471,11 +3475,11 @@ fn add_root_cleanup(bcx: block, scope_id: ast::node_id,
34713475 some ( { id, _} ) if id == scope_id { ret bcx_sid; }
34723476 _ {
34733477 alt bcx_sid. parent {
3474- parent_none {
3478+ none {
34753479 bcx. tcx ( ) . sess . bug (
34763480 #fmt[ "no enclosing scope with id %d" , scope_id] ) ;
34773481 }
3478- parent_some ( bcx_par) { bcx_par }
3482+ some ( bcx_par) { bcx_par }
34793483 }
34803484 }
34813485 }
@@ -3785,7 +3789,10 @@ fn do_spill(bcx: block, v: ValueRef, t: ty::t) -> ValueRef {
37853789
37863790// Since this function does *not* root, it is the caller's responsibility to
37873791// ensure that the referent is pointed to by a root.
3788- fn do_spill_noroot ( cx : block , v : ValueRef ) -> ValueRef {
3792+ // [Note-arg-mode]
3793+ // ++ mode is temporary, due to how borrowck treats enums. With hope,
3794+ // will go away anyway when we get rid of modes.
3795+ fn do_spill_noroot ( ++cx : block , v : ValueRef ) -> ValueRef {
37893796 let llptr = alloca ( cx, val_ty ( v) ) ;
37903797 Store ( cx, v, llptr) ;
37913798 ret llptr;
@@ -3970,9 +3977,9 @@ fn trans_break_cont(bcx: block, to_end: bool)
39703977 _ { }
39713978 }
39723979 unwind = alt unwind. parent {
3973- parent_some ( cx) { cx }
3980+ some ( cx) { cx }
39743981 // This is a return from a loop body block
3975- parent_none {
3982+ none {
39763983 Store ( bcx, C_bool ( !to_end) , bcx. fcx . llretptr ) ;
39773984 cleanup_and_leave ( bcx, none, some ( bcx. fcx . llreturn ) ) ;
39783985 Unreachable ( bcx) ;
@@ -4090,7 +4097,7 @@ fn trans_stmt(cx: block, s: ast::stmt) -> block {
40904097
40914098// You probably don't want to use this one. See the
40924099// next three functions instead.
4093- fn new_block ( cx : fn_ctxt , parent : block_parent , +kind : block_kind ,
4100+ fn new_block ( cx : fn_ctxt , parent : option < block > , +kind : block_kind ,
40944101 name : str , opt_node_info : option < node_info > ) -> block {
40954102
40964103 let s = if cx. ccx . sess . opts . save_temps || cx. ccx . sess . opts . debuginfo {
@@ -4099,19 +4106,10 @@ fn new_block(cx: fn_ctxt, parent: block_parent, +kind: block_kind,
40994106 let llbb: BasicBlockRef = str:: as_c_str ( s, { |buf|
41004107 llvm:: LLVMAppendBasicBlock ( cx. llfn , buf)
41014108 } ) ;
4102- let bcx = @{ llbb: llbb,
4103- mut terminated: false ,
4104- mut unreachable: false ,
4105- parent: parent,
4106- kind: kind,
4107- node_info: opt_node_info,
4108- fcx: cx} ;
4109- alt parent {
4110- parent_some( cx) {
4109+ let bcx = mk_block ( llbb, parent, kind, opt_node_info, cx) ;
4110+ option:: iter ( parent) { |cx|
41114111 if cx. unreachable { Unreachable ( bcx) ; }
4112- }
4113- _ { }
4114- }
4112+ } ;
41154113 ret bcx;
41164114}
41174115
@@ -4122,20 +4120,20 @@ fn simple_block_scope() -> block_kind {
41224120
41234121// Use this when you're at the top block of a function or the like.
41244122fn top_scope_block ( fcx : fn_ctxt , opt_node_info : option < node_info > ) -> block {
4125- ret new_block ( fcx, parent_none , simple_block_scope ( ) ,
4123+ ret new_block ( fcx, none , simple_block_scope ( ) ,
41264124 "function top level" , opt_node_info) ;
41274125}
41284126
41294127fn scope_block ( bcx : block ,
41304128 opt_node_info : option < node_info > ,
41314129 n : str ) -> block {
4132- ret new_block ( bcx. fcx , parent_some ( bcx) , simple_block_scope ( ) ,
4130+ ret new_block ( bcx. fcx , some ( bcx) , simple_block_scope ( ) ,
41334131 n, opt_node_info) ;
41344132}
41354133
41364134fn loop_scope_block ( bcx : block , loop_break : block , n : str ,
41374135 opt_node_info : option < node_info > ) -> block {
4138- ret new_block ( bcx. fcx , parent_some ( bcx) , block_scope ( {
4136+ ret new_block ( bcx. fcx , some ( bcx) , block_scope ( {
41394137 loop_break : some( loop_break) ,
41404138 mut cleanups: [ ] ,
41414139 mut cleanup_paths: [ ] ,
@@ -4146,17 +4144,11 @@ fn loop_scope_block(bcx: block, loop_break: block, n: str,
41464144
41474145// Use this when you're making a general CFG BB within a scope.
41484146fn sub_block ( bcx : block , n : str ) -> block {
4149- ret new_block ( bcx. fcx , parent_some ( bcx) , block_non_scope, n, none) ;
4147+ new_block ( bcx. fcx , some ( bcx) , block_non_scope, n, none)
41504148}
41514149
41524150fn raw_block ( fcx : fn_ctxt , llbb : BasicBlockRef ) -> block {
4153- ret @{ llbb : llbb,
4154- mut terminated : false ,
4155- mut unreachable : false ,
4156- parent : parent_none,
4157- kind : block_non_scope,
4158- node_info : none,
4159- fcx : fcx} ;
4151+ mk_block ( llbb, none, block_non_scope, none, fcx)
41604152}
41614153
41624154
@@ -4231,8 +4223,8 @@ fn cleanup_and_leave(bcx: block, upto: option<BasicBlockRef>,
42314223 _ { }
42324224 }
42334225 cur = alt cur. parent {
4234- parent_some ( next) { next }
4235- parent_none { assert option :: is_none ( upto) ; break ; }
4226+ some ( next) { next }
4227+ none { assert is_none( upto) ; break ; }
42364228 } ;
42374229 }
42384230 alt leave {
0 commit comments