Skip to content

Commit 54587bd

Browse files
committed
Switch all vases of vec += elt to vec += vec. Prohibit former in rustboot. Tweak std lib vec fns in process.
1 parent 23eef4d commit 54587bd

29 files changed

+278
-225
lines changed

src/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,6 @@ TEST_XFAILS_RUSTC := $(addprefix test/run-pass/, \
469469
acyclic-unwind.rs \
470470
alt-pattern-drop.rs \
471471
alt-type-simple.rs \
472-
append-units.rs \
473472
basic-1.rs \
474473
basic-2.rs \
475474
basic.rs \

src/boot/me/type.ml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -993,16 +993,14 @@ let check_block (cx:Semant.ctxt) : (fn_ctx -> Ast.block -> unit) =
993993
let src_ty = check_atom ~deref:true src in
994994
let dst_ty = check_lval dst in
995995
match fundamental_ty dst_ty, fundamental_ty src_ty with
996-
Ast.TY_vec elt1, Ast.TY_vec elt2
997-
| Ast.TY_vec elt1, elt2 ->
996+
Ast.TY_vec elt1, Ast.TY_vec elt2 ->
998997
if elt1 = elt2
999998
then ()
1000999
else
10011000
Common.err None
10021001
"mismatched types in vec-append: %s += %s"
10031002
(pretty_ty_str dst_ty)
10041003
(pretty_ty_str src_ty)
1005-
| Ast.TY_str, (Ast.TY_mach Common.TY_u8)
10061004
| Ast.TY_str, Ast.TY_str -> ()
10071005
| _ ->
10081006
infer_lval src_ty dst;

src/comp/driver/rustc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ impure fn main(vec[str] args) {
203203
alt (output_file) {
204204
case (none[str]) {
205205
let vec[str] parts = _str.split(ifile, '.' as u8);
206-
parts = _vec.pop[str](parts);
207-
parts += ".bc";
206+
_vec.pop[str](parts);
207+
parts += vec(".bc");
208208
auto ofile = _str.concat(parts);
209209
compile_input(sess, env, ifile, ofile, shared,
210210
library_search_paths);

src/comp/front/eval.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import front.parser.new_parser;
1313
import front.parser.parse_mod_items;
1414
import util.common;
1515
import util.common.filename;
16-
import util.common.append;
1716
import util.common.span;
1817
import util.common.new_str_hash;
1918

@@ -394,7 +393,7 @@ impure fn eval_crate_directive(parser p,
394393
auto im = ast.item_mod(id, m0, next_id);
395394
auto i = @spanned(cdir.span, cdir.span, im);
396395
ast.index_item(index, i);
397-
append[@ast.item](items, i);
396+
_vec.push[@ast.item](items, i);
398397
}
399398

400399
case (ast.cdir_dir_mod(?id, ?dir_opt, ?cdirs)) {
@@ -412,11 +411,11 @@ impure fn eval_crate_directive(parser p,
412411
auto im = ast.item_mod(id, m0, p.next_def_id());
413412
auto i = @spanned(cdir.span, cdir.span, im);
414413
ast.index_item(index, i);
415-
append[@ast.item](items, i);
414+
_vec.push[@ast.item](items, i);
416415
}
417416

418417
case (ast.cdir_view_item(?vi)) {
419-
append[@ast.view_item](view_items, vi);
418+
_vec.push[@ast.view_item](view_items, vi);
420419
ast.index_view_item(index, vi);
421420
}
422421

src/comp/front/extfmt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ fn parse_fmt_string(str s) -> vec[piece] {
113113
fn flush_buf(str buf, &vec[piece] pieces) -> str {
114114
if (_str.byte_len(buf) > 0u) {
115115
auto piece = piece_string(buf);
116-
pieces += piece;
116+
pieces += vec(piece);
117117
}
118118
ret "";
119119
}
@@ -133,7 +133,7 @@ fn parse_fmt_string(str s) -> vec[piece] {
133133
} else {
134134
buf = flush_buf(buf, pieces);
135135
auto res = parse_conversion(s, i, lim);
136-
pieces += res._0;
136+
pieces += vec(res._0);
137137
i = res._1;
138138
}
139139
} else {

src/comp/front/lexer.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ impure fn next_token(reader rdr) -> token.token {
420420

421421
if (is_alpha(c) || c == '_') {
422422
while (is_alnum(c) || c == '_') {
423-
accum_str += (c as u8);
423+
_str.push_byte(accum_str, (c as u8));
424424
rdr.bump();
425425
c = rdr.curr();
426426
}
@@ -580,23 +580,23 @@ impure fn next_token(reader rdr) -> token.token {
580580
alt (rdr.next()) {
581581
case ('n') {
582582
rdr.bump();
583-
accum_str += '\n' as u8;
583+
_str.push_byte(accum_str, '\n' as u8);
584584
}
585585
case ('r') {
586586
rdr.bump();
587-
accum_str += '\r' as u8;
587+
_str.push_byte(accum_str, '\r' as u8);
588588
}
589589
case ('t') {
590590
rdr.bump();
591-
accum_str += '\t' as u8;
591+
_str.push_byte(accum_str, '\t' as u8);
592592
}
593593
case ('\\') {
594594
rdr.bump();
595-
accum_str += '\\' as u8;
595+
_str.push_byte(accum_str, '\\' as u8);
596596
}
597597
case ('"') {
598598
rdr.bump();
599-
accum_str += '"' as u8;
599+
_str.push_byte(accum_str, '"' as u8);
600600
}
601601
// FIXME: unicode numeric escapes.
602602
case (?c2) {
@@ -607,7 +607,7 @@ impure fn next_token(reader rdr) -> token.token {
607607
}
608608
}
609609
case (_) {
610-
accum_str += rdr.curr() as u8;
610+
_str.push_byte(accum_str, rdr.curr() as u8);
611611
}
612612
}
613613
rdr.bump();

src/comp/front/parser.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import std.map.hashmap;
99
import driver.session;
1010
import util.common;
1111
import util.common.filename;
12-
import util.common.append;
1312
import util.common.span;
1413
import util.common.new_str_hash;
1514

@@ -303,7 +302,7 @@ impure fn parse_constrs(parser p) -> common.spanned[vec[@ast.constr]] {
303302
case (token.IDENT(_)) {
304303
auto constr = parse_ty_constr(p);
305304
hi = constr.span;
306-
append[@ast.constr](constrs, constr);
305+
_vec.push[@ast.constr](constrs, constr);
307306
if (p.peek() == token.COMMA) {
308307
p.bump();
309308
more = false;
@@ -573,7 +572,7 @@ impure fn parse_path(parser p, greed g) -> ast.path {
573572
alt (p.peek()) {
574573
case (token.IDENT(?i)) {
575574
hi = p.get_span();
576-
ids += i;
575+
ids += vec(i);
577576
p.bump();
578577
if (p.peek() == token.DOT) {
579578
if (g == GREEDY) {
@@ -699,7 +698,7 @@ impure fn parse_bottom_expr(parser p) -> @ast.expr {
699698
}
700699
case (token.COMMA) {
701700
p.bump();
702-
fields += parse_field(p);
701+
fields += vec(parse_field(p));
703702
}
704703
case (?t) {
705704
unexpected(p, t);
@@ -877,7 +876,7 @@ impure fn extend_expr_by_ident(parser p, span lo, span hi,
877876
case (ast.expr_path(?pth, ?def, ?ann)) {
878877
if (_vec.len[@ast.ty](pth.node.types) == 0u) {
879878
auto idents_ = pth.node.idents;
880-
idents_ += i;
879+
idents_ += vec(i);
881880
auto tys = parse_ty_args(p, hi);
882881
auto pth_ = spanned(pth.span, tys.span,
883882
rec(idents=idents_,
@@ -1763,8 +1762,8 @@ impure fn parse_item_obj(parser p, ast.layer lyr) -> @ast.item {
17631762
dtor = some[ast.block](parse_block(p));
17641763
}
17651764
case (_) {
1766-
append[@ast.method](meths,
1767-
parse_method(p));
1765+
_vec.push[@ast.method](meths,
1766+
parse_method(p));
17681767
}
17691768
}
17701769
}
@@ -2161,12 +2160,11 @@ impure fn parse_rest_import_name(parser p, ast.ident first,
21612160
-> @ast.view_item {
21622161
auto lo = p.get_span();
21632162
auto hi = lo;
2164-
let vec[ast.ident] identifiers = vec();
2165-
identifiers += first;
2163+
let vec[ast.ident] identifiers = vec(first);
21662164
while (p.peek() != token.SEMI) {
21672165
expect(p, token.DOT);
21682166
auto i = parse_ident(p);
2169-
identifiers += i;
2167+
identifiers += vec(i);
21702168
}
21712169
p.bump();
21722170
auto defined_id;
@@ -2402,7 +2400,7 @@ impure fn parse_crate_directives(parser p, token.token term)
24022400

24032401
while (p.peek() != term) {
24042402
auto cdir = @parse_crate_directive(p);
2405-
append[@ast.crate_directive](cdirs, cdir);
2403+
_vec.push[@ast.crate_directive](cdirs, cdir);
24062404
}
24072405

24082406
ret cdirs;

src/comp/front/token.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import util.common.ty_mach_to_str;
33
import util.common.new_str_hash;
44
import std._int;
55
import std._uint;
6+
import std._str;
67

78
tag binop {
89
PLUS;
@@ -302,8 +303,8 @@ fn to_str(token t) -> str {
302303
case (LIT_CHAR(?c)) {
303304
// FIXME: escape and encode.
304305
auto tmp = "'";
305-
tmp += c as u8;
306-
tmp += '\'' as u8;
306+
_str.push_byte(tmp, c as u8);
307+
_str.push_byte(tmp, '\'' as u8);
307308
ret tmp;
308309
}
309310

src/comp/middle/fold.rs

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import util.common.new_str_hash;
77
import util.common.spanned;
88
import util.common.span;
99
import util.common.ty_mach;
10-
import util.common.append;
1110

1211
import front.ast;
1312
import front.ast.fn_decl;
@@ -318,7 +317,7 @@ type ast_fold[ENV] =
318317
fn fold_path[ENV](&ENV env, ast_fold[ENV] fld, &path p) -> path {
319318
let vec[@ast.ty] tys_ = vec();
320319
for (@ast.ty t in p.node.types) {
321-
append[@ast.ty](tys_, fold_ty(env, fld, t));
320+
_vec.push[@ast.ty](tys_, fold_ty(env, fld, t));
322321
}
323322
let ast.path_ p_ = rec(idents=p.node.idents, types=tys_);
324323
ret fld.fold_path(env, p.span, p_);
@@ -357,15 +356,15 @@ fn fold_ty[ENV](&ENV env, ast_fold[ENV] fld, @ty t) -> @ty {
357356
case (ast.ty_tup(?elts)) {
358357
let vec[@ty] elts_ = vec();
359358
for (@ty elt in elts) {
360-
append[@ty](elts_,fold_ty(env, fld, elt));
359+
_vec.push[@ty](elts_,fold_ty(env, fld, elt));
361360
}
362361
ret fld.fold_ty_tup(env_, t.span, elts_);
363362
}
364363

365364
case (ast.ty_rec(?flds)) {
366365
let vec[ast.ty_field] flds_ = vec();
367366
for (ast.ty_field f in flds) {
368-
append[ast.ty_field]
367+
_vec.push[ast.ty_field]
369368
(flds_, rec(ty=fold_ty(env, fld, f.ty) with f));
370369
}
371370
ret fld.fold_ty_rec(env_, t.span, flds_);
@@ -378,7 +377,7 @@ fn fold_ty[ENV](&ENV env, ast_fold[ENV] fld, @ty t) -> @ty {
378377
m.inputs, m.output);
379378
alt (tfn.node) {
380379
case (ast.ty_fn(?p, ?ins, ?out)) {
381-
append[ast.ty_method]
380+
_vec.push[ast.ty_method]
382381
(meths_, rec(proto=p, inputs=ins, output=out
383382
with m));
384383
}
@@ -494,7 +493,7 @@ fn fold_pat[ENV](&ENV env, ast_fold[ENV] fld, @ast.pat p) -> @ast.pat {
494493
fn fold_exprs[ENV](&ENV env, ast_fold[ENV] fld, vec[@expr] es) -> vec[@expr] {
495494
let vec[@expr] exprs = vec();
496495
for (@expr e in es) {
497-
append[@expr](exprs, fold_expr(env, fld, e));
496+
_vec.push[@expr](exprs, fold_expr(env, fld, e));
498497
}
499498
ret exprs;
500499
}
@@ -525,7 +524,7 @@ fn fold_expr[ENV](&ENV env, ast_fold[ENV] fld, &@expr e) -> @expr {
525524
case (ast.expr_tup(?es, ?t)) {
526525
let vec[ast.elt] elts = vec();
527526
for (ast.elt e in es) {
528-
elts += fold_tup_elt[ENV](env, fld, e);
527+
elts += vec(fold_tup_elt[ENV](env, fld, e));
529528
}
530529
ret fld.fold_expr_tup(env_, e.span, elts, t);
531530
}
@@ -534,7 +533,7 @@ fn fold_expr[ENV](&ENV env, ast_fold[ENV] fld, &@expr e) -> @expr {
534533
let vec[ast.field] fields = vec();
535534
let option.t[@expr] b = none[@expr];
536535
for (ast.field f in fs) {
537-
fields += fold_rec_field(env, fld, f);
536+
fields += vec(fold_rec_field(env, fld, f));
538537
}
539538
alt (base) {
540539
case (none[@ast.expr]) { }
@@ -557,7 +556,7 @@ fn fold_expr[ENV](&ENV env, ast_fold[ENV] fld, &@expr e) -> @expr {
557556
for (option.t[@ast.expr] t_opt in args_opt) {
558557
alt (t_opt) {
559558
case (none[@ast.expr]) {
560-
aargs_opt += none[@ast.expr];
559+
aargs_opt += vec(none[@ast.expr]);
561560
}
562561
case (some[@ast.expr](?e)) {
563562
aargs_opt += vec(some(fold_expr(env_, fld, e)));
@@ -779,7 +778,7 @@ fn fold_block[ENV](&ENV env, ast_fold[ENV] fld, &block blk) -> block {
779778
let vec[@ast.stmt] stmts = vec();
780779
for (@ast.stmt s in blk.node.stmts) {
781780
auto new_stmt = fold_stmt[ENV](env_, fld, s);
782-
append[@ast.stmt](stmts, new_stmt);
781+
_vec.push[@ast.stmt](stmts, new_stmt);
783782
ast.index_stmt(index, new_stmt);
784783
}
785784

@@ -812,7 +811,7 @@ fn fold_fn_decl[ENV](&ENV env, ast_fold[ENV] fld,
812811
&ast.fn_decl decl) -> ast.fn_decl {
813812
let vec[ast.arg] inputs = vec();
814813
for (ast.arg a in decl.inputs) {
815-
inputs += fold_arg(env, fld, a);
814+
inputs += vec(fold_arg(env, fld, a));
816815
}
817816
auto output = fold_ty[ENV](env, fld, decl.output);
818817
ret fld.fold_fn_decl(env, decl.effect, inputs, output);
@@ -846,7 +845,7 @@ fn fold_obj[ENV](&ENV env, ast_fold[ENV] fld, &ast._obj ob) -> ast._obj {
846845
let vec[ast.obj_field] fields = vec();
847846
let vec[@ast.method] meths = vec();
848847
for (ast.obj_field f in ob.fields) {
849-
fields += fold_obj_field(env, fld, f);
848+
fields += vec(fold_obj_field(env, fld, f));
850849
}
851850
let option.t[block] dtor = none[block];
852851
alt (ob.dtor) {
@@ -867,7 +866,7 @@ fn fold_obj[ENV](&ENV env, ast_fold[ENV] fld, &ast._obj ob) -> ast._obj {
867866
m.node.ann),
868867
span=m.span);
869868
let ENV _env = fld.update_env_for_item(env, i);
870-
append[@ast.method](meths, fold_method(_env, fld, m));
869+
_vec.push[@ast.method](meths, fold_method(_env, fld, m));
871870
}
872871
ret fld.fold_obj(env, fields, meths, dtor);
873872
}
@@ -944,8 +943,8 @@ fn fold_item[ENV](&ENV env, ast_fold[ENV] fld, @item i) -> @item {
944943
auto new_ty = fold_ty[ENV](env_, fld, va.ty);
945944
new_args += vec(rec(ty=new_ty, id=va.id));
946945
}
947-
new_variants += rec(name=v.name, args=new_args, id=v.id,
948-
ann=v.ann);
946+
new_variants += vec(rec(name=v.name, args=new_args, id=v.id,
947+
ann=v.ann));
949948
}
950949
ret fld.fold_item_tag(env_, i.span, ident, new_variants,
951950
ty_params, id);
@@ -969,13 +968,13 @@ fn fold_mod[ENV](&ENV e, ast_fold[ENV] fld, &ast._mod m) -> ast._mod {
969968

970969
for (@view_item vi in m.view_items) {
971970
auto new_vi = fold_view_item[ENV](e, fld, vi);
972-
append[@view_item](view_items, new_vi);
971+
_vec.push[@view_item](view_items, new_vi);
973972
ast.index_view_item(index, new_vi);
974973
}
975974

976975
for (@item i in m.items) {
977976
auto new_item = fold_item[ENV](e, fld, i);
978-
append[@item](items, new_item);
977+
_vec.push[@item](items, new_item);
979978
ast.index_item(index, new_item);
980979
}
981980

@@ -1009,12 +1008,12 @@ fn fold_native_mod[ENV](&ENV e, ast_fold[ENV] fld,
10091008

10101009
for (@view_item vi in m.view_items) {
10111010
auto new_vi = fold_view_item[ENV](e, fld, vi);
1012-
append[@view_item](view_items, new_vi);
1011+
_vec.push[@view_item](view_items, new_vi);
10131012
}
10141013

10151014
for (@native_item i in m.items) {
10161015
auto new_item = fold_native_item[ENV](e, fld, i);
1017-
append[@native_item](items, new_item);
1016+
_vec.push[@native_item](items, new_item);
10181017
ast.index_native_item(index, new_item);
10191018
}
10201019

0 commit comments

Comments
 (0)