@@ -50,6 +50,7 @@ import type_of::type_of; // Issue #1873
50
50
import syntax:: ast_map:: { path, path_mod, path_name} ;
51
51
52
52
import std:: smallintmap;
53
+ import option:: is_none;
53
54
54
55
// Destinations
55
56
@@ -1207,7 +1208,8 @@ fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: uint,
1207
1208
}
1208
1209
}
1209
1210
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 ,
1211
1213
field : uint , static_ti : option < @tydesc_info > ) {
1212
1214
let _icx = cx. insn_ctxt ( "call_tydesc_glue_full" ) ;
1213
1215
lazily_emit_tydesc_glue ( cx. ccx ( ) , field, static_ti) ;
@@ -1245,8 +1247,9 @@ fn call_tydesc_glue_full(cx: block, v: ValueRef, tydesc: ValueRef,
1245
1247
C_null ( T_ptr ( T_ptr ( cx. ccx ( ) . tydesc_type ) ) ) , llrawptr] ) ;
1246
1248
}
1247
1249
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 {
1250
1253
let _icx = cx. insn_ctxt ( "call_tydesc_glue" ) ;
1251
1254
let mut ti = none;
1252
1255
let td = get_tydesc ( cx. ccx ( ) , t, ti) ;
@@ -3111,8 +3114,9 @@ fn body_contains_ret(body: ast::blk) -> bool {
3111
3114
cx. found
3112
3115
}
3113
3116
3117
+ // See [Note-arg-mode]
3114
3118
fn trans_call_inner (
3115
- in_cx : block ,
3119
+ ++ in_cx : block ,
3116
3120
call_info : option < node_info > ,
3117
3121
fn_expr_ty : ty:: t ,
3118
3122
ret_ty : ty:: t ,
@@ -3240,8 +3244,8 @@ fn need_invoke(bcx: block) -> bool {
3240
3244
_ { }
3241
3245
}
3242
3246
cur = alt cur. parent {
3243
- parent_some ( next) { next }
3244
- parent_none { ret false; }
3247
+ some ( next) { next }
3248
+ none { ret false; }
3245
3249
}
3246
3250
}
3247
3251
}
@@ -3262,7 +3266,7 @@ fn in_lpad_scope_cx(bcx: block, f: fn(scope_info)) {
3262
3266
loop {
3263
3267
alt bcx. kind {
3264
3268
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 ) {
3266
3270
f ( inf) ; ret;
3267
3271
}
3268
3272
}
@@ -3471,11 +3475,11 @@ fn add_root_cleanup(bcx: block, scope_id: ast::node_id,
3471
3475
some ( { id, _} ) if id == scope_id { ret bcx_sid; }
3472
3476
_ {
3473
3477
alt bcx_sid. parent {
3474
- parent_none {
3478
+ none {
3475
3479
bcx. tcx ( ) . sess . bug (
3476
3480
#fmt[ "no enclosing scope with id %d" , scope_id] ) ;
3477
3481
}
3478
- parent_some ( bcx_par) { bcx_par }
3482
+ some ( bcx_par) { bcx_par }
3479
3483
}
3480
3484
}
3481
3485
}
@@ -3785,7 +3789,10 @@ fn do_spill(bcx: block, v: ValueRef, t: ty::t) -> ValueRef {
3785
3789
3786
3790
// Since this function does *not* root, it is the caller's responsibility to
3787
3791
// 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 {
3789
3796
let llptr = alloca ( cx, val_ty ( v) ) ;
3790
3797
Store ( cx, v, llptr) ;
3791
3798
ret llptr;
@@ -3970,9 +3977,9 @@ fn trans_break_cont(bcx: block, to_end: bool)
3970
3977
_ { }
3971
3978
}
3972
3979
unwind = alt unwind. parent {
3973
- parent_some ( cx) { cx }
3980
+ some ( cx) { cx }
3974
3981
// This is a return from a loop body block
3975
- parent_none {
3982
+ none {
3976
3983
Store ( bcx, C_bool ( !to_end) , bcx. fcx . llretptr ) ;
3977
3984
cleanup_and_leave ( bcx, none, some ( bcx. fcx . llreturn ) ) ;
3978
3985
Unreachable ( bcx) ;
@@ -4090,7 +4097,7 @@ fn trans_stmt(cx: block, s: ast::stmt) -> block {
4090
4097
4091
4098
// You probably don't want to use this one. See the
4092
4099
// 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 ,
4094
4101
name : str , opt_node_info : option < node_info > ) -> block {
4095
4102
4096
4103
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,
4099
4106
let llbb: BasicBlockRef = str:: as_c_str ( s, { |buf|
4100
4107
llvm:: LLVMAppendBasicBlock ( cx. llfn , buf)
4101
4108
} ) ;
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|
4111
4111
if cx. unreachable { Unreachable ( bcx) ; }
4112
- }
4113
- _ { }
4114
- }
4112
+ } ;
4115
4113
ret bcx;
4116
4114
}
4117
4115
@@ -4122,20 +4120,20 @@ fn simple_block_scope() -> block_kind {
4122
4120
4123
4121
// Use this when you're at the top block of a function or the like.
4124
4122
fn 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 ( ) ,
4126
4124
"function top level" , opt_node_info) ;
4127
4125
}
4128
4126
4129
4127
fn scope_block ( bcx : block ,
4130
4128
opt_node_info : option < node_info > ,
4131
4129
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 ( ) ,
4133
4131
n, opt_node_info) ;
4134
4132
}
4135
4133
4136
4134
fn loop_scope_block ( bcx : block , loop_break : block , n : str ,
4137
4135
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 ( {
4139
4137
loop_break : some( loop_break) ,
4140
4138
mut cleanups: [ ] ,
4141
4139
mut cleanup_paths: [ ] ,
@@ -4146,17 +4144,11 @@ fn loop_scope_block(bcx: block, loop_break: block, n: str,
4146
4144
4147
4145
// Use this when you're making a general CFG BB within a scope.
4148
4146
fn 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)
4150
4148
}
4151
4149
4152
4150
fn 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)
4160
4152
}
4161
4153
4162
4154
@@ -4231,8 +4223,8 @@ fn cleanup_and_leave(bcx: block, upto: option<BasicBlockRef>,
4231
4223
_ { }
4232
4224
}
4233
4225
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 ; }
4236
4228
} ;
4237
4229
}
4238
4230
alt leave {
0 commit comments