Skip to content

Commit 8c557c4

Browse files
committed
---
yaml --- r: 5201 b: refs/heads/master c: 0e6e56c h: refs/heads/master i: 5199: 234cd7d v: v3
1 parent 638ee5c commit 8c557c4

File tree

17 files changed

+55
-92
lines changed

17 files changed

+55
-92
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 4be7e1e5cd10646acc814da147f4e91dd610d45a
2+
refs/heads/master: 0e6e56ca606dc8cc1d5435c3929c11c489f3854b

trunk/src/comp/front/test.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,8 @@ fn mk_main(cx: &test_ctxt) -> @ast::item {
290290
let args_ty: ast::ty = nospan(ast::ty_vec(args_mt));
291291

292292
let args_arg: ast::arg =
293-
{mode: ast::val, ty: @args_ty, ident: "args", id: cx.next_node_id()};
293+
{mode: ast::by_ref, ty: @args_ty, ident: "args",
294+
id: cx.next_node_id()};
294295

295296
let ret_ty = nospan(ast::ty_nil);
296297

trunk/src/comp/metadata/tydecode.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -379,16 +379,12 @@ fn parse_ty_fn(st: @pstate, sd: str_def) ->
379379
assert (next(st) as char == '[');
380380
let inputs: [ty::arg] = [];
381381
while peek(st) as char != ']' {
382-
let mode = ty::mo_val;
382+
let mode = ast::by_ref;
383383
if peek(st) as char == '&' {
384-
mode = ty::mo_alias(false);
384+
mode = ast::by_mut_ref;
385385
st.pos += 1u;
386-
if peek(st) as char == 'm' {
387-
mode = ty::mo_alias(true);
388-
st.pos += 1u;
389-
}
390386
} else if peek(st) as char == '-' {
391-
mode = ty::mo_move;
387+
mode = ast::by_move;
392388
st.pos += 1u;
393389
}
394390
inputs += [{mode: mode, ty: parse_ty(st, sd)}];

trunk/src/comp/metadata/tyencode.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,9 @@ fn enc_ty_fn(w: &io::writer, cx: &@ctxt, args: &[ty::arg], out: ty::t,
207207
w.write_char('[');
208208
for arg: ty::arg in args {
209209
alt arg.mode {
210-
ty::mo_alias(mut) {
211-
w.write_char('&');
212-
if mut { w.write_char('m'); }
213-
}
214-
ty::mo_move. { w.write_char('-'); }
215-
ty::mo_val. { }
210+
by_mut_ref. { w.write_char('&'); }
211+
by_move. { w.write_char('-'); }
212+
by_ref. { }
216213
}
217214
enc_ty(w, cx, arg.ty);
218215
}

trunk/src/comp/middle/alias.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ fn check_call(cx: &ctx, f: &@ast::expr, args: &[@ast::expr], sc: &scope)
180180
for arg_t: ty::arg in arg_ts {
181181
let arg = args[i];
182182
let root = expr_root(cx.tcx, arg, false);
183-
if arg_t.mode == ty::mo_alias(true) {
183+
if arg_t.mode == ast::by_mut_ref {
184184
alt path_def(cx, arg) {
185185
some(def) {
186186
let dnum = ast_util::def_id_of_def(def).node;
@@ -202,7 +202,7 @@ fn check_call(cx: &ctx, f: &@ast::expr, args: &[@ast::expr], sc: &scope)
202202
depends_on: deps(sc, root_var),
203203
mutable ok: valid,
204204
// FIXME kludge
205-
mutable given_up: arg_t.mode == ty::mo_move}];
205+
mutable given_up: arg_t.mode == ast::by_move}];
206206
i += 1u;
207207
}
208208
let f_may_close =
@@ -228,7 +228,7 @@ fn check_call(cx: &ctx, f: &@ast::expr, args: &[@ast::expr], sc: &scope)
228228
some(ty) {
229229
let i = 0u;
230230
for arg_t: ty::arg in arg_ts {
231-
let mut_alias = arg_t.mode == ty::mo_alias(true);
231+
let mut_alias = arg_t.mode == ast::by_mut_ref;
232232
if i != j &&
233233
ty_can_unsafely_include(cx, ty, arg_t.ty, mut_alias) &&
234234
cant_copy(cx, r) {

trunk/src/comp/middle/mut.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,9 @@ fn check_lval(cx: &@ctx, dest: &@expr, msg: msg) {
193193
_ {
194194
let root = expr_root(cx.tcx, dest, false);
195195
if vec::len(*root.ds) == 0u {
196-
mk_err(cx, dest.span, msg, "non-lvalue");
196+
if msg == msg_assign {
197+
mk_err(cx, dest.span, msg, "non-lvalue");
198+
}
197199
} else if !root.ds[0].mut {
198200
let name =
199201
alt root.ds[0].kind {
@@ -235,7 +237,7 @@ fn check_call(cx: &@ctx, f: &@expr, args: &[@expr]) {
235237
ty::type_autoderef(cx.tcx, ty::expr_ty(cx.tcx, f)));
236238
let i = 0u;
237239
for arg_t: ty::arg in arg_ts {
238-
if arg_t.mode == ty::mo_alias(true) {
240+
if arg_t.mode != by_ref {
239241
check_lval(cx, args[i], msg_mut_alias);
240242
}
241243
i += 1u;
@@ -249,7 +251,6 @@ fn is_immutable_def(def: &def) -> option::t<str> {
249251
some("static item")
250252
}
251253
def_obj_field(_, imm.) { some("immutable object field") }
252-
def_arg(_, alias(false)) { some("immutable alias") }
253254
def_upvar(_, inner, mut) {
254255
if !mut { some("upvar") } else { is_immutable_def(*inner) }
255256
}

trunk/src/comp/middle/trans.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3516,7 +3516,7 @@ fn trans_arg_expr(cx: &@block_ctxt, arg: &ty::arg, lldestty0: TypeRef,
35163516
// be inspected. It's important for the value
35173517
// to have type lldestty0 (the callee's expected type).
35183518
val = llvm::LLVMGetUndef(lldestty0);
3519-
} else if arg.mode == ty::mo_val || arg.mode == ty::mo_alias(false) {
3519+
} else if arg.mode == ast::by_ref {
35203520
let copied = false;
35213521
if !lv.is_mem && type_is_immediate(ccx, e_ty) {
35223522
val = do_spill_noroot(bcx, val);
@@ -3545,7 +3545,7 @@ fn trans_arg_expr(cx: &@block_ctxt, arg: &ty::arg, lldestty0: TypeRef,
35453545
}
35463546

35473547
// Collect arg for later if it happens to be one we've moving out.
3548-
if arg.mode == ty::mo_move {
3548+
if arg.mode == ast::by_move {
35493549
if lv.is_mem {
35503550
// Use actual ty, not declared ty -- anything else doesn't make
35513551
// sense if declared ty is a ty param
@@ -4241,7 +4241,7 @@ fn trans_put(in_cx: &@block_ctxt, e: &option::t<@ast::expr>) -> result {
42414241
none. { }
42424242
some(x) {
42434243
let e_ty = ty::expr_ty(bcx_tcx(cx), x);
4244-
let arg = {mode: ty::mo_alias(false), ty: e_ty};
4244+
let arg = {mode: ast::by_ref, ty: e_ty};
42454245
let arg_tys = type_of_explicit_args(bcx_ccx(cx), x.span, [arg]);
42464246
let z = [];
42474247
let k = [];
@@ -4867,7 +4867,7 @@ fn copy_args_to_allocas(fcx: @fn_ctxt, scope: @block_ctxt, args: &[ast::arg],
48674867
for aarg: ast::arg in args {
48684868
let arg_ty = arg_tys[arg_n].ty;
48694869
alt aarg.mode {
4870-
ast::val. | ast::alias(false) {
4870+
ast::by_ref. {
48714871
let mutated = !ignore_mut &&
48724872
fcx.lcx.ccx.mut_map.contains_key(aarg.id);
48734873
// Overwrite the llargs entry for locally mutated params
@@ -4881,7 +4881,7 @@ fn copy_args_to_allocas(fcx: @fn_ctxt, scope: @block_ctxt, args: &[ast::arg],
48814881
add_clean(scope, alloc, arg_ty);
48824882
}
48834883
}
4884-
ast::move. {
4884+
ast::by_move. {
48854885
add_clean(scope, bcx.fcx.llargs.get(aarg.id), arg_ty);
48864886
}
48874887
_ { }
@@ -5109,7 +5109,7 @@ fn trans_tag_variant(cx: @local_ctxt, tag_id: ast::node_id,
51095109
let i = 0u;
51105110
for varg: ast::variant_arg in variant.node.args {
51115111
fn_args +=
5112-
[{mode: ast::alias(false),
5112+
[{mode: ast::by_ref,
51135113
ty: varg.ty,
51145114
ident: "arg" + uint::to_str(i, 10u),
51155115
id: varg.id}];
@@ -5334,7 +5334,7 @@ fn create_main_wrapper(ccx: &@crate_ctxt, sp: &span, main_llfn: ValueRef,
53345334
takes_argv: bool) -> ValueRef {
53355335
let unit_ty = ty::mk_str(ccx.tcx);
53365336
let vecarg_ty: ty::arg =
5337-
{mode: ty::mo_val,
5337+
{mode: ast::by_ref,
53385338
ty: ty::mk_vec(ccx.tcx, {ty: unit_ty, mut: ast::imm})};
53395339
let llfty =
53405340
type_of_fn(ccx, sp, ast::proto_fn, [vecarg_ty],
@@ -5528,7 +5528,7 @@ fn decl_native_fn_and_pair(ccx: &@crate_ctxt, sp: &span, path: &[str],
55285528
}
55295529
fn convert_arg_to_i32(cx: &@block_ctxt, v: ValueRef, t: ty::t,
55305530
mode: ty::mode) -> ValueRef {
5531-
if mode == ty::mo_val {
5531+
if mode == ast::by_ref {
55325532
if ty::type_is_integral(bcx_tcx(cx), t) {
55335533
// FIXME: would be nice to have a postcondition that says
55345534
// if a type is integral, then it has static size (#586)
@@ -5582,7 +5582,7 @@ fn decl_native_fn_and_pair(ccx: &@crate_ctxt, sp: &span, path: &[str],
55825582
let i = arg_n;
55835583
for arg: ty::arg in args {
55845584
let llarg = llvm::LLVMGetParam(fcx.llfn, i);
5585-
if arg.mode == ty::mo_val {
5585+
if arg.mode == ast::by_ref {
55865586
llarg = load_if_immediate(bcx, llarg, arg.ty);
55875587
}
55885588
assert (llarg as int != 0);

trunk/src/comp/middle/trans_common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ fn get_res_dtor(ccx: &@crate_ctxt, sp: &span, did: &ast::def_id,
358358
let params = csearch::get_type_param_count(ccx.sess.get_cstore(), did);
359359
let f_t =
360360
trans::type_of_fn(ccx, sp, ast::proto_fn,
361-
[{mode: ty::mo_alias(false), ty: inner_t}],
361+
[{mode: ast::by_ref, ty: inner_t}],
362362
ty::mk_nil(ccx.tcx), params);
363363
ret trans::get_extern_const(ccx.externs, ccx.llmod,
364364
csearch::get_symbol(ccx.sess.get_cstore(),

trunk/src/comp/middle/trans_objects.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ fn trans_obj(cx: @local_ctxt, sp: &span, ob: &ast::_obj,
4949
let fn_args: [ast::arg] = [];
5050
for f: ast::obj_field in ob.fields {
5151
fn_args +=
52-
[{mode: ast::alias(false), ty: f.ty, ident: f.ident, id: f.id}];
52+
[{mode: ast::by_ref, ty: f.ty, ident: f.ident, id: f.id}];
5353
}
5454
let fcx = new_fn_ctxt(cx, sp, llctor_decl);
5555

@@ -689,12 +689,8 @@ fn process_bkwding_mthd(cx: @local_ctxt, sp: &span, m: @ty::method,
689689
// function (they're in fcx.llargs) to llouter_mthd_args.
690690

691691
let a: uint = 3u; // retptr, task ptr, env come first
692-
let passed_arg: ValueRef = llvm::LLVMGetParam(llbackwarding_fn, a);
693692
for arg: ty::arg in m.inputs {
694-
if arg.mode == ty::mo_val {
695-
passed_arg = load_if_immediate(bcx, passed_arg, arg.ty);
696-
}
697-
llouter_mthd_args += [passed_arg];
693+
llouter_mthd_args += [llvm::LLVMGetParam(llbackwarding_fn, a)];
698694
a += 1u;
699695
}
700696

@@ -861,12 +857,8 @@ fn process_fwding_mthd(cx: @local_ctxt, sp: &span, m: @ty::method,
861857
// function (they're in fcx.llargs) to llorig_mthd_args.
862858

863859
let a: uint = 3u; // retptr, task ptr, env come first
864-
let passed_arg: ValueRef = llvm::LLVMGetParam(llforwarding_fn, a);
865860
for arg: ty::arg in m.inputs {
866-
if arg.mode == ty::mo_val {
867-
passed_arg = load_if_immediate(bcx, passed_arg, arg.ty);
868-
}
869-
llorig_mthd_args += [passed_arg];
861+
llorig_mthd_args += [llvm::LLVMGetParam(llforwarding_fn, a)];
870862
a += 1u;
871863
}
872864

trunk/src/comp/middle/tstate/auxiliary.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,7 @@ fn callee_modes(fcx: &fn_ctxt, callee: node_id) -> [ty::mode] {
11131113

11141114
fn callee_arg_init_ops(fcx: &fn_ctxt, callee: node_id) -> [init_op] {
11151115
fn mode_to_op(m: &ty::mode) -> init_op {
1116-
alt m { ty::mo_move. { init_move } _ { init_assign } }
1116+
alt m { by_move. { init_move } _ { init_assign } }
11171117
}
11181118
vec::map(mode_to_op, callee_modes(fcx, callee))
11191119
}

trunk/src/comp/middle/tstate/pre_post_conditions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ fn forget_args_moved_in(fcx: &fn_ctxt, parent: &@expr, modes: &[ty::mode],
311311
operands: &[@expr]) {
312312
let i = 0u;
313313
for mode: ty::mode in modes {
314-
if mode == ty::mo_move {
314+
if mode == by_move {
315315
forget_in_postcond(fcx, parent.id, operands[i].id);
316316
}
317317
i += 1u;

trunk/src/comp/middle/ty.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,6 @@ export mk_uniq;
8686
export mk_var;
8787
export mk_iter_body_fn;
8888
export mode;
89-
export mo_val;
90-
export mo_alias;
91-
export mo_move;
9289
export mt;
9390
export node_type_table;
9491
export pat_ty;
@@ -177,7 +174,6 @@ export walk_ty;
177174
export occurs_check_fails;
178175

179176
// Data types
180-
tag mode { mo_val; mo_alias(bool); mo_move; }
181177

182178
type arg = {mode: mode, ty: t};
183179

@@ -587,7 +583,7 @@ fn mk_type(_cx: &ctxt) -> t { ret idx_type; }
587583
fn mk_native(cx: &ctxt, did: &def_id) -> t { ret gen_ty(cx, ty_native(did)); }
588584

589585
fn mk_iter_body_fn(cx: &ctxt, output: t) -> t {
590-
ret mk_fn(cx, ast::proto_block, [{mode: ty::mo_alias(false), ty: output}],
586+
ret mk_fn(cx, ast::proto_block, [{mode: ast::by_ref, ty: output}],
591587
ty::mk_nil(cx), ast::return, []);
592588
}
593589

trunk/src/comp/middle/typeck.rs

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ import middle::ty::block_ty;
2020
import middle::ty::expr_ty;
2121
import middle::ty::field;
2222
import middle::ty::method;
23-
import middle::ty::mo_val;
24-
import middle::ty::mo_alias;
25-
import middle::ty::mo_move;
2623
import middle::ty::node_type_table;
2724
import middle::ty::pat_ty;
2825
import middle::ty::ty_param_substs_opt_and_ty;
@@ -213,15 +210,6 @@ fn instantiate_path(fcx: &@fn_ctxt, pth: &ast::path,
213210
ret {substs: ty_substs_opt, ty: tpt.ty};
214211
}
215212

216-
fn ast_mode_to_mode(mode: ast::mode) -> ty::mode {
217-
alt mode {
218-
ast::val. { mo_val }
219-
ast::alias(mut) { mo_alias(mut) }
220-
ast::move. { mo_move }
221-
}
222-
}
223-
224-
225213
// Type tests
226214
fn structurally_resolved_type(fcx: &@fn_ctxt, sp: &span, tp: ty::t) -> ty::t {
227215
alt ty::unify::resolve_type_structure(fcx.ccx.tcx, fcx.var_bindings, tp) {
@@ -282,8 +270,7 @@ fn ast_ty_to_ty(tcx: &ty::ctxt, getter: &ty_getter, ast_ty: &@ast::ty) ->
282270
tcx.ast_ty_to_ty_cache.insert(ast_ty, none::<ty::t>);
283271
fn ast_arg_to_arg(tcx: &ty::ctxt, getter: &ty_getter, arg: &ast::ty_arg)
284272
-> {mode: ty::mode, ty: ty::t} {
285-
let ty_mode = ast_mode_to_mode(arg.node.mode);
286-
ret {mode: ty_mode, ty: ast_ty_to_ty(tcx, getter, arg.node.ty)};
273+
ret {mode: arg.node.mode, ty: ast_ty_to_ty(tcx, getter, arg.node.ty)};
287274
}
288275
fn ast_mt_to_mt(tcx: &ty::ctxt, getter: &ty_getter, mt: &ast::mt) ->
289276
ty::mt {
@@ -592,10 +579,9 @@ mod collect {
592579
ret tpt;
593580
}
594581
fn ty_of_arg(cx: @ctxt, a: &ast::arg) -> ty::arg {
595-
let ty_mode = ast_mode_to_mode(a.mode);
596582
let f = bind getter(cx, _);
597583
let tt = ast_ty_to_ty(cx.tcx, f, a.ty);
598-
ret {mode: ty_mode, ty: tt};
584+
ret {mode: a.mode, ty: tt};
599585
}
600586
fn ty_of_method(cx: @ctxt, m: &@ast::method) -> ty::method {
601587
let get = bind getter(cx, _);
@@ -635,7 +621,7 @@ mod collect {
635621
for f: ast::obj_field in ob.fields {
636622
let g = bind getter(cx, _);
637623
let t_field = ast_ty_to_ty(cx.tcx, g, f.ty);
638-
t_inputs += [{mode: ty::mo_alias(false), ty: t_field}];
624+
t_inputs += [{mode: ast::by_ref, ty: t_field}];
639625
}
640626

641627
let t_fn =
@@ -745,7 +731,7 @@ mod collect {
745731
let args: [arg] = [];
746732
for va: ast::variant_arg in variant.node.args {
747733
let arg_ty = ast_ty_to_ty(cx.tcx, f, va.ty);
748-
args += [{mode: ty::mo_alias(false), ty: arg_ty}];
734+
args += [{mode: ast::by_ref, ty: arg_ty}];
749735
}
750736
let tag_t = ty::mk_tag(cx.tcx, tag_id, ty_param_tys);
751737
// FIXME: this will be different for constrained types
@@ -1605,7 +1591,7 @@ fn check_expr_with_unifier(fcx: &@fn_ctxt, expr: &@ast::expr, unify: &unifier,
16051591
} else { "s were" }]);
16061592
// HACK: build an arguments list with dummy arguments to
16071593
// check against
1608-
let dummy = {mode: ty::mo_val, ty: ty::mk_bot(fcx.ccx.tcx)};
1594+
let dummy = {mode: ast::by_ref, ty: ty::mk_bot(fcx.ccx.tcx)};
16091595
arg_tys = vec::init_elt(dummy, supplied_arg_count);
16101596
}
16111597

@@ -2018,9 +2004,8 @@ fn check_expr_with_unifier(fcx: &@fn_ctxt, expr: &@ast::expr, unify: &unifier,
20182004
let convert = bind ast_ty_to_ty_crate_tyvar(fcx, _);
20192005
let ty_of_arg =
20202006
lambda (a: &ast::arg) -> ty::arg {
2021-
let ty_mode = ast_mode_to_mode(a.mode);
20222007
let tt = ast_ty_to_ty_crate_tyvar(fcx, a.ty);
2023-
ret {mode: ty_mode, ty: tt};
2008+
ret {mode: a.mode, ty: tt};
20242009
};
20252010
let fty =
20262011
collect::ty_of_fn_decl(cx, convert, ty_of_arg, f.decl, f.proto,
@@ -2292,8 +2277,7 @@ fn check_expr_with_unifier(fcx: &@fn_ctxt, expr: &@ast::expr, unify: &unifier,
22922277
// FIXME: These next three functions are largely ripped off from
22932278
// similar ones in collect::. Is there a better way to do this?
22942279
fn ty_of_arg(ccx: @crate_ctxt, a: &ast::arg) -> ty::arg {
2295-
let ty_mode = ast_mode_to_mode(a.mode);
2296-
ret {mode: ty_mode, ty: ast_ty_to_ty_crate(ccx, a.ty)};
2280+
ret {mode: a.mode, ty: ast_ty_to_ty_crate(ccx, a.ty)};
22972281
}
22982282

22992283
fn ty_of_method(ccx: @crate_ctxt, m: &@ast::method) -> ty::method {

trunk/src/comp/syntax/ast.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ tag binop {
127127

128128
tag unop { box(mutability); deref; not; neg; }
129129

130-
tag mode { val; alias(bool); move; }
130+
tag mode { by_ref; by_mut_ref; by_move; }
131131

132132
type stmt = spanned<stmt_>;
133133

@@ -296,7 +296,7 @@ tag ty_ {
296296
/* bot represents the value of functions that don't return a value
297297
locally to their context. in contrast, things like log that do
298298
return, but don't return a meaningful value, have result type nil. */
299-
ty_bool;
299+
ty_bool;
300300
ty_int;
301301
ty_uint;
302302
ty_float;

0 commit comments

Comments
 (0)