Skip to content

Commit 9ac523d

Browse files
committed
---
yaml --- r: 3015 b: refs/heads/master c: f28796e h: refs/heads/master i: 3013: 5b9ce5d 3011: d03945d 3007: 28d49db v: v3
1 parent 24bf8bf commit 9ac523d

File tree

9 files changed

+39
-29
lines changed

9 files changed

+39
-29
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: fccf0652661f8f76875655628e6a61d7e00bd856
2+
refs/heads/master: f28796ed99c57b574a16430dd0f7b1b1884740c6

trunk/src/comp/middle/trans.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3889,7 +3889,7 @@ fn trans_for(&@block_ctxt cx,
38893889
fn collect_upvars(&@block_ctxt cx, &ast::block bloc,
38903890
&ast::def_id initial_decl) -> vec[ast::def_id] {
38913891
type env = @rec(
3892-
vec[ast::def_id] refs,
3892+
mutable vec[ast::def_id] refs,
38933893
hashmap[ast::def_id,()] decls,
38943894
resolve::def_map def_map
38953895
);
@@ -3923,7 +3923,7 @@ fn collect_upvars(&@block_ctxt cx, &ast::block bloc,
39233923
let vec[ast::def_id] refs = [];
39243924
let hashmap[ast::def_id,()] decls = new_def_hash[()]();
39253925
decls.insert(initial_decl, ());
3926-
let env e = @rec(refs=refs,
3926+
let env e = @rec(mutable refs=refs,
39273927
decls=decls,
39283928
def_map=cx.fcx.lcx.ccx.tcx.def_map);
39293929

@@ -3934,7 +3934,8 @@ fn collect_upvars(&@block_ctxt cx, &ast::block bloc,
39343934

39353935
// Calculate (refs - decls). This is the set of captured upvars.
39363936
let vec[ast::def_id] result = [];
3937-
for (ast::def_id ref_id in e.refs) {
3937+
for (ast::def_id ref_id_ in e.refs) {
3938+
auto ref_id = ref_id_;
39383939
if (!decls.contains_key(ref_id)) {
39393940
result += [ref_id];
39403941
}

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ import aux::crate_ctxt;
5757
import aux::add_node;
5858
import middle::tstate::ann::empty_ann;
5959

60-
fn collect_ids_expr(&@expr e, @vec[uint] res) -> () {
60+
fn collect_ids_expr(&@expr e, @mutable vec[uint] res) -> () {
6161
vec::push(*res, (expr_ann(e)).id);
6262
}
63-
fn collect_ids_block(&block b, @vec[uint] res) -> () {
63+
fn collect_ids_block(&block b, @mutable vec[uint] res) -> () {
6464
vec::push(*res, b.node.a.id);
6565
}
6666

67-
fn collect_ids_stmt(&@stmt s, @vec[uint] res) -> () {
67+
fn collect_ids_stmt(&@stmt s, @mutable vec[uint] res) -> () {
6868
alt (s.node) {
6969
case (stmt_decl(_,?a)) {
7070
log("node_id " + uistr(a.id));
@@ -82,7 +82,7 @@ fn collect_ids_stmt(&@stmt s, @vec[uint] res) -> () {
8282
}
8383
}
8484

85-
fn collect_ids_decl(&@decl d, @vec[uint] res) -> () {
85+
fn collect_ids_decl(&@decl d, @mutable vec[uint] res) -> () {
8686
alt (d.node) {
8787
case (decl_local(?l)) {
8888
vec::push(*res, l.ann.id);
@@ -92,7 +92,7 @@ fn collect_ids_decl(&@decl d, @vec[uint] res) -> () {
9292
}
9393

9494
fn node_ids_in_fn(&_fn f, &span sp, &ident i, &def_id d, &ann a,
95-
@vec[uint] res) -> () {
95+
@mutable vec[uint] res) -> () {
9696
auto collect_ids = walk::default_visitor();
9797
collect_ids = rec(visit_expr_pre = bind collect_ids_expr(_,res),
9898
visit_block_pre = bind collect_ids_block(_,res),
@@ -102,19 +102,19 @@ fn node_ids_in_fn(&_fn f, &span sp, &ident i, &def_id d, &ann a,
102102
walk::walk_fn(collect_ids, f, sp, i, d, a);
103103
}
104104

105-
fn init_vecs(&crate_ctxt ccx, @vec[uint] node_ids, uint len) -> () {
106-
for (uint i in *node_ids) {
105+
fn init_vecs(&crate_ctxt ccx, &vec[uint] node_ids, uint len) -> () {
106+
for (uint i in node_ids) {
107107
log(uistr(i) + " |-> " + uistr(len));
108108
add_node(ccx, i, empty_ann(len));
109109
}
110110
}
111111

112112
fn visit_fn(&crate_ctxt ccx, uint num_constraints, &_fn f,
113113
&span sp, &ident i, &def_id d, &ann a) -> () {
114-
let vec[uint] node_ids_ = [];
115-
let @vec[uint] node_ids = @node_ids_;
114+
let @mutable vec[uint] node_ids = @mutable [];
116115
node_ids_in_fn(f, sp, i, d, a, node_ids);
117-
init_vecs(ccx, node_ids, num_constraints);
116+
auto node_id_vec = *node_ids;
117+
init_vecs(ccx, node_id_vec, num_constraints);
118118
}
119119

120120
fn annotate_in_fn(&crate_ctxt ccx, &_fn f, &span sp, &ident i,

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ type pred_desc_ = rec(vec[@constr_arg] args,
216216
type pred_desc = spanned[pred_desc_];
217217
tag constraint {
218218
cinit(uint, span, ident);
219-
cpred(path, @vec[pred_desc]);
219+
cpred(path, @mutable vec[pred_desc]);
220220
}
221221
tag constr_ {
222222
ninit(ident);
@@ -239,7 +239,7 @@ type constr_map = @std::map::hashmap[def_id, constraint];
239239
type fn_info = rec(constr_map constrs, uint num_constraints, controlflow cf);
240240

241241
/* mapping from node ID to typestate annotation */
242-
type node_ann_table = @vec[ts_ann];
242+
type node_ann_table = @mutable vec[ts_ann];
243243

244244
/* mapping from function name to fn_info map */
245245
type fn_info_map = @std::map::hashmap[def_id, fn_info];
@@ -470,7 +470,7 @@ fn num_constraints(fn_info m) -> uint {
470470

471471
fn new_crate_ctxt(ty::ctxt cx) -> crate_ctxt {
472472
let vec[ts_ann] na = [];
473-
ret rec(tcx=cx, node_anns=@na, fm=@new_def_hash[fn_info]());
473+
ret rec(tcx=cx, node_anns=@mutable na, fm=@new_def_hash[fn_info]());
474474
}
475475

476476
fn controlflow_def_id(&crate_ctxt ccx, &def_id d) -> controlflow {
@@ -551,10 +551,10 @@ fn constraints(&fn_ctxt fcx) -> vec[norm_constraint] {
551551
// FIXME:
552552
// this probably doesn't handle name shadowing well (or at all)
553553
// variables should really always be id'd by def_id and not ident
554-
fn match_args(&fn_ctxt fcx, @vec[pred_desc] occs,
554+
fn match_args(&fn_ctxt fcx, vec[pred_desc] occs,
555555
vec[@constr_arg] occ) -> uint {
556556
log ("match_args: looking at " + constr_args_to_str(occ));
557-
for (pred_desc pd in *occs) {
557+
for (pred_desc pd in occs) {
558558
log ("match_args: candidate " + pred_desc_to_str(pd));
559559
if (ty::args_eq(pd.node.args, occ)) {
560560
ret pd.node.bit_num;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ fn bit_num(&fn_ctxt fcx, &def_id v, &constr_occ o) -> uint {
5353
case (occ_args(?args)) {
5454
alt (res) {
5555
case (cpred(_, ?descs)) {
56-
ret match_args(fcx, descs, args);
56+
ret match_args(fcx, *descs, args);
5757
}
5858
case (_) {
5959
fcx.ccx.tcx.sess.bug("bit_num: asked for pred constraint,"

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import util::common::uistr;
2525
import util::common::span;
2626
import util::common::respan;
2727

28-
type ctxt = rec(@vec[constraint_info] cs,
28+
type ctxt = rec(@mutable vec[constraint_info] cs,
2929
ty::ctxt tcx);
3030

3131
fn collect_local(&ctxt cx, &@decl d) -> () {
@@ -52,7 +52,7 @@ fn collect_pred(&ctxt cx, &@expr e) -> () {
5252

5353
fn find_locals(&ty::ctxt tcx, &_fn f, &span sp, &ident i, &def_id d, &ann a)
5454
-> ctxt {
55-
let ctxt cx = rec(cs=@vec::alloc[constraint_info](0u), tcx=tcx);
55+
let ctxt cx = rec(cs=@mutable vec::alloc[constraint_info](0u), tcx=tcx);
5656
auto visitor = walk::default_visitor();
5757
visitor = rec(visit_decl_pre=bind collect_local(cx,_),
5858
visit_expr_pre=bind collect_pred(cx,_)
@@ -86,7 +86,8 @@ fn add_constraint(&ty::ctxt tcx, constraint_info c, uint next, constr_map tbl)
8686
}
8787
case (none[constraint]) {
8888
tbl.insert(c.id, cpred(p,
89-
@[respan(cn.span, rec(args=args, bit_num=next))]));
89+
@mutable [respan(cn.span, rec(args=args,
90+
bit_num=next))]));
9091
}
9192
}
9293
}
@@ -110,7 +111,7 @@ fn mk_fn_info(&crate_ctxt ccx, &_fn f, &span f_sp,
110111
/* now we have to add bit nums for both the constraints
111112
and the variables... */
112113

113-
for (constraint_info c in *cx.cs) {
114+
for (constraint_info c in {*cx.cs}) {
114115
next = add_constraint(cx.tcx, c, next, res_map);
115116
}
116117
/* add a pseudo-entry for the function's return value

trunk/src/lib/time.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ native "rust" mod rustrt {
55
type timeval = rec(u32 sec, u32 usec);
66

77
fn get_time() -> timeval {
8-
let timeval res = rec(sec=0u32, usec=0u32);
9-
rustrt::get_time(res.sec, res.usec);
10-
ret res;
8+
auto sec = 0u32; auto usec = 0u32;
9+
rustrt::get_time(sec, usec);
10+
ret rec(sec=sec, usec=usec);
1111
}
1212

trunk/src/lib/vec.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,14 @@ fn member[T](&T x, &array[T] v) -> bool {
293293
ret false;
294294
}
295295

296+
fn count[T](&T x, &array[T] v) -> uint {
297+
auto cnt = 0u;
298+
for (T elt in v) {
299+
if (x == elt) { cnt += 1u; }
300+
}
301+
ret cnt;
302+
}
303+
296304
fn foldl[T, U](fn (&U, &T) -> U p, &U z, &vec[T] v) -> U {
297305
auto sz = len[T](v);
298306

trunk/src/test/run-pass/vec-push.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ fn push[T](&mutable vec[mutable? T] v, &T t) {
33
}
44

55
fn main() {
6-
auto v = @[1, 2, 3];
7-
push[int](*v, 1);
6+
auto v = [1, 2, 3];
7+
push(v, 1);
88
}
99

0 commit comments

Comments
 (0)