Skip to content

Commit 83feece

Browse files
committed
---
yaml --- r: 3657 b: refs/heads/master c: 7714cb2 h: refs/heads/master i: 3655: 9fd1a62 v: v3
1 parent 39d57dc commit 83feece

File tree

13 files changed

+72
-44
lines changed

13 files changed

+72
-44
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: 368f1f4ba8c00a42cc9ffb91082b9462ecb61dc3
2+
refs/heads/master: 7714cb297b5ef54690acaec26cae4828adfceab7

trunk/src/comp/metadata/tydecode.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,21 +80,21 @@ fn parse_constrs(@pstate st, str_def sd) -> (@ty::constr_def)[] {
8080
}
8181

8282
fn parse_path(@pstate st, str_def sd) -> ast::path {
83-
let vec[ast::ident] idents = [];
83+
let ast::ident[] idents = ~[];
8484
fn is_last(char c) -> bool {
8585
ret (c == '(' || c == ':');
8686
}
87-
idents += [parse_ident_(st, sd, is_last)];
87+
idents += ~[parse_ident_(st, sd, is_last)];
8888
while (true) {
8989
alt (peek(st) as char) {
9090
case (':') { next(st); next(st); }
9191
case (?c) {
9292
if (c == '(') {
9393
ret respan(rec(lo=0u, hi=0u),
94-
rec(idents=idents, types=[]));
94+
rec(idents=idents, types=~[]));
9595
}
9696
else {
97-
idents += [parse_ident_(st, sd, is_last)];
97+
idents += ~[parse_ident_(st, sd, is_last)];
9898
}
9999
}
100100
}

trunk/src/comp/middle/resolve.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import syntax::ast::respan;
1818
import middle::ty::constr_table;
1919
import syntax::visit;
2020
import visit::vt;
21+
import std::ivec;
2122
import std::map::hashmap;
2223
import std::list;
2324
import std::list::list;
@@ -554,9 +555,9 @@ fn mk_unresolved_msg(&ident id, &str kind) -> str {
554555
}
555556

556557
// Lookup helpers
557-
fn lookup_path_strict(&env e, &scopes sc, &span sp, vec[ident] idents,
558+
fn lookup_path_strict(&env e, &scopes sc, &span sp, &ident[] idents,
558559
namespace ns) -> option::t[def] {
559-
auto n_idents = vec::len(idents);
560+
auto n_idents = ivec::len(idents);
560561
auto headns = if (n_idents == 1u) { ns } else { ns_module };
561562
auto dcur = lookup_in_scope_strict(e, sc, sp, idents.(0), headns);
562563
auto i = 1u;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ fn substitute_arg(&ty::ctxt cx, &(@expr)[] actuals, @constr_arg a) ->
641641
}
642642

643643
fn path_to_ident(&ty::ctxt cx, &path p) -> ident {
644-
alt (std::vec::last(p.node.idents)) {
644+
alt (ivec::last(p.node.idents)) {
645645
case (none) { cx.sess.span_fatal(p.span, "Malformed path"); }
646646
case (some(?i)) { ret i; }
647647
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ fn kill_poststate(&fn_ctxt fcx, node_id id, &constr_ c) -> bool {
230230
fn clear_in_poststate_expr(&fn_ctxt fcx, &@expr e, &poststate t) {
231231
alt (e.node) {
232232
case (expr_path(?p)) {
233-
alt (std::vec::last(p.node.idents)) {
233+
alt (ivec::last(p.node.idents)) {
234234
case (some(?i)) {
235235
alt (local_node_id_to_def(fcx, e.id)) {
236236
case (some(def_local(?d_id))) {

trunk/src/comp/middle/typeck.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ fn instantiate_path(&@fn_ctxt fcx, &ast::path pth, &ty_param_count_and_ty tpt,
157157
ty_param_count);
158158
auto ty_param_vars = bind_result._0;
159159
auto ty_substs_opt;
160-
auto ty_substs_len = vec::len[@ast::ty](pth.node.types);
160+
auto ty_substs_len = ivec::len[@ast::ty](pth.node.types);
161161
if (ty_substs_len > 0u) {
162162
let ty::t[] ty_substs = ~[];
163163
auto i = 0u;
@@ -258,7 +258,7 @@ fn ast_ty_to_ty(&ty::ctxt tcx, &ty_getter getter, &@ast::ty ast_ty) -> ty::t {
258258
ret rec(ty=ast_ty_to_ty(tcx, getter, mt.ty), mut=mt.mut);
259259
}
260260
fn instantiate(&ty::ctxt tcx, &span sp, &ty_getter getter,
261-
&ast::def_id id, &vec[@ast::ty] args) -> ty::t {
261+
&ast::def_id id, &(@ast::ty)[] args) -> ty::t {
262262
// TODO: maybe record cname chains so we can do
263263
// "foo = int" like OCaml?
264264

@@ -346,9 +346,8 @@ fn ast_ty_to_ty(&ty::ctxt tcx, &ty_getter getter, &@ast::ty ast_ty) -> ty::t {
346346
case (ast::ty_path(?path, ?id)) {
347347
alt (tcx.def_map.find(id)) {
348348
case (some(ast::def_ty(?id))) {
349-
typ =
350-
instantiate(tcx, ast_ty.span, getter, id,
351-
path.node.types);
349+
typ = instantiate(tcx, ast_ty.span, getter, id,
350+
path.node.types);
352351
}
353352
case (some(ast::def_native_ty(?id))) { typ = getter(id)._1; }
354353
case (some(ast::def_ty_arg(?id))) {
@@ -1696,7 +1695,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
16961695
// The definition doesn't take type parameters. If the programmer
16971696
// supplied some, that's an error.
16981697

1699-
if (vec::len[@ast::ty](pth.node.types) > 0u) {
1698+
if (ivec::len[@ast::ty](pth.node.types) > 0u) {
17001699
fcx.ccx.tcx.sess.span_fatal(expr.span,
17011700
"this kind of value does not \
17021701
take type parameters");

trunk/src/comp/syntax/ast.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
// The Rust abstract syntax tree.
12

3+
import std::ivec;
24
import std::option;
35
import std::str;
46
import std::vec;
@@ -15,11 +17,11 @@ type fn_ident = option::t[ident];
1517
// FIXME: with typestate constraint, could say
1618
// idents and types are the same length, and are
1719
// non-empty
18-
type path_ = rec(vec[ident] idents, vec[@ty] types);
20+
type path_ = rec(ident[] idents, (@ty)[] types);
1921

2022
type path = spanned[path_];
2123

22-
fn path_name(&path p) -> str { ret str::connect(p.node.idents, "::"); }
24+
fn path_name(&path p) -> str { ret str::connect_ivec(p.node.idents, "::"); }
2325

2426
type crate_num = int;
2527
type node_id = int;
@@ -632,11 +634,11 @@ fn ternary_to_if(&@expr e) -> @ast::expr {
632634

633635
// Path stringification
634636
fn path_to_str(&ast::path pth) -> str {
635-
auto result = str::connect(pth.node.idents, "::");
636-
if (vec::len[@ast::ty](pth.node.types) > 0u) {
637+
auto result = str::connect_ivec(pth.node.idents, "::");
638+
if (ivec::len[@ast::ty](pth.node.types) > 0u) {
637639
fn f(&@ast::ty t) -> str { ret print::pprust::ty_to_str(*t); }
638640
result += "[";
639-
result += str::connect(vec::map(f, pth.node.types), ",");
641+
result += str::connect_ivec(ivec::map(f, pth.node.types), ",");
640642
result += "]";
641643
}
642644
ret result;

trunk/src/comp/syntax/ext/base.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import std::ivec;
12
import std::vec;
23
import std::option;
34
import std::map::hashmap;
@@ -71,8 +72,8 @@ fn expr_to_str(&ext_ctxt cx, @ast::expr expr, str error) -> str {
7172
fn expr_to_ident(&ext_ctxt cx, @ast::expr expr, str error) -> ast::ident {
7273
alt(expr.node) {
7374
case (ast::expr_path(?p)) {
74-
if (vec::len(p.node.types) > 0u
75-
|| vec::len(p.node.idents) != 1u) {
75+
if (ivec::len(p.node.types) > 0u
76+
|| ivec::len(p.node.idents) != 1u) {
7677
cx.span_fatal(expr.span, error);
7778
} else {
7879
ret p.node.idents.(0);

trunk/src/comp/syntax/ext/fmt.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,9 @@ fn pieces_to_expr(&ext_ctxt cx, span sp, vec[piece] pieces,
6060
auto binexpr = ast::expr_binary(ast::add, lhs, rhs);
6161
ret @rec(id=cx.next_id(), node=binexpr, span=sp);
6262
}
63-
fn make_path_expr(&ext_ctxt cx, span sp, vec[ast::ident] idents)
63+
fn make_path_expr(&ext_ctxt cx, span sp, &ast::ident[] idents)
6464
-> @ast::expr {
65-
let vec[@ast::ty] types = [];
66-
auto path = rec(idents=idents, types=types);
65+
auto path = rec(idents=idents, types=~[]);
6766
auto sp_path = rec(node=path, span=sp);
6867
auto pathexpr = ast::expr_path(sp_path);
6968
ret @rec(id=cx.next_id(), node=pathexpr, span=sp);
@@ -73,7 +72,7 @@ fn pieces_to_expr(&ext_ctxt cx, span sp, vec[piece] pieces,
7372
auto vecexpr = ast::expr_vec(exprs, ast::imm, ast::sk_rc);
7473
ret @rec(id=cx.next_id(), node=vecexpr, span=sp);
7574
}
76-
fn make_call(&ext_ctxt cx, span sp, vec[ast::ident] fn_path,
75+
fn make_call(&ext_ctxt cx, span sp, &ast::ident[] fn_path,
7776
vec[@ast::expr] args) -> @ast::expr {
7877
auto pathexpr = make_path_expr(cx, sp, fn_path);
7978
auto callexpr = ast::expr_call(pathexpr, args);
@@ -92,11 +91,11 @@ fn pieces_to_expr(&ext_ctxt cx, span sp, vec[piece] pieces,
9291
auto recexpr = ast::expr_rec(astfields, option::none[@ast::expr]);
9392
ret @rec(id=cx.next_id(), node=recexpr, span=sp);
9493
}
95-
fn make_path_vec(str ident) -> vec[str] {
94+
fn make_path_vec(str ident) -> str[] {
9695
// FIXME: #fmt can't currently be used from within std
9796
// because we're explicitly referencing the 'std' crate here
9897

99-
ret ["std", "extfmt", "rt", ident];
98+
ret ~["std", "extfmt", "rt", ident];
10099
}
101100
fn make_rt_path_expr(&ext_ctxt cx, span sp, str ident) ->
102101
@ast::expr {

trunk/src/comp/syntax/ext/simplext.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std;
22

33
import codemap::span;
4+
import std::ivec;
45
import std::vec;
56
import std::option;
67
import vec::map;
@@ -50,7 +51,7 @@ fn subst_ident(&ext_ctxt cx, &vec[@ast::expr] args,
5051
fn subst_path(&ext_ctxt cx, &vec[@ast::expr] args,
5152
@vec[ident] param_names, &path_ p, ast_fold fld) -> path_ {
5253
// Don't substitute into qualified names.
53-
if (len(p.types) > 0u || len(p.idents) != 1u) { ret p; }
54+
if (ivec::len(p.types) > 0u || ivec::len(p.idents) != 1u) { ret p; }
5455
alt (position(p.idents.(0), *param_names)) {
5556
case (some[uint](?idx)) {
5657
alt (args.(idx).node) {
@@ -75,7 +76,8 @@ fn subst_expr(&ext_ctxt cx, &vec[@ast::expr] args, @vec[ident] param_names,
7576
ret alt(e) {
7677
case (expr_path(?p)){
7778
// Don't substitute into qualified names.
78-
if (len(p.node.types) > 0u || len(p.node.idents) != 1u) { e }
79+
if (ivec::len(p.node.types) > 0u ||
80+
ivec::len(p.node.idents) != 1u) { e }
7981
alt (position(p.node.idents.(0), *param_names)) {
8082
case (some[uint](?idx)) {
8183
args.(idx).node

trunk/src/comp/syntax/fold.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import syntax::codemap::span;
22
import ast::*;
33

4+
import std::ivec;
45
import std::vec;
56
import std::option;
67
import vec::map;
@@ -486,8 +487,8 @@ fn noop_fold_ident(&ident i, ast_fold fld) -> ident {
486487
}
487488

488489
fn noop_fold_path(&path_ p, ast_fold fld) -> path_ {
489-
ret rec(idents=map(fld.fold_ident, p.idents),
490-
types=map(fld.fold_ty, p.types));
490+
ret rec(idents=ivec::map(fld.fold_ident, p.idents),
491+
types=ivec::map(fld.fold_ty, p.types));
491492
}
492493

493494
fn noop_fold_local(&local_ l, ast_fold fld) -> local_ {

trunk/src/comp/syntax/parse/parser.rs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
import std::io;
3+
import std::ivec;
34
import std::vec;
45
import std::str;
56
import std::option;
@@ -409,13 +410,18 @@ fn parse_ty_postfix(@ast::ty orig_t, &parser p) -> @ast::ty {
409410
// This is explicit type parameter instantiation.
410411
auto seq = parse_seq_to_end(token::RBRACKET, some(token::COMMA),
411412
parse_ty, p);
413+
414+
// FIXME: Remove this vec->ivec conversion.
415+
auto seq_ivec = ~[];
416+
for (@ast::ty typ in seq) { seq_ivec += ~[typ]; }
417+
412418
alt (orig_t.node) {
413419
case (ast::ty_path(?pth, ?ann)) {
414420
auto hi = p.get_hi_pos();
415421
ret @spanned(lo, hi,
416422
ast::ty_path(spanned(lo, hi,
417423
rec(idents=pth.node.idents,
418-
types=seq)),
424+
types=seq_ivec)),
419425
ann));
420426
}
421427
case (_) {
@@ -637,20 +643,20 @@ fn is_ident(token::token t) -> bool {
637643
fn parse_path(&parser p) -> ast::path {
638644
auto lo = p.get_lo_pos();
639645
auto hi = lo;
640-
let vec[ast::ident] ids = [];
646+
let ast::ident[] ids = ~[];
641647
while (true) {
642648
alt (p.peek()) {
643649
case (token::IDENT(?i, _)) {
644650
hi = p.get_hi_pos();
645-
ids += [p.get_str(i)];
651+
ids += ~[p.get_str(i)];
646652
p.bump();
647653
if (p.peek() == token::MOD_SEP) { p.bump(); } else { break; }
648654
}
649655
case (_) { break; }
650656
}
651657
}
652658
hi = p.get_hi_pos();
653-
ret spanned(lo, hi, rec(idents=ids, types=[]));
659+
ret spanned(lo, hi, rec(idents=ids, types=~[]));
654660
}
655661

656662
fn parse_path_and_ty_param_substs(&parser p) -> ast::path {
@@ -659,8 +665,13 @@ fn parse_path_and_ty_param_substs(&parser p) -> ast::path {
659665
if (p.peek() == token::LBRACKET) {
660666
auto seq = parse_seq(token::LBRACKET, token::RBRACKET,
661667
some(token::COMMA), parse_ty, p);
668+
669+
// FIXME: Remove this vec->ivec conversion.
670+
auto seq_ivec = ~[];
671+
for (@ast::ty typ in seq.node) { seq_ivec += ~[typ]; }
672+
662673
auto hi = p.get_hi_pos();
663-
path = spanned(lo, hi, rec(idents=path.node.idents, types=seq.node));
674+
path = spanned(lo, hi, rec(idents=path.node.idents, types=seq_ivec));
664675
}
665676
ret path;
666677
}
@@ -954,7 +965,7 @@ fn parse_syntax_ext(&parser p) -> @ast::expr {
954965

955966
fn parse_syntax_ext_naked(&parser p, uint lo) -> @ast::expr {
956967
auto pth = parse_path(p);
957-
if (vec::len(pth.node.idents) == 0u) {
968+
if (ivec::len(pth.node.idents) == 0u) {
958969
p.fatal("expected a syntax expander name");
959970
}
960971
auto es = parse_seq(token::LPAREN, token::RPAREN,
@@ -974,7 +985,7 @@ fn parse_syntax_ext_naked(&parser p, uint lo) -> @ast::expr {
974985
fn expand_syntax_ext(&parser p, span sp, &ast::path path,
975986
vec[@ast::expr] args, option::t[str] body) ->
976987
ast::expr_ {
977-
assert (vec::len(path.node.idents) > 0u);
988+
assert (ivec::len(path.node.idents) > 0u);
978989
auto extname = path.node.idents.(0);
979990
alt (p.get_syntax_expanders().find(extname)) {
980991
case (none) { p.fatal("unknown syntax expander: '" + extname + "'"); }

trunk/src/comp/syntax/print/pprust.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11

2-
import std::uint;
2+
import std::ivec;
33
import std::int;
4-
import std::vec;
5-
import std::str;
64
import std::io;
5+
import std::str;
6+
import std::uint;
7+
import std::vec;
78
import std::option;
89
import parse::lexer;
910
import syntax::codemap::codemap;
@@ -206,6 +207,17 @@ fn commasep[IN](&ps s, breaks b, vec[IN] elts, fn(&ps, &IN) op) {
206207
end(s);
207208
}
208209

210+
fn commasep_ivec[IN](&ps s, breaks b, &IN[] elts, fn(&ps, &IN) op) {
211+
box(s, 0u, b);
212+
auto first = true;
213+
for (IN elt in elts) {
214+
if (first) { first = false; } else { word_space(s, ","); }
215+
op(s, elt);
216+
}
217+
end(s);
218+
}
219+
220+
209221
fn commasep_cmnt[IN](&ps s, breaks b, vec[IN] elts, fn(&ps, &IN) op,
210222
fn(&IN) -> codemap::span get_span) {
211223
box(s, 0u, b);
@@ -1013,9 +1025,9 @@ fn print_path(&ps s, &ast::path path) {
10131025
if (first) { first = false; } else { word(s.s, "::"); }
10141026
word(s.s, id);
10151027
}
1016-
if (vec::len(path.node.types) > 0u) {
1028+
if (ivec::len(path.node.types) > 0u) {
10171029
word(s.s, "[");
1018-
commasep(s, inconsistent, path.node.types, print_boxed_type);
1030+
commasep_ivec(s, inconsistent, path.node.types, print_boxed_type);
10191031
word(s.s, "]");
10201032
}
10211033
}

0 commit comments

Comments
 (0)