From f164d7779aea578dfadf22146e294e0fcd142796 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Wed, 6 Jul 2011 16:12:39 -0700 Subject: [PATCH] rustc: Move AST constraints to interior vectors --- src/comp/syntax/ast.rs | 8 ++++---- src/comp/syntax/fold.rs | 9 +++++---- src/comp/syntax/parse/parser.rs | 12 ++++++------ src/comp/syntax/print/pprust.rs | 4 ++-- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/comp/syntax/ast.rs b/src/comp/syntax/ast.rs index 0099535651d..cd20f703291 100644 --- a/src/comp/syntax/ast.rs +++ b/src/comp/syntax/ast.rs @@ -337,7 +337,7 @@ fn is_path(&@expr e) -> bool { ty_arg[] inputs, @ty output, controlflow cf, - vec[@constr] constrs); + (@constr)[] constrs); type ty_field = spanned[ty_field_]; @@ -403,11 +403,11 @@ fn ty_mach_to_str(ty_mach tm) -> str { ty_chan(@ty); ty_tup(mt[]); ty_rec(ty_field[]); - ty_fn(proto, ty_arg[], @ty, controlflow, vec[@constr]); + ty_fn(proto, ty_arg[], @ty, controlflow, (@constr)[]); ty_obj(ty_method[]); ty_path(path, node_id); ty_type; - ty_constr(@ty, vec[@constr]); + ty_constr(@ty, (@constr)[]); } @@ -442,7 +442,7 @@ fn ty_mach_to_str(ty_mach tm) -> str { @ty output, purity purity, controlflow cf, - vec[@constr] constraints); + (@constr)[] constraints); tag purity { pure_fn; // declared with "pred" diff --git a/src/comp/syntax/fold.rs b/src/comp/syntax/fold.rs index 09e46d50122..3a8fd4260fe 100644 --- a/src/comp/syntax/fold.rs +++ b/src/comp/syntax/fold.rs @@ -175,8 +175,8 @@ fn noop_fold_native_item(&@native_item ni, ast_fold fld) -> @native_item { rec(inputs=map(fold_arg, fdec.inputs), output=fld.fold_ty(fdec.output), purity=fdec.purity, cf=fdec.cf, - constraints=map(fld.fold_constr, - fdec.constraints)), + constraints=ivec::map(fld.fold_constr, + fdec.constraints)), typms) } }, @@ -450,11 +450,12 @@ fn noop_fold_constr(&constr_ c, ast_fold fld) -> constr_ { fn noop_fold_fn(&_fn f, ast_fold fld) -> _fn { auto fold_arg = bind fold_arg_(_, fld); - ret rec(decl= rec(inputs=map(fold_arg, f.decl.inputs), + ret rec(decl= rec(inputs=vec::map(fold_arg, f.decl.inputs), output=fld.fold_ty(f.decl.output), purity=f.decl.purity, cf=f.decl.cf, - constraints=map(fld.fold_constr, f.decl.constraints)), + constraints=ivec::map(fld.fold_constr, + f.decl.constraints)), proto = f.proto, body = fld.fold_block(f.body)); } diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index 3abe4f5a6ed..c0b102d5c5e 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -363,17 +363,17 @@ fn parse_ty_constr(&vec[ast::arg] fn_args, &parser p) -> @ast::constr { // Use the args list to translate each bound variable // mentioned in a constraint to an arg index. // Seems weird to do this in the parser, but I'm not sure how else to. -fn parse_constrs(&vec[ast::arg] args, &parser p) -> - ast::spanned[vec[@ast::constr]] { +fn parse_constrs(&vec[ast::arg] args, &parser p) + -> ast::spanned[(@ast::constr)[]] { auto lo = p.get_lo_pos(); auto hi = p.get_hi_pos(); - let vec[@ast::constr] constrs = []; + let (@ast::constr)[] constrs = ~[]; if (p.peek() == token::COLON) { p.bump(); while (true) { auto constr = parse_ty_constr(args, p); hi = constr.span.hi; - vec::push(constrs, constr); + constrs += ~[constr]; if (p.peek() == token::COMMA) { p.bump(); } else { break; } } } @@ -1799,7 +1799,7 @@ fn parse_dtor(&parser p) -> @ast::method { cf=ast::return, // I guess dtors can't have constraints? - constraints=[]); + constraints=~[]); let ast::_fn f = rec(decl=d, proto=ast::proto_fn, body=b); let ast::method_ m = rec(ident="drop", meth=f, id=p.get_id()); @@ -1844,7 +1844,7 @@ fn parse_item_res(&parser p, ast::layer lyr, &ast::attribute[] attrs) -> output=@spanned(lo, lo, ast::ty_nil), purity=ast::impure_fn, cf=ast::return, - constraints=[]); + constraints=~[]); auto f = rec(decl=decl, proto=ast::proto_fn, body=dtor); ret mk_item(p, lo, dtor.span.hi, ident, ast::item_res(f, p.get_id(), ty_params, p.get_id()), attrs); diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs index c93e7631c1a..6f63a600925 100644 --- a/src/comp/syntax/print/pprust.rs +++ b/src/comp/syntax/print/pprust.rs @@ -1235,7 +1235,7 @@ fn print_mt(&ps s, &ast::mt mt) { fn print_ty_fn(&ps s, &ast::proto proto, &option::t[str] id, &ast::ty_arg[] inputs, &@ast::ty output, - &ast::controlflow cf, &vec[@ast::constr] constrs) { + &ast::controlflow cf, &(@ast::constr)[] constrs) { ibox(s, indent_unit); if (proto == ast::proto_fn) { word(s.s, "fn"); @@ -1488,7 +1488,7 @@ fn ast_constr_to_str(&@ast::constr c) -> str { constr_args_to_str(uint_to_str, cag_ivec); } -fn ast_constrs_str(&vec[@ast::constr] constrs) -> str { +fn ast_constrs_str(&(@ast::constr)[] constrs) -> str { auto s = ""; auto colon = true; for (@ast::constr c in constrs) { -- GitLab