libsyntax: progress on making syntax::visit vecs_implicitly_copyable-free
This commit is contained in:
parent
9ac5262bdf
commit
f14409c528
41 changed files with 1060 additions and 921 deletions
|
@ -134,7 +134,7 @@ pub pure fn safe_to_use_expr(e: ast::expr, tm: test_mode) -> bool {
|
|||
|
||||
pub fn safe_to_steal_ty(t: @ast::Ty, tm: test_mode) -> bool {
|
||||
// Restrictions happen to be the same.
|
||||
safe_to_replace_ty(t.node, tm)
|
||||
safe_to_replace_ty(&t.node, tm)
|
||||
}
|
||||
|
||||
// Not type-parameterized: https://github.com/mozilla/rust/issues/898 (FIXED)
|
||||
|
@ -175,8 +175,8 @@ pub fn steal(crate: ast::crate, tm: test_mode) -> StolenStuff {
|
|||
}
|
||||
|
||||
|
||||
pub fn safe_to_replace_expr(e: ast::expr_, _tm: test_mode) -> bool {
|
||||
match e {
|
||||
pub fn safe_to_replace_expr(e: &ast::expr_, _tm: test_mode) -> bool {
|
||||
match *e {
|
||||
// https://github.com/mozilla/rust/issues/652
|
||||
ast::expr_if(*) => { false }
|
||||
ast::expr_block(_) => { false }
|
||||
|
@ -188,8 +188,8 @@ pub fn safe_to_replace_expr(e: ast::expr_, _tm: test_mode) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn safe_to_replace_ty(t: ast::ty_, _tm: test_mode) -> bool {
|
||||
match t {
|
||||
pub fn safe_to_replace_ty(t: &ast::ty_, _tm: test_mode) -> bool {
|
||||
match *t {
|
||||
ast::ty_infer => { false } // always implicit, always top level
|
||||
ast::ty_bot => { false } // in source, can only appear
|
||||
// as the out type of a function
|
||||
|
@ -204,7 +204,7 @@ pub fn replace_expr_in_crate(crate: ast::crate, i: uint,
|
|||
ast::crate {
|
||||
let j: @mut uint = @mut 0u;
|
||||
fn fold_expr_rep(j_: @mut uint, i_: uint, newexpr_: ast::expr_,
|
||||
original: ast::expr_, fld: fold::ast_fold,
|
||||
original: &ast::expr_, fld: fold::ast_fold,
|
||||
tm_: test_mode) ->
|
||||
ast::expr_ {
|
||||
*j_ += 1u;
|
||||
|
@ -221,7 +221,7 @@ pub fn replace_expr_in_crate(crate: ast::crate, i: uint,
|
|||
.. *fold::default_ast_fold()
|
||||
};
|
||||
let af = fold::make_fold(afp);
|
||||
let crate2: @ast::crate = @af.fold_crate(crate);
|
||||
let crate2: @ast::crate = @af.fold_crate(&crate);
|
||||
*crate2
|
||||
}
|
||||
|
||||
|
@ -231,7 +231,7 @@ pub fn replace_ty_in_crate(crate: ast::crate, i: uint, newty: ast::Ty,
|
|||
tm: test_mode) -> ast::crate {
|
||||
let j: @mut uint = @mut 0u;
|
||||
fn fold_ty_rep(j_: @mut uint, i_: uint, newty_: ast::ty_,
|
||||
original: ast::ty_, fld: fold::ast_fold,
|
||||
original: &ast::ty_, fld: fold::ast_fold,
|
||||
tm_: test_mode) ->
|
||||
ast::ty_ {
|
||||
*j_ += 1u;
|
||||
|
@ -244,7 +244,7 @@ pub fn replace_ty_in_crate(crate: ast::crate, i: uint, newty: ast::Ty,
|
|||
.. *fold::default_ast_fold()
|
||||
};
|
||||
let af = fold::make_fold(afp);
|
||||
let crate2: @ast::crate = @af.fold_crate(crate);
|
||||
let crate2: @ast::crate = @af.fold_crate(&crate);
|
||||
*crate2
|
||||
}
|
||||
|
||||
|
|
|
@ -396,7 +396,7 @@ pub fn pretty_print_input(sess: Session, +cfg: ast::crate_cfg, input: input,
|
|||
pprust::node_block(s, ref blk) => {
|
||||
pp::space(s.s);
|
||||
pprust::synth_comment(
|
||||
s, ~"block " + int::to_str((*blk).node.id));
|
||||
s, ~"block " + int::to_str(blk.node.id));
|
||||
}
|
||||
pprust::node_expr(s, expr) => {
|
||||
pp::space(s.s);
|
||||
|
|
|
@ -45,7 +45,7 @@ pub fn strip_items(crate: @ast::crate, in_cfg: in_cfg_pred)
|
|||
.. *fold::default_ast_fold()};
|
||||
|
||||
let fold = fold::make_fold(precursor);
|
||||
let res = @fold.fold_crate(*crate);
|
||||
let res = @fold.fold_crate(&*crate);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ fn filter_view_item(cx: @Context, &&view_item: @ast::view_item
|
|||
}
|
||||
}
|
||||
|
||||
fn fold_mod(cx: @Context, m: ast::_mod, fld: fold::ast_fold) -> ast::_mod {
|
||||
fn fold_mod(cx: @Context, m: &ast::_mod, fld: fold::ast_fold) -> ast::_mod {
|
||||
let filtered_items =
|
||||
m.items.filter_mapped(|a| filter_item(cx, *a));
|
||||
let filtered_view_items =
|
||||
|
@ -83,7 +83,7 @@ fn filter_foreign_item(cx: @Context, &&item: @ast::foreign_item) ->
|
|||
|
||||
fn fold_foreign_mod(
|
||||
cx: @Context,
|
||||
nm: ast::foreign_mod,
|
||||
nm: &ast::foreign_mod,
|
||||
fld: fold::ast_fold
|
||||
) -> ast::foreign_mod {
|
||||
let filtered_items =
|
||||
|
@ -98,21 +98,21 @@ fn fold_foreign_mod(
|
|||
}
|
||||
}
|
||||
|
||||
fn fold_item_underscore(cx: @Context, +item: ast::item_,
|
||||
fn fold_item_underscore(cx: @Context, item: &ast::item_,
|
||||
fld: fold::ast_fold) -> ast::item_ {
|
||||
let item = match item {
|
||||
ast::item_impl(a, b, c, methods) => {
|
||||
let item = match *item {
|
||||
ast::item_impl(ref a, b, c, ref methods) => {
|
||||
let methods = methods.filtered(|m| method_in_cfg(cx, *m) );
|
||||
ast::item_impl(a, b, c, methods)
|
||||
ast::item_impl(/*bad*/ copy *a, b, c, methods)
|
||||
}
|
||||
ast::item_trait(ref a, ref b, ref methods) => {
|
||||
let methods = methods.filtered(|m| trait_method_in_cfg(cx, m) );
|
||||
ast::item_trait(/*bad*/copy *a, /*bad*/copy *b, methods)
|
||||
}
|
||||
item => item
|
||||
ref item => /*bad*/ copy *item
|
||||
};
|
||||
|
||||
fold::noop_fold_item_underscore(item, fld)
|
||||
fold::noop_fold_item_underscore(&item, fld)
|
||||
}
|
||||
|
||||
fn filter_stmt(cx: @Context, &&stmt: @ast::stmt) ->
|
||||
|
@ -134,7 +134,7 @@ fn filter_stmt(cx: @Context, &&stmt: @ast::stmt) ->
|
|||
|
||||
fn fold_block(
|
||||
cx: @Context,
|
||||
b: ast::blk_,
|
||||
b: &ast::blk_,
|
||||
fld: fold::ast_fold
|
||||
) -> ast::blk_ {
|
||||
let filtered_stmts =
|
||||
|
|
|
@ -66,10 +66,13 @@ fn inject_libcore_ref(sess: Session,
|
|||
view_items: vis,
|
||||
../*bad*/copy crate.module
|
||||
};
|
||||
new_module = fld.fold_mod(new_module);
|
||||
new_module = fld.fold_mod(&new_module);
|
||||
|
||||
// FIXME #2543: Bad copy.
|
||||
let new_crate = ast::crate_ { module: new_module, ..copy crate };
|
||||
let new_crate = ast::crate_ {
|
||||
module: new_module,
|
||||
..copy *crate
|
||||
};
|
||||
(new_crate, span)
|
||||
},
|
||||
fold_mod: |module, fld| {
|
||||
|
@ -95,12 +98,15 @@ fn inject_libcore_ref(sess: Session,
|
|||
let vis = vec::append(~[vi2], module.view_items);
|
||||
|
||||
// FIXME #2543: Bad copy.
|
||||
let new_module = ast::_mod { view_items: vis, ..copy module };
|
||||
fold::noop_fold_mod(new_module, fld)
|
||||
let new_module = ast::_mod {
|
||||
view_items: vis,
|
||||
..copy *module
|
||||
};
|
||||
fold::noop_fold_mod(&new_module, fld)
|
||||
},
|
||||
..*fold::default_ast_fold()
|
||||
};
|
||||
|
||||
let fold = fold::make_fold(precursor);
|
||||
@fold.fold_crate(*crate)
|
||||
@fold.fold_crate(crate)
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ fn generate_test_harness(sess: session::Session,
|
|||
fold_mod: |a,b| fold_mod(cx, a, b),.. *fold::default_ast_fold()};
|
||||
|
||||
let fold = fold::make_fold(precursor);
|
||||
let res = @fold.fold_crate(*crate);
|
||||
let res = @fold.fold_crate(&*crate);
|
||||
cx.ext_cx.bt_pop();
|
||||
return res;
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ fn strip_test_functions(crate: @ast::crate) -> @ast::crate {
|
|||
}
|
||||
|
||||
fn fold_mod(cx: @mut TestCtxt,
|
||||
m: ast::_mod,
|
||||
m: &ast::_mod,
|
||||
fld: fold::ast_fold)
|
||||
-> ast::_mod {
|
||||
// Remove any #[main] from the AST so it doesn't clash with
|
||||
|
@ -125,19 +125,21 @@ fn fold_mod(cx: @mut TestCtxt,
|
|||
items: vec::map(m.items, |i| nomain(cx, *i)),
|
||||
};
|
||||
|
||||
fold::noop_fold_mod(mod_nomain, fld)
|
||||
fold::noop_fold_mod(&mod_nomain, fld)
|
||||
}
|
||||
|
||||
fn fold_crate(cx: @mut TestCtxt,
|
||||
c: ast::crate_,
|
||||
c: &ast::crate_,
|
||||
fld: fold::ast_fold)
|
||||
-> ast::crate_ {
|
||||
let folded = fold::noop_fold_crate(c, fld);
|
||||
|
||||
// Add a special __test module to the crate that will contain code
|
||||
// generated for the test harness
|
||||
ast::crate_ { module: add_test_module(cx, /*bad*/copy folded.module),
|
||||
.. folded }
|
||||
ast::crate_ {
|
||||
module: add_test_module(cx, &folded.module),
|
||||
.. folded
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -238,11 +240,11 @@ fn should_fail(i: @ast::item) -> bool {
|
|||
vec::len(attr::find_attrs_by_name(i.attrs, ~"should_fail")) > 0u
|
||||
}
|
||||
|
||||
fn add_test_module(cx: &TestCtxt, +m: ast::_mod) -> ast::_mod {
|
||||
fn add_test_module(cx: &TestCtxt, m: &ast::_mod) -> ast::_mod {
|
||||
let testmod = mk_test_module(cx);
|
||||
ast::_mod {
|
||||
items: vec::append_one(/*bad*/copy m.items, testmod),
|
||||
.. m
|
||||
.. /*bad*/ copy *m
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -323,7 +323,7 @@ fn encode_path(ecx: @EncodeContext, ebml_w: writer::Encoder,
|
|||
}
|
||||
|
||||
fn encode_info_for_mod(ecx: @EncodeContext, ebml_w: writer::Encoder,
|
||||
md: _mod, id: node_id, path: &[ast_map::path_elt],
|
||||
md: &_mod, id: node_id, path: &[ast_map::path_elt],
|
||||
name: ident) {
|
||||
ebml_w.start_tag(tag_items_data_item);
|
||||
encode_def_id(ebml_w, local_def(id));
|
||||
|
@ -621,7 +621,7 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
|
|||
}
|
||||
ebml_w.end_tag();
|
||||
}
|
||||
item_mod(m) => {
|
||||
item_mod(ref m) => {
|
||||
add_to_index();
|
||||
encode_info_for_mod(ecx, ebml_w, m, item.id, path, item.ident);
|
||||
}
|
||||
|
@ -856,8 +856,8 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
|
|||
// method info, we output static methods with type signatures as
|
||||
// written. Here, we output the *real* type signatures. I feel like
|
||||
// maybe we should only ever handle the real type signatures.
|
||||
for vec::each((*ms)) |m| {
|
||||
let ty_m = ast_util::trait_method_to_ty_method(*m);
|
||||
for ms.each |m| {
|
||||
let ty_m = ast_util::trait_method_to_ty_method(m);
|
||||
if ty_m.self_ty.node != ast::sty_static { loop; }
|
||||
|
||||
index.push(entry { val: ty_m.id, pos: ebml_w.writer.tell() });
|
||||
|
@ -927,7 +927,7 @@ fn encode_info_for_items(ecx: @EncodeContext, ebml_w: writer::Encoder,
|
|||
let index = @mut ~[];
|
||||
ebml_w.start_tag(tag_items_data);
|
||||
index.push(entry { val: crate_node_id, pos: ebml_w.writer.tell() });
|
||||
encode_info_for_mod(ecx, ebml_w, crate.node.module,
|
||||
encode_info_for_mod(ecx, ebml_w, &crate.node.module,
|
||||
crate_node_id, ~[],
|
||||
syntax::parse::token::special_idents::invalid);
|
||||
visit::visit_crate(*crate, (), visit::mk_vt(@visit::Visitor {
|
||||
|
|
|
@ -298,7 +298,7 @@ fn encode_ast(ebml_w: writer::Encoder, item: ast::inlined_item) {
|
|||
// nested items, as otherwise it would get confused when translating
|
||||
// inlined items.
|
||||
fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item {
|
||||
fn drop_nested_items(blk: ast::blk_, fld: fold::ast_fold) -> ast::blk_ {
|
||||
fn drop_nested_items(blk: &ast::blk_, fld: fold::ast_fold) -> ast::blk_ {
|
||||
let stmts_sans_items = do blk.stmts.filtered |stmt| {
|
||||
match stmt.node {
|
||||
ast::stmt_expr(_, _) | ast::stmt_semi(_, _) |
|
||||
|
@ -317,7 +317,7 @@ fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item {
|
|||
id: blk.id,
|
||||
rules: blk.rules
|
||||
};
|
||||
fold::noop_fold_block(blk_sans_items, fld)
|
||||
fold::noop_fold_block(&blk_sans_items, fld)
|
||||
}
|
||||
|
||||
let fld = fold::make_fold(@fold::AstFoldFns {
|
||||
|
@ -336,7 +336,7 @@ fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item {
|
|||
ast::ii_foreign(fld.fold_foreign_item(i))
|
||||
}
|
||||
ast::ii_dtor(ref dtor, nm, ref tps, parent_id) => {
|
||||
let dtor_body = fld.fold_block((*dtor).node.body);
|
||||
let dtor_body = fld.fold_block(&dtor.node.body);
|
||||
ast::ii_dtor(
|
||||
codemap::spanned {
|
||||
node: ast::struct_dtor_ { body: dtor_body,
|
||||
|
@ -372,7 +372,7 @@ fn renumber_ast(xcx: @ExtendedDecodeContext, ii: ast::inlined_item)
|
|||
ast::ii_foreign(fld.fold_foreign_item(i))
|
||||
}
|
||||
ast::ii_dtor(ref dtor, nm, ref tps, parent_id) => {
|
||||
let dtor_body = fld.fold_block((*dtor).node.body);
|
||||
let dtor_body = fld.fold_block(&dtor.node.body);
|
||||
let dtor_attrs = fld.fold_attributes(/*bad*/copy (*dtor).node.attrs);
|
||||
let new_params = fold::fold_ty_params(/*bad*/copy *tps, fld);
|
||||
let dtor_id = fld.new_id((*dtor).node.id);
|
||||
|
|
|
@ -580,8 +580,8 @@ impl CheckLoanCtxt {
|
|||
}
|
||||
|
||||
fn check_loans_in_fn(fk: &visit::fn_kind,
|
||||
decl: ast::fn_decl,
|
||||
body: ast::blk,
|
||||
decl: &ast::fn_decl,
|
||||
body: &ast::blk,
|
||||
sp: span,
|
||||
id: ast::node_id,
|
||||
&&self: @mut CheckLoanCtxt,
|
||||
|
@ -753,7 +753,7 @@ fn check_loans_in_expr(expr: @ast::expr,
|
|||
visit::visit_expr(expr, self, vt);
|
||||
}
|
||||
|
||||
fn check_loans_in_block(blk: ast::blk,
|
||||
fn check_loans_in_block(blk: &ast::blk,
|
||||
&&self: @mut CheckLoanCtxt,
|
||||
vt: visit::vt<@mut CheckLoanCtxt>) {
|
||||
do save_and_restore_managed(self.declared_purity) {
|
||||
|
|
|
@ -96,8 +96,8 @@ pub fn gather_loans(bccx: @BorrowckCtxt, crate: @ast::crate) -> ReqMaps {
|
|||
}
|
||||
|
||||
fn req_loans_in_fn(fk: &visit::fn_kind,
|
||||
decl: ast::fn_decl,
|
||||
body: ast::blk,
|
||||
decl: &ast::fn_decl,
|
||||
body: &ast::blk,
|
||||
sp: span,
|
||||
id: ast::node_id,
|
||||
&&self: @mut GatherLoanCtxt,
|
||||
|
@ -269,13 +269,13 @@ fn req_loans_in_expr(ex: @ast::expr,
|
|||
(vt.visit_expr)(cond, self, vt);
|
||||
|
||||
// during body, can only root for the body
|
||||
self.root_ub = (*body).node.id;
|
||||
(vt.visit_block)((*body), self, vt);
|
||||
self.root_ub = body.node.id;
|
||||
(vt.visit_block)(body, self, vt);
|
||||
}
|
||||
|
||||
// see explanation attached to the `root_ub` field:
|
||||
ast::expr_loop(ref body, _) => {
|
||||
self.root_ub = (*body).node.id;
|
||||
self.root_ub = body.node.id;
|
||||
visit::visit_expr(ex, self, vt);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,10 +33,10 @@ pub fn check_crate(tcx: ty::ctxt, crate: @crate) {
|
|||
match e.node {
|
||||
expr_while(e, ref b) => {
|
||||
(v.visit_expr)(e, cx, v);
|
||||
(v.visit_block)((*b), Context { in_loop: true,.. cx }, v);
|
||||
(v.visit_block)(b, Context { in_loop: true,.. cx }, v);
|
||||
}
|
||||
expr_loop(ref b, _) => {
|
||||
(v.visit_block)((*b), Context { in_loop: true,.. cx }, v);
|
||||
(v.visit_block)(b, Context { in_loop: true,.. cx }, v);
|
||||
}
|
||||
expr_fn(*) => {
|
||||
visit::visit_expr(e, Context {
|
||||
|
@ -45,7 +45,7 @@ pub fn check_crate(tcx: ty::ctxt, crate: @crate) {
|
|||
}, v);
|
||||
}
|
||||
expr_fn_block(_, ref b) => {
|
||||
(v.visit_block)((*b), Context {
|
||||
(v.visit_block)(b, Context {
|
||||
in_loop: false,
|
||||
can_ret: false
|
||||
}, v);
|
||||
|
@ -53,10 +53,10 @@ pub fn check_crate(tcx: ty::ctxt, crate: @crate) {
|
|||
expr_loop_body(@expr {node: expr_fn_block(_, ref b), _}) => {
|
||||
let sigil = ty::ty_closure_sigil(ty::expr_ty(tcx, e));
|
||||
let blk = (sigil == BorrowedSigil);
|
||||
(v.visit_block)((*b), Context {
|
||||
(v.visit_block)(b, Context {
|
||||
in_loop: true,
|
||||
can_ret: blk
|
||||
}, v);
|
||||
}, v);
|
||||
}
|
||||
expr_break(_) => {
|
||||
if !cx.in_loop {
|
||||
|
|
|
@ -670,8 +670,8 @@ pub fn check_local(cx: @MatchCheckCtxt,
|
|||
|
||||
pub fn check_fn(cx: @MatchCheckCtxt,
|
||||
kind: &visit::fn_kind,
|
||||
decl: fn_decl,
|
||||
body: blk,
|
||||
decl: &fn_decl,
|
||||
body: &blk,
|
||||
sp: span,
|
||||
id: node_id,
|
||||
&&s: (),
|
||||
|
|
|
@ -39,7 +39,7 @@ pub type freevar_map = HashMap<ast::node_id, freevar_info>;
|
|||
// Since we want to be able to collect upvars in some arbitrary piece
|
||||
// of the AST, we take a walker function that we invoke with a visitor
|
||||
// in order to start the search.
|
||||
fn collect_freevars(def_map: resolve::DefMap, blk: ast::blk)
|
||||
fn collect_freevars(def_map: resolve::DefMap, blk: &ast::blk)
|
||||
-> freevar_info {
|
||||
let seen = HashMap();
|
||||
let refs = @mut ~[];
|
||||
|
@ -100,8 +100,8 @@ pub fn annotate_freevars(def_map: resolve::DefMap, crate: @ast::crate) ->
|
|||
freevar_map {
|
||||
let freevars = HashMap();
|
||||
|
||||
let walk_fn = fn@(_fk: &visit::fn_kind, _decl: ast::fn_decl,
|
||||
blk: ast::blk, _sp: span, nid: ast::node_id) {
|
||||
let walk_fn = fn@(_fk: &visit::fn_kind, _decl: &ast::fn_decl,
|
||||
blk: &ast::blk, _sp: span, nid: ast::node_id) {
|
||||
let vars = collect_freevars(def_map, blk);
|
||||
freevars.insert(nid, vars);
|
||||
};
|
||||
|
|
|
@ -153,8 +153,14 @@ fn with_appropriate_checker(cx: Context, id: node_id, b: fn(check_fn)) {
|
|||
|
||||
// Check that the free variables used in a shared/sendable closure conform
|
||||
// to the copy/move kind bounds. Then recursively check the function body.
|
||||
fn check_fn(fk: &visit::fn_kind, decl: fn_decl, body: blk, sp: span,
|
||||
fn_id: node_id, cx: Context, v: visit::vt<Context>) {
|
||||
fn check_fn(
|
||||
fk: &visit::fn_kind,
|
||||
decl: &fn_decl,
|
||||
body: &blk,
|
||||
sp: span,
|
||||
fn_id: node_id,
|
||||
cx: Context,
|
||||
v: visit::vt<Context>) {
|
||||
|
||||
// Check kinds on free variables:
|
||||
do with_appropriate_checker(cx, fn_id) |chk| {
|
||||
|
@ -166,7 +172,7 @@ fn check_fn(fk: &visit::fn_kind, decl: fn_decl, body: blk, sp: span,
|
|||
visit::visit_fn(fk, decl, body, sp, fn_id, cx, v);
|
||||
}
|
||||
|
||||
fn check_arm(a: arm, cx: Context, v: visit::vt<Context>) {
|
||||
fn check_arm(a: &arm, cx: Context, v: visit::vt<Context>) {
|
||||
for vec::each(a.pats) |p| {
|
||||
do pat_util::pat_bindings(cx.tcx.def_map, *p) |mode, id, span, _pth| {
|
||||
if mode == bind_by_copy {
|
||||
|
|
|
@ -726,7 +726,7 @@ fn check_item_structural_records(cx: ty::ctxt, it: @ast::item) {
|
|||
fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) {
|
||||
|
||||
fn check_foreign_fn(cx: ty::ctxt, fn_id: ast::node_id,
|
||||
decl: ast::fn_decl) {
|
||||
decl: &ast::fn_decl) {
|
||||
let tys = vec::map(decl.inputs, |a| a.ty );
|
||||
for vec::each(vec::append_one(tys, decl.output)) |ty| {
|
||||
match ty.node {
|
||||
|
@ -760,7 +760,7 @@ fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) {
|
|||
either::Right(ast::foreign_abi_rust_intrinsic) => {
|
||||
for nmod.items.each |ni| {
|
||||
match /*bad*/copy ni.node {
|
||||
ast::foreign_item_fn(decl, _, _) => {
|
||||
ast::foreign_item_fn(ref decl, _, _) => {
|
||||
check_foreign_fn(cx, it.id, decl);
|
||||
}
|
||||
// FIXME #4622: Not implemented.
|
||||
|
@ -923,8 +923,8 @@ fn check_item_non_camel_case_types(cx: ty::ctxt, it: @ast::item) {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_fn(tcx: ty::ctxt, fk: &visit::fn_kind, decl: ast::fn_decl,
|
||||
_body: ast::blk, span: span, id: ast::node_id) {
|
||||
fn check_fn(tcx: ty::ctxt, fk: &visit::fn_kind, decl: &ast::fn_decl,
|
||||
_body: &ast::blk, span: span, id: ast::node_id) {
|
||||
debug!("lint check_fn fk=%? id=%?", fk, id);
|
||||
|
||||
// don't complain about blocks, since they tend to get their modes
|
||||
|
@ -938,7 +938,7 @@ fn check_fn(tcx: ty::ctxt, fk: &visit::fn_kind, decl: ast::fn_decl,
|
|||
check_fn_deprecated_modes(tcx, fn_ty, decl, span, id);
|
||||
}
|
||||
|
||||
fn check_fn_deprecated_modes(tcx: ty::ctxt, fn_ty: ty::t, decl: ast::fn_decl,
|
||||
fn check_fn_deprecated_modes(tcx: ty::ctxt, fn_ty: ty::t, decl: &ast::fn_decl,
|
||||
span: span, id: ast::node_id) {
|
||||
match ty::get(fn_ty).sty {
|
||||
ty::ty_closure(ty::ClosureTy {sig: ref sig, _}) |
|
||||
|
@ -990,7 +990,7 @@ fn check_fn_deprecated_modes(tcx: ty::ctxt, fn_ty: ty::t, decl: ast::fn_decl,
|
|||
ast::ty_closure(@ast::TyClosure{decl: ref d, _}) |
|
||||
ast::ty_bare_fn(@ast::TyBareFn{decl: ref d, _})=>{
|
||||
check_fn_deprecated_modes(tcx, arg_ty.ty,
|
||||
*d, span, id);
|
||||
d, span, id);
|
||||
}
|
||||
ast::ty_path(*) => {
|
||||
// This is probably a typedef, so we can't
|
||||
|
@ -1026,7 +1026,7 @@ fn check_item_deprecated_modes(tcx: ty::ctxt, it: @ast::item) {
|
|||
ast::ty_bare_fn(@ast::TyBareFn {decl: ref decl, _}) => {
|
||||
let fn_ty = ty::node_id_to_type(tcx, it.id);
|
||||
check_fn_deprecated_modes(
|
||||
tcx, fn_ty, *decl, ty.span, it.id)
|
||||
tcx, fn_ty, decl, ty.span, it.id)
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
|
|
|
@ -436,8 +436,8 @@ impl IrMaps {
|
|||
}
|
||||
|
||||
fn visit_fn(fk: &visit::fn_kind,
|
||||
decl: fn_decl,
|
||||
body: blk,
|
||||
decl: &fn_decl,
|
||||
body: &blk,
|
||||
sp: span,
|
||||
id: node_id,
|
||||
&&self: @mut IrMaps,
|
||||
|
@ -540,7 +540,7 @@ fn visit_local(local: @local, &&self: @mut IrMaps, vt: vt<@mut IrMaps>) {
|
|||
visit::visit_local(local, self, vt);
|
||||
}
|
||||
|
||||
fn visit_arm(arm: arm, &&self: @mut IrMaps, vt: vt<@mut IrMaps>) {
|
||||
fn visit_arm(arm: &arm, &&self: @mut IrMaps, vt: vt<@mut IrMaps>) {
|
||||
let def_map = self.tcx.def_map;
|
||||
for arm.pats.each |pat| {
|
||||
do pat_util::pat_bindings(def_map, *pat) |bm, p_id, sp, path| {
|
||||
|
@ -979,7 +979,7 @@ impl Liveness {
|
|||
|
||||
// _______________________________________________________________________
|
||||
|
||||
fn compute(&self, decl: fn_decl, body: blk) -> LiveNode {
|
||||
fn compute(&self, decl: &fn_decl, body: &blk) -> LiveNode {
|
||||
// if there is a `break` or `again` at the top level, then it's
|
||||
// effectively a return---this only occurs in `for` loops,
|
||||
// where the body is really a closure.
|
||||
|
@ -1004,7 +1004,7 @@ impl Liveness {
|
|||
entry_ln
|
||||
}
|
||||
|
||||
fn propagate_through_fn_block(&self, decl: fn_decl, blk: blk)
|
||||
fn propagate_through_fn_block(&self, decl: &fn_decl, blk: &blk)
|
||||
-> LiveNode {
|
||||
// inputs passed by & mode should be considered live on exit:
|
||||
for decl.inputs.each |arg| {
|
||||
|
@ -1038,7 +1038,7 @@ impl Liveness {
|
|||
self.propagate_through_block(blk, self.s.fallthrough_ln)
|
||||
}
|
||||
|
||||
fn propagate_through_block(&self, blk: blk, succ: LiveNode) -> LiveNode {
|
||||
fn propagate_through_block(&self, blk: &blk, succ: LiveNode) -> LiveNode {
|
||||
let succ = self.propagate_through_opt_expr(blk.node.expr, succ);
|
||||
do blk.node.stmts.foldr(succ) |stmt, succ| {
|
||||
self.propagate_through_stmt(*stmt, succ)
|
||||
|
@ -1134,7 +1134,7 @@ impl Liveness {
|
|||
The next-node for a break is the successor of the entire
|
||||
loop. The next-node for a continue is the top of this loop.
|
||||
*/
|
||||
self.with_loop_nodes((*blk).node.id, succ,
|
||||
self.with_loop_nodes(blk.node.id, succ,
|
||||
self.live_node(expr.id, expr.span), || {
|
||||
|
||||
// the construction of a closure itself is not important,
|
||||
|
@ -1164,7 +1164,7 @@ impl Liveness {
|
|||
// ( succ )
|
||||
//
|
||||
let else_ln = self.propagate_through_opt_expr(els, succ);
|
||||
let then_ln = self.propagate_through_block((*then), succ);
|
||||
let then_ln = self.propagate_through_block(then, succ);
|
||||
let ln = self.live_node(expr.id, expr.span);
|
||||
self.init_from_succ(ln, else_ln);
|
||||
self.merge_from_succ(ln, then_ln, false);
|
||||
|
@ -1172,13 +1172,13 @@ impl Liveness {
|
|||
}
|
||||
|
||||
expr_while(cond, ref blk) => {
|
||||
self.propagate_through_loop(expr, Some(cond), (*blk), succ)
|
||||
self.propagate_through_loop(expr, Some(cond), blk, succ)
|
||||
}
|
||||
|
||||
// Note that labels have been resolved, so we don't need to look
|
||||
// at the label ident
|
||||
expr_loop(ref blk, _) => {
|
||||
self.propagate_through_loop(expr, None, (*blk), succ)
|
||||
self.propagate_through_loop(expr, None, blk, succ)
|
||||
}
|
||||
|
||||
expr_match(e, ref arms) => {
|
||||
|
@ -1199,9 +1199,9 @@ impl Liveness {
|
|||
let ln = self.live_node(expr.id, expr.span);
|
||||
self.init_empty(ln, succ);
|
||||
let mut first_merge = true;
|
||||
for (*arms).each |arm| {
|
||||
for arms.each |arm| {
|
||||
let body_succ =
|
||||
self.propagate_through_block(arm.body, succ);
|
||||
self.propagate_through_block(&arm.body, succ);
|
||||
let guard_succ =
|
||||
self.propagate_through_opt_expr(arm.guard, body_succ);
|
||||
let arm_succ =
|
||||
|
@ -1362,7 +1362,7 @@ impl Liveness {
|
|||
}
|
||||
|
||||
expr_block(ref blk) => {
|
||||
self.propagate_through_block((*blk), succ)
|
||||
self.propagate_through_block(blk, succ)
|
||||
}
|
||||
|
||||
expr_mac(*) => {
|
||||
|
@ -1463,7 +1463,7 @@ impl Liveness {
|
|||
|
||||
fn propagate_through_loop(&self, expr: @expr,
|
||||
cond: Option<@expr>,
|
||||
body: blk,
|
||||
body: &blk,
|
||||
succ: LiveNode) -> LiveNode {
|
||||
|
||||
/*
|
||||
|
@ -1568,7 +1568,7 @@ fn check_local(local: @local, &&self: @Liveness, vt: vt<@Liveness>) {
|
|||
visit::visit_local(local, self, vt);
|
||||
}
|
||||
|
||||
fn check_arm(arm: arm, &&self: @Liveness, vt: vt<@Liveness>) {
|
||||
fn check_arm(arm: &arm, &&self: @Liveness, vt: vt<@Liveness>) {
|
||||
do self.arm_pats_bindings(arm.pats) |ln, var, sp| {
|
||||
self.warn_about_unused(sp, ln, var);
|
||||
}
|
||||
|
@ -1639,8 +1639,8 @@ fn check_expr(expr: @expr, &&self: @Liveness, vt: vt<@Liveness>) {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_fn(_fk: &visit::fn_kind, _decl: fn_decl,
|
||||
_body: blk, _sp: span, _id: node_id,
|
||||
fn check_fn(_fk: &visit::fn_kind, _decl: &fn_decl,
|
||||
_body: &blk, _sp: span, _id: node_id,
|
||||
&&_self: @Liveness, _v: vt<@Liveness>) {
|
||||
// do not check contents of nested fns
|
||||
}
|
||||
|
@ -1885,7 +1885,7 @@ impl @Liveness {
|
|||
if name[0] == ('_' as u8) { None } else { Some(name) }
|
||||
}
|
||||
|
||||
fn warn_about_unused_args(&self, decl: fn_decl, entry_ln: LiveNode) {
|
||||
fn warn_about_unused_args(&self, decl: &fn_decl, entry_ln: LiveNode) {
|
||||
for decl.inputs.each |arg| {
|
||||
do pat_util::pat_bindings(self.tcx.def_map, arg.pat)
|
||||
|_bm, p_id, sp, _n| {
|
||||
|
|
|
@ -221,7 +221,7 @@ pub fn record_parent(cx: ctxt, child_id: ast::node_id) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn resolve_block(blk: ast::blk, cx: ctxt, visitor: visit::vt<ctxt>) {
|
||||
pub fn resolve_block(blk: &ast::blk, cx: ctxt, visitor: visit::vt<ctxt>) {
|
||||
// Record the parent of this block.
|
||||
record_parent(cx, blk.node.id);
|
||||
|
||||
|
@ -230,7 +230,7 @@ pub fn resolve_block(blk: ast::blk, cx: ctxt, visitor: visit::vt<ctxt>) {
|
|||
visit::visit_block(blk, new_cx, visitor);
|
||||
}
|
||||
|
||||
pub fn resolve_arm(arm: ast::arm, cx: ctxt, visitor: visit::vt<ctxt>) {
|
||||
pub fn resolve_arm(arm: &ast::arm, cx: ctxt, visitor: visit::vt<ctxt>) {
|
||||
visit::visit_arm(arm, cx, visitor);
|
||||
}
|
||||
|
||||
|
@ -317,8 +317,8 @@ pub fn resolve_item(item: @ast::item, cx: ctxt, visitor: visit::vt<ctxt>) {
|
|||
}
|
||||
|
||||
pub fn resolve_fn(fk: &visit::fn_kind,
|
||||
decl: ast::fn_decl,
|
||||
body: ast::blk,
|
||||
decl: &ast::fn_decl,
|
||||
body: &ast::blk,
|
||||
sp: span,
|
||||
id: ast::node_id,
|
||||
cx: ctxt,
|
||||
|
@ -608,8 +608,8 @@ pub fn determine_rp_in_item(item: @ast::item,
|
|||
}
|
||||
|
||||
pub fn determine_rp_in_fn(fk: &visit::fn_kind,
|
||||
decl: ast::fn_decl,
|
||||
body: ast::blk,
|
||||
decl: &ast::fn_decl,
|
||||
body: &ast::blk,
|
||||
_: span,
|
||||
_: ast::node_id,
|
||||
&&cx: @mut DetermineRpCtxt,
|
||||
|
@ -626,7 +626,7 @@ pub fn determine_rp_in_fn(fk: &visit::fn_kind,
|
|||
}
|
||||
}
|
||||
|
||||
pub fn determine_rp_in_ty_method(ty_m: ast::ty_method,
|
||||
pub fn determine_rp_in_ty_method(ty_m: &ast::ty_method,
|
||||
&&cx: @mut DetermineRpCtxt,
|
||||
visitor: visit::vt<@mut DetermineRpCtxt>) {
|
||||
do cx.with(cx.item_id, false) {
|
||||
|
|
|
@ -1027,7 +1027,7 @@ pub impl Resolver {
|
|||
}
|
||||
}
|
||||
|
||||
fn block_needs_anonymous_module(@mut self, block: blk) -> bool {
|
||||
fn block_needs_anonymous_module(@mut self, block: &blk) -> bool {
|
||||
// If the block has view items, we need an anonymous module.
|
||||
if block.node.view_items.len() > 0 {
|
||||
return true;
|
||||
|
@ -1276,7 +1276,7 @@ pub impl Resolver {
|
|||
// methods, so check that first.
|
||||
let mut has_static_methods = false;
|
||||
for (*methods).each |method| {
|
||||
let ty_m = trait_method_to_ty_method(*method);
|
||||
let ty_m = trait_method_to_ty_method(method);
|
||||
match ty_m.self_ty.node {
|
||||
sty_static => {
|
||||
has_static_methods = true;
|
||||
|
@ -1304,7 +1304,7 @@ pub impl Resolver {
|
|||
// Add the names of all the methods to the trait info.
|
||||
let method_names = @HashMap();
|
||||
for (*methods).each |method| {
|
||||
let ty_m = trait_method_to_ty_method(*method);
|
||||
let ty_m = trait_method_to_ty_method(method);
|
||||
|
||||
let ident = ty_m.ident;
|
||||
// Add it to the trait info if not static,
|
||||
|
@ -1534,7 +1534,7 @@ pub impl Resolver {
|
|||
}
|
||||
|
||||
fn build_reduced_graph_for_block(@mut self,
|
||||
block: blk,
|
||||
block: &blk,
|
||||
parent: ReducedGraphParent,
|
||||
&&visitor: vt<ReducedGraphParent>) {
|
||||
let mut new_parent;
|
||||
|
@ -3788,7 +3788,7 @@ pub impl Resolver {
|
|||
item.id,
|
||||
0,
|
||||
OpaqueFunctionRibKind),
|
||||
(*block),
|
||||
block,
|
||||
NoSelfBinding,
|
||||
visitor);
|
||||
}
|
||||
|
@ -3866,7 +3866,7 @@ pub impl Resolver {
|
|||
rib_kind: RibKind,
|
||||
optional_declaration: Option<@fn_decl>,
|
||||
type_parameters: TypeParameters,
|
||||
block: blk,
|
||||
block: &blk,
|
||||
self_binding: SelfBinding,
|
||||
visitor: ResolveVisitor) {
|
||||
// Create a value rib for the function.
|
||||
|
@ -3982,7 +3982,7 @@ pub impl Resolver {
|
|||
self.resolve_function(NormalRibKind,
|
||||
None,
|
||||
NoTypeParameters,
|
||||
(*destructor).node.body,
|
||||
&destructor.node.body,
|
||||
HasSelfBinding
|
||||
((*destructor).node.self_id,
|
||||
true),
|
||||
|
@ -4015,7 +4015,7 @@ pub impl Resolver {
|
|||
self.resolve_function(rib_kind,
|
||||
Some(@/*bad*/copy method.decl),
|
||||
type_parameters,
|
||||
method.body,
|
||||
&method.body,
|
||||
self_binding,
|
||||
visitor);
|
||||
}
|
||||
|
@ -4140,7 +4140,7 @@ pub impl Resolver {
|
|||
return result;
|
||||
}
|
||||
|
||||
fn check_consistent_bindings(@mut self, arm: arm) {
|
||||
fn check_consistent_bindings(@mut self, arm: &arm) {
|
||||
if arm.pats.len() == 0 { return; }
|
||||
let map_0 = self.binding_mode_map(arm.pats[0]);
|
||||
for arm.pats.eachi() |i, p| {
|
||||
|
@ -4179,7 +4179,7 @@ pub impl Resolver {
|
|||
}
|
||||
}
|
||||
|
||||
fn resolve_arm(@mut self, arm: arm, visitor: ResolveVisitor) {
|
||||
fn resolve_arm(@mut self, arm: &arm, visitor: ResolveVisitor) {
|
||||
(*self.value_ribs).push(@Rib(NormalRibKind));
|
||||
|
||||
let bindings_list = HashMap();
|
||||
|
@ -4193,12 +4193,12 @@ pub impl Resolver {
|
|||
self.check_consistent_bindings(arm);
|
||||
|
||||
visit_expr_opt(arm.guard, (), visitor);
|
||||
self.resolve_block(arm.body, visitor);
|
||||
self.resolve_block(&arm.body, visitor);
|
||||
|
||||
(*self.value_ribs).pop();
|
||||
}
|
||||
|
||||
fn resolve_block(@mut self, block: blk, visitor: ResolveVisitor) {
|
||||
fn resolve_block(@mut self, block: &blk, visitor: ResolveVisitor) {
|
||||
debug!("(resolving block) entering block");
|
||||
(*self.value_ribs).push(@Rib(NormalRibKind));
|
||||
|
||||
|
@ -4910,7 +4910,7 @@ pub impl Resolver {
|
|||
self.resolve_function(FunctionRibKind(expr.id, block.node.id),
|
||||
Some(@/*bad*/copy *fn_decl),
|
||||
NoTypeParameters,
|
||||
(*block),
|
||||
block,
|
||||
NoSelfBinding,
|
||||
visitor);
|
||||
}
|
||||
|
|
|
@ -2093,7 +2093,7 @@ pub fn trans_item(ccx: @CrateContext, item: ast::item) {
|
|||
vec::append(/*bad*/copy *path, ~[path_name(item.ident)]),
|
||||
decl, body, llfndecl, no_self, None, item.id, None);
|
||||
} else {
|
||||
for vec::each((*body).node.stmts) |stmt| {
|
||||
for body.node.stmts.each |stmt| {
|
||||
match stmt.node {
|
||||
ast::stmt_decl(@codemap::spanned { node: ast::decl_item(i),
|
||||
_ }, _) => {
|
||||
|
@ -2108,7 +2108,7 @@ pub fn trans_item(ccx: @CrateContext, item: ast::item) {
|
|||
meth::trans_impl(ccx, /*bad*/copy *path, item.ident, ms, tps, None,
|
||||
item.id);
|
||||
}
|
||||
ast::item_mod(m) => {
|
||||
ast::item_mod(ref m) => {
|
||||
trans_mod(ccx, m);
|
||||
}
|
||||
ast::item_enum(ref enum_definition, ref tps) => {
|
||||
|
@ -2121,11 +2121,10 @@ pub fn trans_item(ccx: @CrateContext, item: ast::item) {
|
|||
}
|
||||
}
|
||||
ast::item_const(_, expr) => consts::trans_const(ccx, expr, item.id),
|
||||
ast::item_foreign_mod(foreign_mod) => {
|
||||
ast::item_foreign_mod(ref foreign_mod) => {
|
||||
let abi = match attr::foreign_abi(item.attrs) {
|
||||
either::Right(abi_) => abi_,
|
||||
either::Left(ref msg) => ccx.sess.span_fatal(item.span,
|
||||
/*bad*/copy *msg)
|
||||
Right(abi_) => abi_,
|
||||
Left(ref msg) => ccx.sess.span_fatal(item.span, /*bad*/copy *msg)
|
||||
};
|
||||
foreign::trans_foreign_mod(ccx, foreign_mod, abi);
|
||||
}
|
||||
|
@ -2165,9 +2164,9 @@ pub fn trans_struct_def(ccx: @CrateContext, struct_def: @ast::struct_def,
|
|||
// separate modules in the compiled program. That's because modules exist
|
||||
// only as a convenience for humans working with the code, to organize names
|
||||
// and control visibility.
|
||||
pub fn trans_mod(ccx: @CrateContext, m: ast::_mod) {
|
||||
pub fn trans_mod(ccx: @CrateContext, m: &ast::_mod) {
|
||||
let _icx = ccx.insn_ctxt("trans_mod");
|
||||
for vec::each(m.items) |item| {
|
||||
for m.items.each |item| {
|
||||
trans_item(ccx, **item);
|
||||
}
|
||||
}
|
||||
|
@ -3130,7 +3129,7 @@ pub fn trans_crate(sess: session::Session,
|
|||
|
||||
{
|
||||
let _icx = ccx.insn_ctxt("text");
|
||||
trans_mod(ccx, crate.node.module);
|
||||
trans_mod(ccx, &crate.node.module);
|
||||
}
|
||||
|
||||
decl_gc_metadata(ccx, llmod_id);
|
||||
|
|
|
@ -390,7 +390,7 @@ pub fn trans_rtcall_or_lang_call_with_type_params(bcx: block,
|
|||
ArgVals(args), dest, DontAutorefArg);
|
||||
}
|
||||
|
||||
pub fn body_contains_ret(body: ast::blk) -> bool {
|
||||
pub fn body_contains_ret(body: &ast::blk) -> bool {
|
||||
let cx = @mut false;
|
||||
visit::visit_block(body, cx, visit::mk_vt(@visit::Visitor {
|
||||
visit_item: |_i, _cx, _v| { },
|
||||
|
@ -424,7 +424,7 @@ pub fn trans_call_inner(
|
|||
ast::expr_loop_body(@ast::expr {
|
||||
node: ast::expr_fn_block(_, ref body),
|
||||
_
|
||||
}) => body_contains_ret((*body)),
|
||||
}) => body_contains_ret(body),
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -202,7 +202,7 @@ fn build_wrap_fn_(ccx: @CrateContext,
|
|||
// function itself is unnecessary). We used to do this, in fact, and will
|
||||
// perhaps do so in the future.
|
||||
pub fn trans_foreign_mod(ccx: @CrateContext,
|
||||
foreign_mod: ast::foreign_mod,
|
||||
foreign_mod: &ast::foreign_mod,
|
||||
abi: ast::foreign_abi) {
|
||||
|
||||
let _icx = ccx.insn_ctxt("foreign::trans_foreign_mod");
|
||||
|
|
|
@ -310,7 +310,7 @@ pub fn trans_static_method_callee(bcx: block,
|
|||
let mname = if method_id.crate == ast::local_crate {
|
||||
match bcx.tcx().items.get(&method_id.node) {
|
||||
ast_map::node_trait_method(trait_method, _, _) => {
|
||||
ast_util::trait_method_to_ty_method(*trait_method).ident
|
||||
ast_util::trait_method_to_ty_method(trait_method).ident
|
||||
}
|
||||
_ => fail!(~"callee is not a trait method")
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ fn traverse_public_item(cx: ctx, item: @item) {
|
|||
item_fn(_, _, ref tps, ref blk) => {
|
||||
if tps.len() > 0u ||
|
||||
attr::find_inline_attr(item.attrs) != attr::ia_none {
|
||||
traverse_inline_body(cx, (*blk));
|
||||
traverse_inline_body(cx, blk);
|
||||
}
|
||||
}
|
||||
item_impl(tps, _, _, ms) => {
|
||||
|
@ -117,7 +117,7 @@ fn traverse_public_item(cx: ctx, item: @item) {
|
|||
if tps.len() > 0u || m.tps.len() > 0u ||
|
||||
attr::find_inline_attr(m.attrs) != attr::ia_none {
|
||||
cx.rmap.insert(m.id, ());
|
||||
traverse_inline_body(cx, m.body);
|
||||
traverse_inline_body(cx, &m.body);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ fn traverse_public_item(cx: ctx, item: @item) {
|
|||
cx.rmap.insert(dtor.node.id, ());
|
||||
if tps.len() > 0u || attr::find_inline_attr(dtor.node.attrs)
|
||||
!= attr::ia_none {
|
||||
traverse_inline_body(cx, dtor.node.body);
|
||||
traverse_inline_body(cx, &dtor.node.body);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ fn traverse_ty(ty: @Ty, cx: ctx, v: visit::vt<ctx>) {
|
|||
}
|
||||
}
|
||||
|
||||
fn traverse_inline_body(cx: ctx, body: blk) {
|
||||
fn traverse_inline_body(cx: ctx, body: &blk) {
|
||||
fn traverse_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
|
||||
match e.node {
|
||||
expr_path(_) => {
|
||||
|
@ -217,7 +217,7 @@ fn traverse_inline_body(cx: ctx, body: blk) {
|
|||
fn traverse_item(i: @item, cx: ctx, _v: visit::vt<ctx>) {
|
||||
traverse_public_item(cx, i);
|
||||
}
|
||||
visit::visit_block(body, cx, visit::mk_vt(@visit::Visitor {
|
||||
visit::visit_block(body, cx, visit::mk_vt(@visit::Visitor {
|
||||
visit_expr: traverse_expr,
|
||||
visit_item: traverse_item,
|
||||
..*visit::default_visitor()
|
||||
|
|
|
@ -103,7 +103,7 @@ pub fn type_uses_for(ccx: @CrateContext, fn_id: def_id, n_tps: uint)
|
|||
ast_map::node_item(@ast::item { node: item_fn(_, _, _, ref body),
|
||||
_ }, _) |
|
||||
ast_map::node_method(@ast::method {body: ref body, _}, _, _) => {
|
||||
handle_body(cx, (*body));
|
||||
handle_body(cx, body);
|
||||
}
|
||||
ast_map::node_trait_method(*) => {
|
||||
// This will be a static trait method. For now, we just assume
|
||||
|
@ -159,8 +159,8 @@ pub fn type_uses_for(ccx: @CrateContext, fn_id: def_id, n_tps: uint)
|
|||
for uint::range(0u, n_tps) |n| { cx.uses[n] |= flags;}
|
||||
}
|
||||
}
|
||||
ast_map::node_dtor(_, dtor, _, _) => {
|
||||
handle_body(cx, dtor.node.body);
|
||||
ast_map::node_dtor(_, ref dtor, _, _) => {
|
||||
handle_body(cx, &dtor.node.body);
|
||||
}
|
||||
ast_map::node_struct_ctor(*) => {
|
||||
// Similarly to node_variant, this monomorphized function just uses
|
||||
|
@ -359,7 +359,7 @@ pub fn mark_for_expr(cx: Context, e: @expr) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn handle_body(cx: Context, body: blk) {
|
||||
pub fn handle_body(cx: Context, body: &blk) {
|
||||
let v = visit::mk_vt(@visit::Visitor {
|
||||
visit_expr: |e, cx, v| {
|
||||
visit::visit_expr(e, cx, v);
|
||||
|
|
|
@ -3850,7 +3850,7 @@ pub fn item_path(cx: ctxt, id: ast::def_id) -> ast_map::path {
|
|||
ast_map::path_name(method.ident))
|
||||
}
|
||||
ast_map::node_trait_method(trait_method, _, path) => {
|
||||
let method = ast_util::trait_method_to_ty_method(*trait_method);
|
||||
let method = ast_util::trait_method_to_ty_method(&*trait_method);
|
||||
vec::append_one(/*bad*/copy *path,
|
||||
ast_map::path_name(method.ident))
|
||||
}
|
||||
|
|
|
@ -332,14 +332,14 @@ pub fn ast_ty_to_ty<AC:AstConv,RS:region_scope + Copy + Durable>(
|
|||
};
|
||||
ty::mk_rec(tcx, flds)
|
||||
}
|
||||
ast::ty_bare_fn(bf) => {
|
||||
ast::ty_bare_fn(ref bf) => {
|
||||
ty::mk_bare_fn(tcx, ty_of_bare_fn(self, rscope, bf.purity,
|
||||
bf.abi, bf.decl))
|
||||
bf.abi, &bf.decl))
|
||||
}
|
||||
ast::ty_closure(f) => {
|
||||
ast::ty_closure(ref f) => {
|
||||
let fn_decl = ty_of_closure(self, rscope, f.sigil,
|
||||
f.purity, f.onceness,
|
||||
f.region, f.decl, None,
|
||||
f.region, &f.decl, None,
|
||||
ast_ty.span);
|
||||
ty::mk_closure(tcx, fn_decl)
|
||||
}
|
||||
|
@ -473,7 +473,7 @@ pub fn ty_of_bare_fn<AC:AstConv,RS:region_scope + Copy + Durable>(
|
|||
rscope: RS,
|
||||
purity: ast::purity,
|
||||
abi: ast::Abi,
|
||||
decl: ast::fn_decl)
|
||||
decl: &ast::fn_decl)
|
||||
-> ty::BareFnTy {
|
||||
debug!("ty_of_fn_decl");
|
||||
|
||||
|
@ -501,7 +501,7 @@ pub fn ty_of_closure<AC:AstConv,RS:region_scope + Copy + Durable>(
|
|||
purity: ast::purity,
|
||||
onceness: ast::Onceness,
|
||||
opt_region: Option<@ast::region>,
|
||||
decl: ast::fn_decl,
|
||||
decl: &ast::fn_decl,
|
||||
expected_tys: Option<ty::FnSig>,
|
||||
span: span)
|
||||
-> ty::ClosureTy {
|
||||
|
|
|
@ -58,7 +58,7 @@ pub fn check_match(fcx: @mut FnCtxt,
|
|||
Some(e) => { check_expr_has_type(fcx, e, ty::mk_bool(tcx)); },
|
||||
None => ()
|
||||
}
|
||||
if !check_block(fcx, arm.body) { arm_non_bot = true; }
|
||||
if !check_block(fcx, &arm.body) { arm_non_bot = true; }
|
||||
let bty = fcx.node_ty(arm.body.node.id);
|
||||
demand::suptype(fcx, arm.body.span, result_ty, bty);
|
||||
}
|
||||
|
|
|
@ -244,7 +244,7 @@ pub fn check_item_types(ccx: @mut CrateCtxt, crate: @ast::crate) {
|
|||
|
||||
pub fn check_bare_fn(ccx: @mut CrateCtxt,
|
||||
decl: &ast::fn_decl,
|
||||
body: ast::blk,
|
||||
body: &ast::blk,
|
||||
id: ast::node_id,
|
||||
self_info: Option<SelfInfo>) {
|
||||
let fty = ty::node_id_to_type(ccx.tcx, id);
|
||||
|
@ -264,7 +264,7 @@ pub fn check_fn(ccx: @mut CrateCtxt,
|
|||
sigil: Option<ast::Sigil>,
|
||||
fn_sig: &ty::FnSig,
|
||||
decl: &ast::fn_decl,
|
||||
body: ast::blk,
|
||||
body: &ast::blk,
|
||||
fn_kind: FnKind,
|
||||
old_fcx: Option<@mut FnCtxt>) {
|
||||
let tcx = ccx.tcx;
|
||||
|
@ -381,7 +381,7 @@ pub fn check_fn(ccx: @mut CrateCtxt,
|
|||
|
||||
fn gather_locals(fcx: @mut FnCtxt,
|
||||
decl: &ast::fn_decl,
|
||||
body: ast::blk,
|
||||
body: &ast::blk,
|
||||
arg_tys: &[ty::t],
|
||||
self_info: Option<SelfInfo>) {
|
||||
let tcx = fcx.ccx.tcx;
|
||||
|
@ -459,7 +459,7 @@ pub fn check_fn(ccx: @mut CrateCtxt,
|
|||
visit::visit_pat(p, e, v);
|
||||
};
|
||||
|
||||
let visit_block = fn@(b: ast::blk, &&e: (), v: visit::vt<()>) {
|
||||
let visit_block = fn@(b: &ast::blk, &&e: (), v: visit::vt<()>) {
|
||||
// non-obvious: the `blk` variable maps to region lb, so
|
||||
// we have to keep this up-to-date. This
|
||||
// is... unfortunate. It'd be nice to not need this.
|
||||
|
@ -469,8 +469,8 @@ pub fn check_fn(ccx: @mut CrateCtxt,
|
|||
};
|
||||
|
||||
// Don't descend into fns and items
|
||||
fn visit_fn(_fk: &visit::fn_kind, _decl: ast::fn_decl,
|
||||
_body: ast::blk, _sp: span,
|
||||
fn visit_fn(_fk: &visit::fn_kind, _decl: &ast::fn_decl,
|
||||
_body: &ast::blk, _sp: span,
|
||||
_id: ast::node_id, &&_t: (), _v: visit::vt<()>) {
|
||||
}
|
||||
fn visit_item(_i: @ast::item, &&_e: (), _v: visit::vt<()>) { }
|
||||
|
@ -497,7 +497,13 @@ pub fn check_method(ccx: @mut CrateCtxt,
|
|||
def_id: self_impl_def_id,
|
||||
explicit_self: method.self_ty
|
||||
};
|
||||
check_bare_fn(ccx, &method.decl, method.body, method.id, Some(self_info));
|
||||
check_bare_fn(
|
||||
ccx,
|
||||
&method.decl,
|
||||
&method.body,
|
||||
method.id,
|
||||
Some(self_info)
|
||||
);
|
||||
}
|
||||
|
||||
pub fn check_no_duplicate_fields(tcx: ty::ctxt,
|
||||
|
@ -541,9 +547,13 @@ pub fn check_struct(ccx: @mut CrateCtxt,
|
|||
};
|
||||
// typecheck the dtor
|
||||
let dtor_dec = ast_util::dtor_dec();
|
||||
check_bare_fn(ccx, &dtor_dec,
|
||||
dtor.node.body, dtor.node.id,
|
||||
Some(class_t));
|
||||
check_bare_fn(
|
||||
ccx,
|
||||
&dtor_dec,
|
||||
&dtor.node.body,
|
||||
dtor.node.id,
|
||||
Some(class_t)
|
||||
);
|
||||
};
|
||||
|
||||
// Check that the class is instantiable
|
||||
|
@ -565,7 +575,7 @@ pub fn check_item(ccx: @mut CrateCtxt, it: @ast::item) {
|
|||
it.id);
|
||||
}
|
||||
ast::item_fn(ref decl, _, _, ref body) => {
|
||||
check_bare_fn(ccx, decl, (*body), it.id, None);
|
||||
check_bare_fn(ccx, decl, body, it.id, None);
|
||||
}
|
||||
ast::item_impl(_, _, ty, ms) => {
|
||||
let rp = ccx.tcx.region_paramd_items.find(&it.id);
|
||||
|
@ -1397,7 +1407,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
|
|||
fn check_for(fcx: @mut FnCtxt,
|
||||
local: @ast::local,
|
||||
element_ty: ty::t,
|
||||
body: ast::blk,
|
||||
body: &ast::blk,
|
||||
node_id: ast::node_id)
|
||||
-> bool {
|
||||
let local_ty = fcx.local_ty(local.span, local.node.id);
|
||||
|
@ -1411,7 +1421,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
|
|||
// A generic function for checking the then and else in an if
|
||||
// or if-check
|
||||
fn check_then_else(fcx: @mut FnCtxt,
|
||||
thn: ast::blk,
|
||||
thn: &ast::blk,
|
||||
elsopt: Option<@ast::expr>,
|
||||
id: ast::node_id,
|
||||
_sp: span)
|
||||
|
@ -1609,7 +1619,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
|
|||
expr: @ast::expr,
|
||||
ast_sigil_opt: Option<ast::Sigil>,
|
||||
decl: &ast::fn_decl,
|
||||
body: ast::blk,
|
||||
body: &ast::blk,
|
||||
fn_kind: FnKind,
|
||||
expected: Option<ty::t>) {
|
||||
let tcx = fcx.ccx.tcx;
|
||||
|
@ -1653,7 +1663,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
|
|||
let mut fn_ty = astconv::ty_of_closure(
|
||||
fcx, fcx,
|
||||
sigil, purity, expected_onceness,
|
||||
None, *decl, expected_tys, expr.span);
|
||||
None, decl, expected_tys, expr.span);
|
||||
|
||||
let fty = ty::mk_closure(tcx, copy fn_ty);
|
||||
|
||||
|
@ -2094,7 +2104,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
|
|||
// message because of the indirect_ret_ty.
|
||||
let fn_kind = if err_happened {Vanilla} else {ForLoop};
|
||||
check_expr_fn(fcx, loop_body, None,
|
||||
decl, *body, fn_kind, Some(inner_ty));
|
||||
decl, body, fn_kind, Some(inner_ty));
|
||||
demand::suptype(fcx, loop_body.span,
|
||||
inner_ty, fcx.expr_ty(loop_body));
|
||||
}
|
||||
|
@ -2341,28 +2351,28 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
|
|||
}
|
||||
ast::expr_if(cond, ref thn, elsopt) => {
|
||||
bot = check_expr_has_type(fcx, cond, ty::mk_bool(tcx));
|
||||
bot |= check_then_else(fcx, *thn, elsopt, id, expr.span);
|
||||
bot |= check_then_else(fcx, thn, elsopt, id, expr.span);
|
||||
}
|
||||
ast::expr_while(cond, ref body) => {
|
||||
bot = check_expr_has_type(fcx, cond, ty::mk_bool(tcx));
|
||||
check_block_no_value(fcx, (*body));
|
||||
check_block_no_value(fcx, body);
|
||||
fcx.write_ty(id, ty::mk_nil(tcx));
|
||||
}
|
||||
ast::expr_loop(ref body, _) => {
|
||||
check_block_no_value(fcx, (*body));
|
||||
check_block_no_value(fcx, body);
|
||||
fcx.write_ty(id, ty::mk_nil(tcx));
|
||||
bot = !may_break(tcx, expr.id, (*body));
|
||||
bot = !may_break(tcx, expr.id, body);
|
||||
}
|
||||
ast::expr_match(discrim, ref arms) => {
|
||||
bot = _match::check_match(fcx, expr, discrim, (/*bad*/copy *arms));
|
||||
}
|
||||
ast::expr_fn(sigil, ref decl, ref body, _) => {
|
||||
check_expr_fn(fcx, expr, Some(sigil),
|
||||
decl, (*body), Vanilla, expected);
|
||||
decl, body, Vanilla, expected);
|
||||
}
|
||||
ast::expr_fn_block(ref decl, ref body) => {
|
||||
check_expr_fn(fcx, expr, None,
|
||||
decl, (*body), Vanilla, expected);
|
||||
decl, body, Vanilla, expected);
|
||||
}
|
||||
ast::expr_loop_body(loop_body) => {
|
||||
check_loop_body(fcx, expr, expected, loop_body);
|
||||
|
@ -2392,7 +2402,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
|
|||
match b.node {
|
||||
ast::expr_fn_block(ref decl, ref body) => {
|
||||
check_expr_fn(fcx, b, None,
|
||||
decl, *body, DoBlock, Some(inner_ty));
|
||||
decl, body, DoBlock, Some(inner_ty));
|
||||
demand::suptype(fcx, b.span, inner_ty, fcx.expr_ty(b));
|
||||
}
|
||||
// argh
|
||||
|
@ -2402,7 +2412,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
|
|||
}
|
||||
ast::expr_block(ref b) => {
|
||||
// If this is an unchecked block, turn off purity-checking
|
||||
bot = check_block_with_expected(fcx, *b, expected);
|
||||
bot = check_block_with_expected(fcx, b, expected);
|
||||
let typ =
|
||||
match b.node.expr {
|
||||
Some(expr) => fcx.expr_ty(expr),
|
||||
|
@ -2692,7 +2702,7 @@ pub fn check_stmt(fcx: @mut FnCtxt, stmt: @ast::stmt) -> bool {
|
|||
return bot;
|
||||
}
|
||||
|
||||
pub fn check_block_no_value(fcx: @mut FnCtxt, blk: ast::blk) -> bool {
|
||||
pub fn check_block_no_value(fcx: @mut FnCtxt, blk: &ast::blk) -> bool {
|
||||
let bot = check_block(fcx, blk);
|
||||
if !bot {
|
||||
let blkty = fcx.node_ty(blk.node.id);
|
||||
|
@ -2702,12 +2712,12 @@ pub fn check_block_no_value(fcx: @mut FnCtxt, blk: ast::blk) -> bool {
|
|||
return bot;
|
||||
}
|
||||
|
||||
pub fn check_block(fcx0: @mut FnCtxt, blk: ast::blk) -> bool {
|
||||
pub fn check_block(fcx0: @mut FnCtxt, blk: &ast::blk) -> bool {
|
||||
check_block_with_expected(fcx0, blk, None)
|
||||
}
|
||||
|
||||
pub fn check_block_with_expected(fcx0: @mut FnCtxt,
|
||||
blk: ast::blk,
|
||||
blk: &ast::blk,
|
||||
expected: Option<ty::t>)
|
||||
-> bool {
|
||||
let fcx = match blk.node.rules {
|
||||
|
@ -3102,7 +3112,7 @@ pub fn ast_expr_vstore_to_vstore(fcx: @mut FnCtxt,
|
|||
}
|
||||
|
||||
// Returns true if b contains a break that can exit from b
|
||||
pub fn may_break(cx: ty::ctxt, id: ast::node_id, b: ast::blk) -> bool {
|
||||
pub fn may_break(cx: ty::ctxt, id: ast::node_id, b: &ast::blk) -> bool {
|
||||
// First: is there an unlabeled break immediately
|
||||
// inside the loop?
|
||||
(loop_query(b, |e| {
|
||||
|
|
|
@ -125,7 +125,7 @@ pub fn regionck_expr(fcx: @mut FnCtxt, e: @ast::expr) {
|
|||
fcx.infcx().resolve_regions();
|
||||
}
|
||||
|
||||
pub fn regionck_fn(fcx: @mut FnCtxt, blk: ast::blk) {
|
||||
pub fn regionck_fn(fcx: @mut FnCtxt, blk: &ast::blk) {
|
||||
let rcx = @mut Rcx { fcx: fcx, errors_reported: 0 };
|
||||
let v = regionck_visitor();
|
||||
(v.visit_block)(blk, rcx, v);
|
||||
|
@ -176,7 +176,7 @@ pub fn visit_local(l: @ast::local, &&rcx: @mut Rcx, v: rvt) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn visit_block(b: ast::blk, &&rcx: @mut Rcx, v: rvt) {
|
||||
pub fn visit_block(b: &ast::blk, &&rcx: @mut Rcx, v: rvt) {
|
||||
visit::visit_block(b, rcx, v);
|
||||
}
|
||||
|
||||
|
|
|
@ -731,7 +731,7 @@ pub fn resolve_expr(ex: @ast::expr,
|
|||
|
||||
// Detect points where a trait-bounded type parameter is
|
||||
// instantiated, resolve the impls for the parameters.
|
||||
pub fn resolve_in_block(fcx: @mut FnCtxt, bl: ast::blk) {
|
||||
pub fn resolve_in_block(fcx: @mut FnCtxt, bl: &ast::blk) {
|
||||
visit::visit_block(bl, fcx, visit::mk_vt(@visit::Visitor {
|
||||
visit_expr: resolve_expr,
|
||||
visit_item: |_,_,_| {},
|
||||
|
|
|
@ -200,7 +200,7 @@ fn visit_expr(e: @ast::expr, &&wbcx: @mut WbCtxt, v: wb_vt) {
|
|||
}
|
||||
visit::visit_expr(e, wbcx, v);
|
||||
}
|
||||
fn visit_block(b: ast::blk, &&wbcx: @mut WbCtxt, v: wb_vt) {
|
||||
fn visit_block(b: &ast::blk, &&wbcx: @mut WbCtxt, v: wb_vt) {
|
||||
if !wbcx.success { return; }
|
||||
resolve_type_vars_for_node(wbcx, b.span, b.node.id);
|
||||
visit::visit_block(b, wbcx, v);
|
||||
|
@ -260,7 +260,7 @@ pub fn resolve_type_vars_in_expr(fcx: @mut FnCtxt, e: @ast::expr) -> bool {
|
|||
|
||||
pub fn resolve_type_vars_in_fn(fcx: @mut FnCtxt,
|
||||
decl: &ast::fn_decl,
|
||||
blk: ast::blk,
|
||||
blk: &ast::blk,
|
||||
self_info: Option<SelfInfo>) -> bool {
|
||||
let wbcx = @mut WbCtxt { fcx: fcx, success: true };
|
||||
let visit = mk_visitor();
|
||||
|
|
|
@ -228,7 +228,7 @@ pub fn ensure_trait_methods(ccx: @mut CrateCtxt,
|
|||
}
|
||||
|
||||
fn make_static_method_ty(ccx: @mut CrateCtxt,
|
||||
am: ast::ty_method,
|
||||
am: &ast::ty_method,
|
||||
rp: Option<ty::region_variance>,
|
||||
m: ty::method,
|
||||
// Take this as an argument b/c we may check
|
||||
|
@ -289,10 +289,11 @@ pub fn ensure_trait_methods(ccx: @mut CrateCtxt,
|
|||
}
|
||||
|
||||
let trait_bounds = ty_param_bounds(ccx, *params);
|
||||
let ty_m = trait_method_to_ty_method(*m);
|
||||
let method_ty = ty_of_ty_method(ccx, ty_m, region_paramd, def_id);
|
||||
let ty_m = trait_method_to_ty_method(m);
|
||||
let method_ty = ty_of_ty_method(ccx, &ty_m, region_paramd,
|
||||
def_id);
|
||||
if ty_m.self_ty.node == ast::sty_static {
|
||||
make_static_method_ty(ccx, ty_m, region_paramd,
|
||||
make_static_method_ty(ccx, &ty_m, region_paramd,
|
||||
method_ty, trait_ty,
|
||||
trait_bounds);
|
||||
}
|
||||
|
@ -689,7 +690,7 @@ pub fn convert_struct(ccx: @mut CrateCtxt,
|
|||
astconv::ty_of_bare_fn(
|
||||
ccx, type_rscope(rp),
|
||||
ast::impure_fn, ast::RustAbi,
|
||||
ast_util::dtor_dec()));
|
||||
&ast_util::dtor_dec()));
|
||||
write_ty_to_tcx(tcx, dtor.node.id, t_dtor);
|
||||
tcx.tcache.insert(local_def(dtor.node.id),
|
||||
ty_param_bounds_and_ty {
|
||||
|
@ -748,7 +749,7 @@ pub fn ty_of_method(ccx: @mut CrateCtxt,
|
|||
ident: m.ident,
|
||||
tps: ty_param_bounds(ccx, m.tps),
|
||||
fty: astconv::ty_of_bare_fn(ccx, type_rscope(rp), m.purity,
|
||||
ast::RustAbi, m.decl),
|
||||
ast::RustAbi, &m.decl),
|
||||
self_ty: m.self_ty.node,
|
||||
vis: m.vis,
|
||||
def_id: local_def(m.id)
|
||||
|
@ -756,14 +757,14 @@ pub fn ty_of_method(ccx: @mut CrateCtxt,
|
|||
}
|
||||
|
||||
pub fn ty_of_ty_method(self: @mut CrateCtxt,
|
||||
m: ast::ty_method,
|
||||
m: &ast::ty_method,
|
||||
rp: Option<ty::region_variance>,
|
||||
id: ast::def_id) -> ty::method {
|
||||
ty::method {
|
||||
ident: m.ident,
|
||||
tps: ty_param_bounds(self, m.tps),
|
||||
fty: astconv::ty_of_bare_fn(self, type_rscope(rp), m.purity,
|
||||
ast::RustAbi, m.decl),
|
||||
ast::RustAbi, &m.decl),
|
||||
// assume public, because this is only invoked on trait methods
|
||||
self_ty: m.self_ty.node,
|
||||
vis: ast::public,
|
||||
|
@ -819,7 +820,7 @@ pub fn ty_of_item(ccx: @mut CrateCtxt, it: @ast::item)
|
|||
ast::item_fn(decl, purity, tps, _) => {
|
||||
let bounds = ty_param_bounds(ccx, tps);
|
||||
let tofd = astconv::ty_of_bare_fn(ccx, empty_rscope, purity,
|
||||
ast::RustAbi, decl);
|
||||
ast::RustAbi, &decl);
|
||||
let tpt = ty_param_bounds_and_ty {
|
||||
bounds: bounds,
|
||||
region_param: None,
|
||||
|
@ -903,17 +904,17 @@ pub fn ty_of_item(ccx: @mut CrateCtxt, it: @ast::item)
|
|||
pub fn ty_of_foreign_item(ccx: @mut CrateCtxt, it: @ast::foreign_item)
|
||||
-> ty::ty_param_bounds_and_ty {
|
||||
match /*bad*/copy it.node {
|
||||
ast::foreign_item_fn(fn_decl, _, params) => {
|
||||
return ty_of_foreign_fn_decl(ccx, fn_decl, params, local_def(it.id));
|
||||
}
|
||||
ast::foreign_item_const(t) => {
|
||||
let rb = in_binding_rscope(empty_rscope);
|
||||
return ty::ty_param_bounds_and_ty {
|
||||
bounds: @~[],
|
||||
region_param: None,
|
||||
ty: ast_ty_to_ty(ccx, rb, t)
|
||||
};
|
||||
}
|
||||
ast::foreign_item_fn(ref fn_decl, _, ref params) => {
|
||||
ty_of_foreign_fn_decl(ccx, fn_decl, *params, local_def(it.id))
|
||||
}
|
||||
ast::foreign_item_const(t) => {
|
||||
let rb = in_binding_rscope(empty_rscope);
|
||||
ty::ty_param_bounds_and_ty {
|
||||
bounds: @~[],
|
||||
region_param: None,
|
||||
ty: ast_ty_to_ty(ccx, rb, t)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -958,7 +959,7 @@ pub fn compute_bounds(ccx: @mut CrateCtxt,
|
|||
}
|
||||
|
||||
pub fn ty_param_bounds(ccx: @mut CrateCtxt,
|
||||
params: ~[ast::ty_param])
|
||||
params: &[ast::ty_param])
|
||||
-> @~[ty::param_bounds] {
|
||||
@do params.map |param| {
|
||||
match ccx.tcx.ty_param_bounds.find(¶m.id) {
|
||||
|
@ -973,8 +974,8 @@ pub fn ty_param_bounds(ccx: @mut CrateCtxt,
|
|||
}
|
||||
|
||||
pub fn ty_of_foreign_fn_decl(ccx: @mut CrateCtxt,
|
||||
decl: ast::fn_decl,
|
||||
+ty_params: ~[ast::ty_param],
|
||||
decl: &ast::fn_decl,
|
||||
ty_params: &[ast::ty_param],
|
||||
def_id: ast::def_id)
|
||||
-> ty::ty_param_bounds_and_ty {
|
||||
let bounds = ty_param_bounds(ccx, ty_params);
|
||||
|
|
|
@ -56,7 +56,7 @@ pub fn field_exprs(fields: ~[ast::field]) -> ~[@ast::expr] {
|
|||
|
||||
// Takes a predicate p, returns true iff p is true for any subexpressions
|
||||
// of b -- skipping any inner loops (loop, while, loop_body)
|
||||
pub fn loop_query(b: ast::blk, p: fn@(ast::expr_) -> bool) -> bool {
|
||||
pub fn loop_query(b: &ast::blk, p: fn@(ast::expr_) -> bool) -> bool {
|
||||
let rs = @mut false;
|
||||
let visit_expr: @fn(@ast::expr,
|
||||
&&flag: @mut bool,
|
||||
|
@ -79,7 +79,7 @@ pub fn loop_query(b: ast::blk, p: fn@(ast::expr_) -> bool) -> bool {
|
|||
|
||||
// Takes a predicate p, returns true iff p is true for any subexpressions
|
||||
// of b -- skipping any inner loops (loop, while, loop_body)
|
||||
pub fn block_query(b: ast::blk, p: fn@(@ast::expr) -> bool) -> bool {
|
||||
pub fn block_query(b: &ast::blk, p: fn@(@ast::expr) -> bool) -> bool {
|
||||
let rs = @mut false;
|
||||
let visit_expr: @fn(@ast::expr,
|
||||
&&flag: @mut bool,
|
||||
|
|
|
@ -70,7 +70,7 @@ pub fn explain_region_and_span(cx: ctxt, region: ty::Region)
|
|||
re_scope(node_id) => {
|
||||
match cx.items.find(&node_id) {
|
||||
Some(ast_map::node_block(ref blk)) => {
|
||||
explain_span(cx, "block", (*blk).span)
|
||||
explain_span(cx, "block", blk.span)
|
||||
}
|
||||
Some(ast_map::node_expr(expr)) => {
|
||||
match expr.node {
|
||||
|
@ -108,7 +108,7 @@ pub fn explain_region_and_span(cx: ctxt, region: ty::Region)
|
|||
|
||||
match cx.items.find(&id) {
|
||||
Some(ast_map::node_block(ref blk)) => {
|
||||
let (msg, opt_span) = explain_span(cx, "block", (*blk).span);
|
||||
let (msg, opt_span) = explain_span(cx, "block", blk.span);
|
||||
(fmt!("%s %s", prefix, msg), opt_span)
|
||||
}
|
||||
Some(_) | None => {
|
||||
|
@ -159,7 +159,7 @@ pub fn re_scope_id_to_str(cx: ctxt, node_id: ast::node_id) -> ~str {
|
|||
match cx.items.find(&node_id) {
|
||||
Some(ast_map::node_block(ref blk)) => {
|
||||
fmt!("<block at %s>",
|
||||
cx.sess.codemap.span_to_str((*blk).span))
|
||||
cx.sess.codemap.span_to_str(blk.span))
|
||||
}
|
||||
Some(ast_map::node_expr(expr)) => {
|
||||
match expr.node {
|
||||
|
|
|
@ -76,7 +76,7 @@ struct ReadyCtx {
|
|||
fns: ~[ListenerFn]
|
||||
}
|
||||
|
||||
fn fold_mod(_ctx: @mut ReadyCtx, m: ast::_mod,
|
||||
fn fold_mod(_ctx: @mut ReadyCtx, m: &ast::_mod,
|
||||
fold: fold::ast_fold) -> ast::_mod {
|
||||
fn strip_main(item: @ast::item) -> @ast::item {
|
||||
@ast::item {
|
||||
|
@ -87,11 +87,11 @@ fn fold_mod(_ctx: @mut ReadyCtx, m: ast::_mod,
|
|||
}
|
||||
}
|
||||
|
||||
fold::noop_fold_mod(ast::_mod {
|
||||
items: do vec::map(m.items) |item| {
|
||||
fold::noop_fold_mod(&ast::_mod {
|
||||
items: do m.items.map |item| {
|
||||
strip_main(*item)
|
||||
},
|
||||
.. m
|
||||
.. copy *m
|
||||
}, fold)
|
||||
}
|
||||
|
||||
|
@ -199,7 +199,7 @@ pub fn ready_crate(sess: session::Session,
|
|||
|
||||
let fold = fold::make_fold(precursor);
|
||||
|
||||
@fold.fold_crate(*crate)
|
||||
@fold.fold_crate(crate)
|
||||
}
|
||||
|
||||
pub fn parse_vers(vers: ~str) -> result::Result<semver::Version, ~str> {
|
||||
|
|
|
@ -186,8 +186,8 @@ pub fn map_decoded_item(diag: span_handler,
|
|||
|
||||
pub fn map_fn(
|
||||
fk: &visit::fn_kind,
|
||||
decl: fn_decl,
|
||||
body: blk,
|
||||
decl: &fn_decl,
|
||||
body: &blk,
|
||||
sp: codemap::span,
|
||||
id: node_id,
|
||||
&&cx: @mut Ctx,
|
||||
|
@ -205,7 +205,7 @@ pub fn map_fn(
|
|||
id: id,
|
||||
attrs: /* FIXME (#2543) */ vec::from_slice(*attrs),
|
||||
self_id: self_id,
|
||||
body: /* FIXME (#2543) */ copy body,
|
||||
body: /* FIXME (#2543) */ copy *body,
|
||||
},
|
||||
span: sp,
|
||||
};
|
||||
|
@ -222,8 +222,8 @@ pub fn map_fn(
|
|||
visit::visit_fn(fk, decl, body, sp, id, cx, v);
|
||||
}
|
||||
|
||||
pub fn map_block(b: blk, &&cx: @mut Ctx, v: visit::vt<@mut Ctx>) {
|
||||
cx.map.insert(b.node.id, node_block(/* FIXME (#2543) */ copy b));
|
||||
pub fn map_block(b: &blk, &&cx: @mut Ctx, v: visit::vt<@mut Ctx>) {
|
||||
cx.map.insert(b.node.id, node_block(/* FIXME (#2543) */ copy *b));
|
||||
visit::visit_block(b, cx, v);
|
||||
}
|
||||
|
||||
|
@ -244,7 +244,7 @@ pub fn map_local(loc: @local, &&cx: @mut Ctx, v: visit::vt<@mut Ctx>) {
|
|||
visit::visit_local(loc, cx, v);
|
||||
}
|
||||
|
||||
pub fn map_arm(arm: arm, &&cx: @mut Ctx, v: visit::vt<@mut Ctx>) {
|
||||
pub fn map_arm(arm: &arm, &&cx: @mut Ctx, v: visit::vt<@mut Ctx>) {
|
||||
number_pat(cx, arm.pats[0]);
|
||||
visit::visit_arm(arm, cx, v);
|
||||
}
|
||||
|
@ -308,7 +308,7 @@ pub fn map_item(i: @item, &&cx: @mut Ctx, v: visit::vt<@mut Ctx>) {
|
|||
cx.map.insert(p.ref_id, node_item(i, item_path));
|
||||
}
|
||||
for methods.each |tm| {
|
||||
let id = ast_util::trait_method_to_ty_method(*tm).id;
|
||||
let id = ast_util::trait_method_to_ty_method(tm).id;
|
||||
let d_id = ast_util::local_def(i.id);
|
||||
cx.map.insert(id, node_trait_method(@*tm, d_id, item_path));
|
||||
}
|
||||
|
@ -387,14 +387,14 @@ pub fn node_id_to_str(map: map, id: node_id, itr: @ident_interner) -> ~str {
|
|||
fmt!("method %s in %s (id=%?)",
|
||||
*itr.get(m.ident), path_to_str(*path, itr), id)
|
||||
}
|
||||
Some(node_trait_method(tm, _, path)) => {
|
||||
let m = ast_util::trait_method_to_ty_method(*tm);
|
||||
Some(node_trait_method(ref tm, _, path)) => {
|
||||
let m = ast_util::trait_method_to_ty_method(&**tm);
|
||||
fmt!("method %s in %s (id=%?)",
|
||||
*itr.get(m.ident), path_to_str(*path, itr), id)
|
||||
}
|
||||
Some(node_variant(ref variant, _, path)) => {
|
||||
fmt!("variant %s in %s (id=%?)",
|
||||
*itr.get((*variant).node.name), path_to_str(*path, itr), id)
|
||||
*itr.get(variant.node.name), path_to_str(*path, itr), id)
|
||||
}
|
||||
Some(node_expr(expr)) => {
|
||||
fmt!("expr %s (id=%?)", pprust::expr_to_str(expr, itr), id)
|
||||
|
|
|
@ -260,9 +260,9 @@ pub fn public_methods(ms: ~[@method]) -> ~[@method] {
|
|||
|
||||
// extract a ty_method from a trait_method. if the trait_method is
|
||||
// a default, pull out the useful fields to make a ty_method
|
||||
pub fn trait_method_to_ty_method(method: trait_method) -> ty_method {
|
||||
match method {
|
||||
required(ref m) => (*m),
|
||||
pub fn trait_method_to_ty_method(method: &trait_method) -> ty_method {
|
||||
match *method {
|
||||
required(ref m) => copy *m,
|
||||
provided(ref m) => {
|
||||
ty_method {
|
||||
ident: m.ident,
|
||||
|
@ -278,7 +278,7 @@ pub fn trait_method_to_ty_method(method: trait_method) -> ty_method {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn split_trait_methods(trait_methods: ~[trait_method])
|
||||
pub fn split_trait_methods(trait_methods: &[trait_method])
|
||||
-> (~[ty_method], ~[@method]) {
|
||||
let mut reqd = ~[], provd = ~[];
|
||||
for trait_methods.each |trt_method| {
|
||||
|
@ -425,7 +425,7 @@ pub fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> {
|
|||
vfn(l.node.id);
|
||||
},
|
||||
|
||||
visit_block: fn@(b: blk) {
|
||||
visit_block: fn@(b: &blk) {
|
||||
vfn(b.node.id);
|
||||
},
|
||||
|
||||
|
@ -433,7 +433,7 @@ pub fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> {
|
|||
vfn(ast_util::stmt_id(*s));
|
||||
},
|
||||
|
||||
visit_arm: fn@(_a: arm) { },
|
||||
visit_arm: fn@(_a: &arm) { },
|
||||
|
||||
visit_pat: fn@(p: @pat) {
|
||||
vfn(p.id)
|
||||
|
@ -463,8 +463,8 @@ pub fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> {
|
|||
}
|
||||
},
|
||||
|
||||
visit_fn: fn@(fk: &visit::fn_kind, d: ast::fn_decl,
|
||||
_b: ast::blk, _sp: span, id: ast::node_id) {
|
||||
visit_fn: fn@(fk: &visit::fn_kind, d: &ast::fn_decl,
|
||||
_b: &ast::blk, _sp: span, id: ast::node_id) {
|
||||
vfn(id);
|
||||
|
||||
match *fk {
|
||||
|
@ -491,10 +491,10 @@ pub fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> {
|
|||
}
|
||||
},
|
||||
|
||||
visit_ty_method: fn@(_ty_m: ty_method) {
|
||||
visit_ty_method: fn@(_ty_m: &ty_method) {
|
||||
},
|
||||
|
||||
visit_trait_method: fn@(_ty_m: trait_method) {
|
||||
visit_trait_method: fn@(_ty_m: &trait_method) {
|
||||
},
|
||||
|
||||
visit_struct_def: fn@(_sd: @struct_def, _id: ident, _tps: &[ty_param],
|
||||
|
|
|
@ -183,28 +183,28 @@ pub fn contains(haystack: &[@ast::meta_item],
|
|||
}
|
||||
|
||||
fn eq(a: @ast::meta_item, b: @ast::meta_item) -> bool {
|
||||
return match a.node {
|
||||
ast::meta_word(ref na) => match b.node {
|
||||
match a.node {
|
||||
ast::meta_word(ref na) => match b.node {
|
||||
ast::meta_word(ref nb) => (*na) == (*nb),
|
||||
_ => false
|
||||
},
|
||||
ast::meta_name_value(ref na, va) => match b.node {
|
||||
},
|
||||
ast::meta_name_value(ref na, va) => match b.node {
|
||||
ast::meta_name_value(ref nb, vb) => {
|
||||
(*na) == (*nb) && va.node == vb.node
|
||||
}
|
||||
_ => false
|
||||
},
|
||||
ast::meta_list(ref na, misa) => match b.node {
|
||||
ast::meta_list(ref nb, misb) => {
|
||||
},
|
||||
ast::meta_list(ref na, ref misa) => match b.node {
|
||||
ast::meta_list(ref nb, ref misb) => {
|
||||
if na != nb { return false; }
|
||||
for misa.each |&mi| {
|
||||
if !contains(misb, mi) { return false; }
|
||||
for misa.each |mi| {
|
||||
if !misb.contains(mi) { return false; }
|
||||
}
|
||||
true
|
||||
}
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn contains_name(metas: &[@ast::meta_item], name: &str) -> bool {
|
||||
|
@ -260,21 +260,23 @@ pub fn last_meta_item_list_by_name(items: ~[@ast::meta_item], name: &str)
|
|||
|
||||
/* Higher-level applications */
|
||||
|
||||
pub fn sort_meta_items(+items: ~[@ast::meta_item]) -> ~[@ast::meta_item] {
|
||||
pub fn sort_meta_items(items: &[@ast::meta_item]) -> ~[@ast::meta_item] {
|
||||
// This is sort of stupid here, converting to a vec of mutables and back
|
||||
let mut v = items;
|
||||
let mut v = vec::from_slice(items);
|
||||
do std::sort::quick_sort(v) |ma, mb| {
|
||||
get_meta_item_name(*ma) <= get_meta_item_name(*mb)
|
||||
}
|
||||
|
||||
// There doesn't seem to be a more optimal way to do this
|
||||
do v.map |&m| {
|
||||
do v.map |m| {
|
||||
match m.node {
|
||||
ast::meta_list(n, mis) => @spanned {
|
||||
node: ast::meta_list(n, sort_meta_items(mis)),
|
||||
.. *m
|
||||
},
|
||||
_ => m
|
||||
ast::meta_list(n, ref mis) => {
|
||||
@spanned {
|
||||
node: ast::meta_list(n, sort_meta_items(*mis)),
|
||||
.. /*bad*/ copy **m
|
||||
}
|
||||
}
|
||||
_ => /*bad*/ copy *m
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,63 +24,71 @@ use core::vec;
|
|||
use std::oldmap::HashMap;
|
||||
|
||||
pub fn expand_expr(exts: SyntaxExtensions, cx: ext_ctxt,
|
||||
e: expr_, s: span, fld: ast_fold,
|
||||
orig: fn@(expr_, span, ast_fold) -> (expr_, span))
|
||||
e: &expr_, s: span, fld: ast_fold,
|
||||
orig: fn@(&expr_, span, ast_fold) -> (expr_, span))
|
||||
-> (expr_, span) {
|
||||
return match e {
|
||||
// expr_mac should really be expr_ext or something; it's the
|
||||
// entry-point for all syntax extensions.
|
||||
expr_mac(ref mac) => {
|
||||
|
||||
match *e {
|
||||
// expr_mac should really be expr_ext or something; it's the
|
||||
// entry-point for all syntax extensions.
|
||||
expr_mac(ref mac) => {
|
||||
match (*mac).node {
|
||||
|
||||
// Token-tree macros, these will be the only case when we're
|
||||
// finished transitioning.
|
||||
mac_invoc_tt(pth, ref tts) => {
|
||||
assert (vec::len(pth.idents) == 1u);
|
||||
/* using idents and token::special_idents would make the
|
||||
the macro names be hygienic */
|
||||
let extname = cx.parse_sess().interner.get(pth.idents[0]);
|
||||
match exts.find(&extname) {
|
||||
None => {
|
||||
cx.span_fatal(pth.span,
|
||||
fmt!("macro undefined: '%s'", *extname))
|
||||
}
|
||||
Some(NormalTT(SyntaxExpanderTT{expander: exp,
|
||||
span: exp_sp})) => {
|
||||
cx.bt_push(ExpandedFrom(CallInfo{
|
||||
call_site: s,
|
||||
callee: NameAndSpan {
|
||||
name: *extname, span: exp_sp
|
||||
// Token-tree macros, these will be the only case when we're
|
||||
// finished transitioning.
|
||||
mac_invoc_tt(pth, ref tts) => {
|
||||
assert (vec::len(pth.idents) == 1u);
|
||||
/* using idents and token::special_idents would make the
|
||||
the macro names be hygienic */
|
||||
let extname = cx.parse_sess().interner.get(pth.idents[0]);
|
||||
match exts.find(&extname) {
|
||||
None => {
|
||||
cx.span_fatal(
|
||||
pth.span,
|
||||
fmt!("macro undefined: '%s'", *extname))
|
||||
}
|
||||
}));
|
||||
Some(NormalTT(SyntaxExpanderTT{
|
||||
expander: exp,
|
||||
span: exp_sp
|
||||
})) => {
|
||||
cx.bt_push(ExpandedFrom(CallInfo {
|
||||
call_site: s,
|
||||
callee: NameAndSpan {
|
||||
name: *extname,
|
||||
span: exp_sp,
|
||||
},
|
||||
}));
|
||||
|
||||
let expanded = match exp(cx, (*mac).span, (*tts)) {
|
||||
MRExpr(e) => e,
|
||||
MRAny(expr_maker,_,_) => expr_maker(),
|
||||
_ => cx.span_fatal(
|
||||
pth.span, fmt!("non-expr macro in expr pos: %s",
|
||||
*extname))
|
||||
};
|
||||
let expanded = match exp(cx, mac.span, *tts) {
|
||||
MRExpr(e) => e,
|
||||
MRAny(expr_maker,_,_) => expr_maker(),
|
||||
_ => {
|
||||
cx.span_fatal(
|
||||
pth.span,
|
||||
fmt!(
|
||||
"non-expr macro in expr pos: %s",
|
||||
*extname
|
||||
)
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
//keep going, outside-in
|
||||
let fully_expanded = fld.fold_expr(expanded).node;
|
||||
cx.bt_pop();
|
||||
|
||||
(fully_expanded, s)
|
||||
}
|
||||
_ => {
|
||||
cx.span_fatal(pth.span,
|
||||
fmt!("'%s' is not a tt-style macro",
|
||||
*extname))
|
||||
}
|
||||
//keep going, outside-in
|
||||
let fully_expanded = fld.fold_expr(expanded).node;
|
||||
cx.bt_pop();
|
||||
|
||||
(fully_expanded, s)
|
||||
}
|
||||
_ => {
|
||||
cx.span_fatal(
|
||||
pth.span,
|
||||
fmt!("'%s' is not a tt-style macro", *extname)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => orig(e, s, fld)
|
||||
};
|
||||
}
|
||||
_ => orig(e, s, fld)
|
||||
}
|
||||
}
|
||||
|
||||
// This is a secondary mechanism for invoking syntax extensions on items:
|
||||
|
@ -93,8 +101,8 @@ pub fn expand_expr(exts: SyntaxExtensions, cx: ext_ctxt,
|
|||
// NB: there is some redundancy between this and expand_item, below, and
|
||||
// they might benefit from some amount of semantic and language-UI merger.
|
||||
pub fn expand_mod_items(exts: SyntaxExtensions, cx: ext_ctxt,
|
||||
module_: ast::_mod, fld: ast_fold,
|
||||
orig: fn@(ast::_mod, ast_fold) -> ast::_mod)
|
||||
module_: &ast::_mod, fld: ast_fold,
|
||||
orig: fn@(&ast::_mod, ast_fold) -> ast::_mod)
|
||||
-> ast::_mod {
|
||||
// Fold the contents first:
|
||||
let module_ = orig(module_, fld);
|
||||
|
@ -130,8 +138,8 @@ pub fn expand_mod_items(exts: SyntaxExtensions, cx: ext_ctxt,
|
|||
|
||||
// When we enter a module, record it, for the sake of `module!`
|
||||
pub fn expand_item(exts: SyntaxExtensions,
|
||||
cx: ext_ctxt, &&it: @ast::item, fld: ast_fold,
|
||||
orig: fn@(&&v: @ast::item, ast_fold) -> Option<@ast::item>)
|
||||
cx: ext_ctxt, it: @ast::item, fld: ast_fold,
|
||||
orig: fn@(@ast::item, ast_fold) -> Option<@ast::item>)
|
||||
-> Option<@ast::item> {
|
||||
let is_mod = match it.node {
|
||||
ast::item_mod(_) | ast::item_foreign_mod(_) => true,
|
||||
|
@ -223,13 +231,13 @@ pub fn expand_item_mac(exts: SyntaxExtensions,
|
|||
}
|
||||
|
||||
pub fn expand_stmt(exts: SyntaxExtensions, cx: ext_ctxt,
|
||||
&& s: stmt_, sp: span, fld: ast_fold,
|
||||
orig: fn@(&&s: stmt_, span, ast_fold) -> (stmt_, span))
|
||||
s: &stmt_, sp: span, fld: ast_fold,
|
||||
orig: fn@(s: &stmt_, span, ast_fold) -> (stmt_, span))
|
||||
-> (stmt_, span) {
|
||||
|
||||
let (mac, pth, tts, semi) = match s {
|
||||
let (mac, pth, tts, semi) = match *s {
|
||||
stmt_mac(ref mac, semi) => {
|
||||
match (*mac).node {
|
||||
match mac.node {
|
||||
mac_invoc_tt(pth, ref tts) => ((*mac), pth, (*tts), semi)
|
||||
}
|
||||
}
|
||||
|
@ -361,8 +369,7 @@ pub fn expand_crate(parse_sess: @mut parse::ParseSess,
|
|||
// as it registers all the core macros as expanders.
|
||||
f.fold_expr(cm);
|
||||
|
||||
let res = @f.fold_crate(*c);
|
||||
return res;
|
||||
@f.fold_crate(&*c)
|
||||
}
|
||||
// Local Variables:
|
||||
// mode: rust
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -38,8 +38,8 @@ use core::u64;
|
|||
use core::vec;
|
||||
|
||||
// The @ps is stored here to prevent recursive type.
|
||||
pub enum ann_node {
|
||||
node_block(@ps, ast::blk),
|
||||
pub enum ann_node/& {
|
||||
node_block(@ps, &ast::blk),
|
||||
node_item(@ps, @ast::item),
|
||||
node_expr(@ps, @ast::expr),
|
||||
node_pat(@ps, @ast::pat),
|
||||
|
@ -183,7 +183,7 @@ pub fn fun_to_str(decl: ast::fn_decl, name: ast::ident,
|
|||
}
|
||||
}
|
||||
|
||||
pub fn block_to_str(blk: ast::blk, intr: @ident_interner) -> ~str {
|
||||
pub fn block_to_str(blk: &ast::blk, intr: @ident_interner) -> ~str {
|
||||
do io::with_str_writer |wr| {
|
||||
let s = rust_printer(wr, intr);
|
||||
// containing cbox, will be closed by print-block at }
|
||||
|
@ -510,7 +510,7 @@ pub fn print_item(s: @ps, &&item: @ast::item) {
|
|||
item.vis
|
||||
);
|
||||
word(s.s, ~" ");
|
||||
print_block_with_attrs(s, (*body), item.attrs);
|
||||
print_block_with_attrs(s, body, item.attrs);
|
||||
}
|
||||
ast::item_mod(_mod) => {
|
||||
head(s, visibility_qualified(item.vis, ~"mod"));
|
||||
|
@ -607,8 +607,8 @@ pub fn print_item(s: @ps, &&item: @ast::item) {
|
|||
}
|
||||
word(s.s, ~" ");
|
||||
bopen(s);
|
||||
for (*methods).each |meth| {
|
||||
print_trait_method(s, *meth);
|
||||
for methods.each |meth| {
|
||||
print_trait_method(s, meth);
|
||||
}
|
||||
bclose(s, item.span);
|
||||
}
|
||||
|
@ -741,7 +741,7 @@ pub fn print_struct(s: @ps,
|
|||
maybe_print_comment(s, dtor.span.lo);
|
||||
print_outer_attributes(s, dtor.node.attrs);
|
||||
head(s, ~"drop");
|
||||
print_block(s, dtor.node.body);
|
||||
print_block(s, &dtor.node.body);
|
||||
}
|
||||
|
||||
for struct_def.fields.each |field| {
|
||||
|
@ -839,7 +839,7 @@ pub fn print_variant(s: @ps, v: ast::variant) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn print_ty_method(s: @ps, m: ast::ty_method) {
|
||||
pub fn print_ty_method(s: @ps, m: &ast::ty_method) {
|
||||
hardbreak_if_not_bol(s);
|
||||
maybe_print_comment(s, m.span.lo);
|
||||
print_outer_attributes(s, m.attrs);
|
||||
|
@ -849,10 +849,10 @@ pub fn print_ty_method(s: @ps, m: ast::ty_method) {
|
|||
word(s.s, ~";");
|
||||
}
|
||||
|
||||
pub fn print_trait_method(s: @ps, m: ast::trait_method) {
|
||||
match m {
|
||||
required(ref ty_m) => print_ty_method(s, (*ty_m)),
|
||||
provided(m) => print_method(s, m)
|
||||
pub fn print_trait_method(s: @ps, m: &ast::trait_method) {
|
||||
match *m {
|
||||
required(ref ty_m) => print_ty_method(s, ty_m),
|
||||
provided(m) => print_method(s, m)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -864,7 +864,7 @@ pub fn print_method(s: @ps, meth: @ast::method) {
|
|||
meth.ident, meth.tps, Some(meth.self_ty.node),
|
||||
meth.vis);
|
||||
word(s.s, ~" ");
|
||||
print_block_with_attrs(s, meth.body, meth.attrs);
|
||||
print_block_with_attrs(s, &meth.body, meth.attrs);
|
||||
}
|
||||
|
||||
pub fn print_outer_attributes(s: @ps, attrs: ~[ast::attribute]) {
|
||||
|
@ -935,22 +935,22 @@ pub fn print_stmt(s: @ps, st: ast::stmt) {
|
|||
maybe_print_trailing_comment(s, st.span, None);
|
||||
}
|
||||
|
||||
pub fn print_block(s: @ps, blk: ast::blk) {
|
||||
pub fn print_block(s: @ps, blk: &ast::blk) {
|
||||
print_possibly_embedded_block(s, blk, block_normal, indent_unit);
|
||||
}
|
||||
|
||||
pub fn print_block_unclosed(s: @ps, blk: ast::blk) {
|
||||
pub fn print_block_unclosed(s: @ps, blk: &ast::blk) {
|
||||
print_possibly_embedded_block_(s, blk, block_normal, indent_unit, ~[],
|
||||
false);
|
||||
}
|
||||
|
||||
pub fn print_block_unclosed_indent(s: @ps, blk: ast::blk, indented: uint) {
|
||||
pub fn print_block_unclosed_indent(s: @ps, blk: &ast::blk, indented: uint) {
|
||||
print_possibly_embedded_block_(s, blk, block_normal, indented, ~[],
|
||||
false);
|
||||
}
|
||||
|
||||
pub fn print_block_with_attrs(s: @ps,
|
||||
blk: ast::blk,
|
||||
blk: &ast::blk,
|
||||
attrs: ~[ast::attribute]) {
|
||||
print_possibly_embedded_block_(s, blk, block_normal, indent_unit, attrs,
|
||||
true);
|
||||
|
@ -959,7 +959,7 @@ pub fn print_block_with_attrs(s: @ps,
|
|||
pub enum embed_type { block_block_fn, block_normal, }
|
||||
|
||||
pub fn print_possibly_embedded_block(s: @ps,
|
||||
blk: ast::blk,
|
||||
blk: &ast::blk,
|
||||
embedded: embed_type,
|
||||
indented: uint) {
|
||||
print_possibly_embedded_block_(
|
||||
|
@ -967,7 +967,7 @@ pub fn print_possibly_embedded_block(s: @ps,
|
|||
}
|
||||
|
||||
pub fn print_possibly_embedded_block_(s: @ps,
|
||||
blk: ast::blk,
|
||||
blk: &ast::blk,
|
||||
embedded: embed_type,
|
||||
indented: uint,
|
||||
attrs: ~[ast::attribute],
|
||||
|
@ -1002,7 +1002,7 @@ pub fn print_possibly_embedded_block_(s: @ps,
|
|||
(s.ann.post)(ann_node);
|
||||
}
|
||||
|
||||
pub fn print_if(s: @ps, test: @ast::expr, blk: ast::blk,
|
||||
pub fn print_if(s: @ps, test: @ast::expr, blk: &ast::blk,
|
||||
elseopt: Option<@ast::expr>, chk: bool) {
|
||||
head(s, ~"if");
|
||||
if chk { word_nbsp(s, ~"check"); }
|
||||
|
@ -1020,7 +1020,7 @@ pub fn print_if(s: @ps, test: @ast::expr, blk: ast::blk,
|
|||
word(s.s, ~" else if ");
|
||||
print_expr(s, i);
|
||||
space(s.s);
|
||||
print_block(s, (*t));
|
||||
print_block(s, t);
|
||||
do_else(s, e);
|
||||
}
|
||||
// "final else"
|
||||
|
@ -1028,7 +1028,7 @@ pub fn print_if(s: @ps, test: @ast::expr, blk: ast::blk,
|
|||
cbox(s, indent_unit - 1u);
|
||||
ibox(s, 0u);
|
||||
word(s.s, ~" else ");
|
||||
print_block(s, (*b));
|
||||
print_block(s, b);
|
||||
}
|
||||
// BLEAH, constraints would be great here
|
||||
_ => {
|
||||
|
@ -1263,13 +1263,13 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) {
|
|||
print_type_ex(s, ty, true);
|
||||
}
|
||||
ast::expr_if(test, ref blk, elseopt) => {
|
||||
print_if(s, test, (*blk), elseopt, false);
|
||||
print_if(s, test, blk, elseopt, false);
|
||||
}
|
||||
ast::expr_while(test, ref blk) => {
|
||||
head(s, ~"while");
|
||||
print_expr(s, test);
|
||||
space(s.s);
|
||||
print_block(s, (*blk));
|
||||
print_block(s, blk);
|
||||
}
|
||||
ast::expr_loop(ref blk, opt_ident) => {
|
||||
head(s, ~"loop");
|
||||
|
@ -1278,7 +1278,7 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) {
|
|||
print_ident(s, *ident);
|
||||
word_space(s, ~":");
|
||||
});
|
||||
print_block(s, (*blk));
|
||||
print_block(s, blk);
|
||||
}
|
||||
ast::expr_match(expr, ref arms) => {
|
||||
cbox(s, match_indent_unit);
|
||||
|
@ -1323,7 +1323,7 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) {
|
|||
ast::expr_block(ref blk) => {
|
||||
// the block will close the pattern's ibox
|
||||
print_block_unclosed_indent(
|
||||
s, (*blk), match_indent_unit);
|
||||
s, blk, match_indent_unit);
|
||||
}
|
||||
_ => {
|
||||
end(s); // close the ibox for the pattern
|
||||
|
@ -1340,7 +1340,7 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) {
|
|||
}
|
||||
} else {
|
||||
// the block will close the pattern's ibox
|
||||
print_block_unclosed_indent(s, arm.body, match_indent_unit);
|
||||
print_block_unclosed_indent(s, &arm.body, match_indent_unit);
|
||||
}
|
||||
}
|
||||
bclose_(s, expr.span, match_indent_unit);
|
||||
|
@ -1354,7 +1354,7 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) {
|
|||
Some(sigil), ast::inherited);
|
||||
print_fn_args_and_ret(s, /* FIXME (#2543) */ copy *decl, None);
|
||||
space(s.s);
|
||||
print_block(s, (*body));
|
||||
print_block(s, body);
|
||||
}
|
||||
ast::expr_fn_block(ref decl, ref body) => {
|
||||
// in do/for blocks we don't want to show an empty
|
||||
|
@ -1365,16 +1365,16 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) {
|
|||
print_fn_block_args(s, /* FIXME (#2543) */ copy *decl);
|
||||
space(s.s);
|
||||
// }
|
||||
assert (*body).node.stmts.is_empty();
|
||||
assert (*body).node.expr.is_some();
|
||||
assert body.node.stmts.is_empty();
|
||||
assert body.node.expr.is_some();
|
||||
// we extract the block, so as not to create another set of boxes
|
||||
match (*body).node.expr.get().node {
|
||||
match body.node.expr.get().node {
|
||||
ast::expr_block(ref blk) => {
|
||||
print_block_unclosed(s, (*blk));
|
||||
print_block_unclosed(s, blk);
|
||||
}
|
||||
_ => {
|
||||
// this is a bare expression
|
||||
print_expr(s, (*body).node.expr.get());
|
||||
print_expr(s, body.node.expr.get());
|
||||
end(s); // need to close a box
|
||||
}
|
||||
}
|
||||
|
@ -1394,7 +1394,7 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) {
|
|||
cbox(s, indent_unit);
|
||||
// head-box, will be closed by print-block after {
|
||||
ibox(s, 0u);
|
||||
print_block(s, (*blk));
|
||||
print_block(s, blk);
|
||||
}
|
||||
ast::expr_copy(e) => { word_space(s, ~"copy"); print_expr(s, e); }
|
||||
ast::expr_assign(lhs, rhs) => {
|
||||
|
|
|
@ -67,18 +67,18 @@ pub struct Visitor<E> {
|
|||
visit_foreign_item: fn@(@foreign_item, E, vt<E>),
|
||||
visit_item: fn@(@item, E, vt<E>),
|
||||
visit_local: fn@(@local, E, vt<E>),
|
||||
visit_block: fn@(ast::blk, E, vt<E>),
|
||||
visit_block: fn@(&blk, E, vt<E>),
|
||||
visit_stmt: fn@(@stmt, E, vt<E>),
|
||||
visit_arm: fn@(arm, E, vt<E>),
|
||||
visit_arm: fn@(&arm, E, vt<E>),
|
||||
visit_pat: fn@(@pat, E, vt<E>),
|
||||
visit_decl: fn@(@decl, E, vt<E>),
|
||||
visit_expr: fn@(@expr, E, vt<E>),
|
||||
visit_expr_post: fn@(@expr, E, vt<E>),
|
||||
visit_ty: fn@(@Ty, E, vt<E>),
|
||||
visit_ty_params: fn@(&[ty_param], E, vt<E>),
|
||||
visit_fn: fn@(&fn_kind, fn_decl, blk, span, node_id, E, vt<E>),
|
||||
visit_ty_method: fn@(ty_method, E, vt<E>),
|
||||
visit_trait_method: fn@(trait_method, E, vt<E>),
|
||||
visit_fn: fn@(&fn_kind, &fn_decl, &blk, span, node_id, E, vt<E>),
|
||||
visit_ty_method: fn@(&ty_method, E, vt<E>),
|
||||
visit_trait_method: fn@(&trait_method, E, vt<E>),
|
||||
visit_struct_def: fn@(@struct_def, ident, &[ty_param], node_id, E,
|
||||
vt<E>),
|
||||
visit_struct_field: fn@(@struct_field, E, vt<E>),
|
||||
|
@ -146,8 +146,8 @@ pub fn visit_item<E>(i: @item, e: E, v: vt<E>) {
|
|||
*tps,
|
||||
purity
|
||||
),
|
||||
/* FIXME (#2543) */ copy *decl,
|
||||
*body,
|
||||
decl,
|
||||
body,
|
||||
i.span,
|
||||
i.id,
|
||||
e,
|
||||
|
@ -190,7 +190,7 @@ pub fn visit_item<E>(i: @item, e: E, v: vt<E>) {
|
|||
(v.visit_ty_params)(*tps, e, v);
|
||||
for traits.each |p| { visit_path(p.path, e, v); }
|
||||
for (*methods).each |m| {
|
||||
(v.visit_trait_method)(*m, e, v);
|
||||
(v.visit_trait_method)(m, e, v);
|
||||
}
|
||||
}
|
||||
item_mac(ref m) => visit_mac((*m), e, v)
|
||||
|
@ -198,12 +198,12 @@ pub fn visit_item<E>(i: @item, e: E, v: vt<E>) {
|
|||
}
|
||||
|
||||
pub fn visit_enum_def<E>(enum_definition: ast::enum_def,
|
||||
tps: ~[ast::ty_param],
|
||||
tps: &[ast::ty_param],
|
||||
e: E,
|
||||
v: vt<E>) {
|
||||
for enum_definition.variants.each |vr| {
|
||||
match vr.node.kind {
|
||||
tuple_variant_kind(variant_args) => {
|
||||
tuple_variant_kind(ref variant_args) => {
|
||||
for variant_args.each |va| { (v.visit_ty)(va.ty, e, v); }
|
||||
}
|
||||
struct_variant_kind(struct_def) => {
|
||||
|
@ -223,30 +223,31 @@ pub fn skip_ty<E>(_t: @Ty, _e: E, _v: vt<E>) {}
|
|||
|
||||
pub fn visit_ty<E>(t: @Ty, e: E, v: vt<E>) {
|
||||
match t.node {
|
||||
ty_box(mt) | ty_uniq(mt) |
|
||||
ty_vec(mt) | ty_ptr(mt) | ty_rptr(_, mt) => {
|
||||
(v.visit_ty)(mt.ty, e, v);
|
||||
}
|
||||
ty_rec(ref flds) => for (*flds).each |f| {
|
||||
(v.visit_ty)(f.node.mt.ty, e, v);
|
||||
},
|
||||
ty_tup(ts) => for ts.each |tt| {
|
||||
(v.visit_ty)(*tt, e, v);
|
||||
},
|
||||
ty_closure(f) => {
|
||||
for f.decl.inputs.each |a| { (v.visit_ty)(a.ty, e, v); }
|
||||
(v.visit_ty)(f.decl.output, e, v);
|
||||
}
|
||||
ty_bare_fn(f) => {
|
||||
for f.decl.inputs.each |a| { (v.visit_ty)(a.ty, e, v); }
|
||||
(v.visit_ty)(f.decl.output, e, v);
|
||||
}
|
||||
ty_path(p, _) => visit_path(p, e, v),
|
||||
ty_fixed_length_vec(mt, _) => (v.visit_ty)(mt.ty, e, v),
|
||||
ty_nil |
|
||||
ty_bot |
|
||||
ty_mac(_) |
|
||||
ty_infer => ()
|
||||
ty_box(mt) | ty_uniq(mt) |
|
||||
ty_vec(mt) | ty_ptr(mt) | ty_rptr(_, mt) => {
|
||||
(v.visit_ty)(mt.ty, e, v);
|
||||
},
|
||||
ty_rec(ref flds) => {
|
||||
for flds.each |f| {
|
||||
(v.visit_ty)(f.node.mt.ty, e, v);
|
||||
}
|
||||
},
|
||||
ty_tup(ref ts) => {
|
||||
for ts.each |tt| {
|
||||
(v.visit_ty)(*tt, e, v);
|
||||
}
|
||||
},
|
||||
ty_closure(ref f) => {
|
||||
for f.decl.inputs.each |a| { (v.visit_ty)(a.ty, e, v); }
|
||||
(v.visit_ty)(f.decl.output, e, v);
|
||||
},
|
||||
ty_bare_fn(ref f) => {
|
||||
for f.decl.inputs.each |a| { (v.visit_ty)(a.ty, e, v); }
|
||||
(v.visit_ty)(f.decl.output, e, v);
|
||||
},
|
||||
ty_path(p, _) => visit_path(p, e, v),
|
||||
ty_fixed_length_vec(ref mt, _) => (v.visit_ty)(mt.ty, e, v),
|
||||
ty_nil | ty_bot | ty_mac(_) | ty_infer => ()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -256,49 +257,55 @@ pub fn visit_path<E>(p: @path, e: E, v: vt<E>) {
|
|||
|
||||
pub fn visit_pat<E>(p: @pat, e: E, v: vt<E>) {
|
||||
match p.node {
|
||||
pat_enum(path, children) => {
|
||||
visit_path(path, e, v);
|
||||
do option::iter(&children) |children| {
|
||||
for children.each |child| { (v.visit_pat)(*child, e, v); }}
|
||||
}
|
||||
pat_rec(fields, _) => for fields.each |f| {
|
||||
(v.visit_pat)(f.pat, e, v)
|
||||
},
|
||||
pat_struct(path, fields, _) => {
|
||||
visit_path(path, e, v);
|
||||
for fields.each |f| {
|
||||
(v.visit_pat)(f.pat, e, v);
|
||||
pat_enum(path, ref children) => {
|
||||
visit_path(path, e, v);
|
||||
do children.iter |children| {
|
||||
for children.each |child| { (v.visit_pat)(*child, e, v); }
|
||||
}
|
||||
}
|
||||
}
|
||||
pat_tup(elts) => for elts.each |elt| {
|
||||
(v.visit_pat)(*elt, e, v)
|
||||
},
|
||||
pat_box(inner) | pat_uniq(inner) | pat_region(inner) =>
|
||||
(v.visit_pat)(inner, e, v),
|
||||
pat_ident(_, path, inner) => {
|
||||
visit_path(path, e, v);
|
||||
do option::iter(&inner) |subpat| { (v.visit_pat)(*subpat, e, v)};
|
||||
}
|
||||
pat_lit(ex) => (v.visit_expr)(ex, e, v),
|
||||
pat_range(e1, e2) => {
|
||||
(v.visit_expr)(e1, e, v);
|
||||
(v.visit_expr)(e2, e, v);
|
||||
}
|
||||
pat_wild => (),
|
||||
pat_vec(elts, tail) => {
|
||||
for elts.each |elt| {
|
||||
(v.visit_pat)(*elt, e, v);
|
||||
pat_rec(ref fields, _) => {
|
||||
for fields.each |f| {
|
||||
(v.visit_pat)(f.pat, e, v)
|
||||
}
|
||||
},
|
||||
pat_struct(path, ref fields, _) => {
|
||||
visit_path(path, e, v);
|
||||
for fields.each |f| {
|
||||
(v.visit_pat)(f.pat, e, v);
|
||||
}
|
||||
}
|
||||
do option::iter(&tail) |tail| {
|
||||
(v.visit_pat)(*tail, e, v);
|
||||
pat_tup(ref elts) => {
|
||||
for elts.each |elt| {
|
||||
(v.visit_pat)(*elt, e, v)
|
||||
}
|
||||
},
|
||||
pat_box(inner) | pat_uniq(inner) | pat_region(inner) => {
|
||||
(v.visit_pat)(inner, e, v)
|
||||
},
|
||||
pat_ident(_, path, ref inner) => {
|
||||
visit_path(path, e, v);
|
||||
do inner.iter |subpat| { (v.visit_pat)(*subpat, e, v) }
|
||||
}
|
||||
pat_lit(ex) => (v.visit_expr)(ex, e, v),
|
||||
pat_range(e1, e2) => {
|
||||
(v.visit_expr)(e1, e, v);
|
||||
(v.visit_expr)(e2, e, v);
|
||||
}
|
||||
pat_wild => (),
|
||||
pat_vec(ref elts, ref tail) => {
|
||||
for elts.each |elt| {
|
||||
(v.visit_pat)(*elt, e, v);
|
||||
}
|
||||
do tail.iter |tail| {
|
||||
(v.visit_pat)(*tail, e, v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn visit_foreign_item<E>(ni: @foreign_item, e: E, v: vt<E>) {
|
||||
match ni.node {
|
||||
foreign_item_fn(fd, _, ref tps) => {
|
||||
foreign_item_fn(ref fd, _, ref tps) => {
|
||||
(v.visit_ty_params)(*tps, e, v);
|
||||
visit_fn_decl(fd, e, v);
|
||||
}
|
||||
|
@ -323,7 +330,7 @@ pub fn visit_ty_params<E>(tps: &[ty_param], e: E, v: vt<E>) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn visit_fn_decl<E>(fd: fn_decl, e: E, v: vt<E>) {
|
||||
pub fn visit_fn_decl<E>(fd: &fn_decl, e: E, v: vt<E>) {
|
||||
for fd.inputs.each |a| {
|
||||
(v.visit_pat)(a.pat, e, v);
|
||||
(v.visit_ty)(a.ty, e, v);
|
||||
|
@ -342,8 +349,8 @@ pub fn visit_method_helper<E>(m: &method, e: E, v: vt<E>) {
|
|||
m.tps,
|
||||
m
|
||||
),
|
||||
m.decl,
|
||||
m.body,
|
||||
&m.decl,
|
||||
&m.body,
|
||||
m.span,
|
||||
m.id,
|
||||
e,
|
||||
|
@ -360,8 +367,8 @@ pub fn visit_struct_dtor_helper<E>(dtor: struct_dtor, tps: &[ty_param],
|
|||
dtor.node.self_id,
|
||||
parent_id
|
||||
),
|
||||
ast_util::dtor_dec(),
|
||||
dtor.node.body,
|
||||
&ast_util::dtor_dec(),
|
||||
&dtor.node.body,
|
||||
dtor.span,
|
||||
dtor.node.id,
|
||||
e,
|
||||
|
@ -370,22 +377,22 @@ pub fn visit_struct_dtor_helper<E>(dtor: struct_dtor, tps: &[ty_param],
|
|||
|
||||
}
|
||||
|
||||
pub fn visit_fn<E>(fk: &fn_kind, decl: fn_decl, body: blk, _sp: span,
|
||||
pub fn visit_fn<E>(fk: &fn_kind, decl: &fn_decl, body: &blk, _sp: span,
|
||||
_id: node_id, e: E, v: vt<E>) {
|
||||
visit_fn_decl(decl, e, v);
|
||||
(v.visit_ty_params)(tps_of_fn(fk), e, v);
|
||||
(v.visit_block)(body, e, v);
|
||||
}
|
||||
|
||||
pub fn visit_ty_method<E>(m: ty_method, e: E, v: vt<E>) {
|
||||
pub fn visit_ty_method<E>(m: &ty_method, e: E, v: vt<E>) {
|
||||
for m.decl.inputs.each |a| { (v.visit_ty)(a.ty, e, v); }
|
||||
(v.visit_ty_params)(m.tps, e, v);
|
||||
(v.visit_ty)(m.decl.output, e, v);
|
||||
}
|
||||
|
||||
pub fn visit_trait_method<E>(m: trait_method, e: E, v: vt<E>) {
|
||||
match m {
|
||||
required(ref ty_m) => (v.visit_ty_method)((*ty_m), e, v),
|
||||
pub fn visit_trait_method<E>(m: &trait_method, e: E, v: vt<E>) {
|
||||
match *m {
|
||||
required(ref ty_m) => (v.visit_ty_method)(ty_m, e, v),
|
||||
provided(m) => visit_method_helper(m, e, v)
|
||||
}
|
||||
}
|
||||
|
@ -408,7 +415,7 @@ pub fn visit_struct_method<E>(m: @method, e: E, v: vt<E>) {
|
|||
visit_method_helper(m, e, v);
|
||||
}
|
||||
|
||||
pub fn visit_block<E>(b: ast::blk, e: E, v: vt<E>) {
|
||||
pub fn visit_block<E>(b: &blk, e: E, v: vt<E>) {
|
||||
for b.node.view_items.each |vi| {
|
||||
(v.visit_view_item)(*vi, e, v);
|
||||
}
|
||||
|
@ -429,10 +436,12 @@ pub fn visit_stmt<E>(s: @stmt, e: E, v: vt<E>) {
|
|||
|
||||
pub fn visit_decl<E>(d: @decl, e: E, v: vt<E>) {
|
||||
match d.node {
|
||||
decl_local(locs) => for locs.each |loc| {
|
||||
(v.visit_local)(*loc, e, v)
|
||||
},
|
||||
decl_item(it) => (v.visit_item)(it, e, v)
|
||||
decl_local(ref locs) => {
|
||||
for locs.each |loc| {
|
||||
(v.visit_local)(*loc, e, v)
|
||||
}
|
||||
},
|
||||
decl_item(it) => (v.visit_item)(it, e, v)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -440,7 +449,7 @@ pub fn visit_expr_opt<E>(eo: Option<@expr>, e: E, v: vt<E>) {
|
|||
match eo { None => (), Some(ex) => (v.visit_expr)(ex, e, v) }
|
||||
}
|
||||
|
||||
pub fn visit_exprs<E>(exprs: ~[@expr], e: E, v: vt<E>) {
|
||||
pub fn visit_exprs<E>(exprs: &[@expr], e: E, v: vt<E>) {
|
||||
for exprs.each |ex| { (v.visit_expr)(*ex, e, v); }
|
||||
}
|
||||
|
||||
|
@ -450,112 +459,121 @@ pub fn visit_mac<E>(_m: mac, _e: E, _v: vt<E>) {
|
|||
|
||||
pub fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) {
|
||||
match ex.node {
|
||||
expr_vstore(x, _) => (v.visit_expr)(x, e, v),
|
||||
expr_vec(es, _) => visit_exprs(es, e, v),
|
||||
expr_repeat(element, count, _) => {
|
||||
(v.visit_expr)(element, e, v);
|
||||
(v.visit_expr)(count, e, v);
|
||||
}
|
||||
expr_rec(ref flds, base) => {
|
||||
for (*flds).each |f| { (v.visit_expr)(f.node.expr, e, v); }
|
||||
visit_expr_opt(base, e, v);
|
||||
}
|
||||
expr_struct(p, ref flds, base) => {
|
||||
visit_path(p, e, v);
|
||||
for (*flds).each |f| { (v.visit_expr)(f.node.expr, e, v); }
|
||||
visit_expr_opt(base, e, v);
|
||||
}
|
||||
expr_tup(elts) => for elts.each |el| { (v.visit_expr)(*el, e, v); },
|
||||
expr_call(callee, args, _) => {
|
||||
visit_exprs(args, e, v);
|
||||
(v.visit_expr)(callee, e, v);
|
||||
}
|
||||
expr_method_call(callee, _, tys, args, _) => {
|
||||
visit_exprs(args, e, v);
|
||||
for tys.each |tp| { (v.visit_ty)(*tp, e, v); }
|
||||
(v.visit_expr)(callee, e, v);
|
||||
}
|
||||
expr_binary(_, a, b) => {
|
||||
(v.visit_expr)(a, e, v); (v.visit_expr)(b, e, v);
|
||||
}
|
||||
expr_addr_of(_, x) | expr_unary(_, x) |
|
||||
expr_loop_body(x) | expr_do_body(x) |
|
||||
expr_assert(x) => (v.visit_expr)(x, e, v),
|
||||
expr_lit(_) => (),
|
||||
expr_cast(x, t) => { (v.visit_expr)(x, e, v); (v.visit_ty)(t, e, v); }
|
||||
expr_if(x, ref b, eo) => {
|
||||
(v.visit_expr)(x, e, v);
|
||||
(v.visit_block)((*b), e, v);
|
||||
visit_expr_opt(eo, e, v);
|
||||
}
|
||||
expr_while(x, ref b) => {
|
||||
(v.visit_expr)(x, e, v);
|
||||
(v.visit_block)((*b), e, v);
|
||||
}
|
||||
expr_loop(ref b, _) => (v.visit_block)((*b), e, v),
|
||||
expr_match(x, ref arms) => {
|
||||
(v.visit_expr)(x, e, v);
|
||||
for (*arms).each |a| { (v.visit_arm)(*a, e, v); }
|
||||
}
|
||||
expr_fn(proto, ref decl, ref body, _) => {
|
||||
(v.visit_fn)(
|
||||
&fk_anon(proto),
|
||||
/* FIXME (#2543) */ copy *decl,
|
||||
*body,
|
||||
ex.span,
|
||||
ex.id,
|
||||
e,
|
||||
v
|
||||
);
|
||||
}
|
||||
expr_fn_block(ref decl, ref body) => {
|
||||
(v.visit_fn)(
|
||||
&fk_fn_block,
|
||||
/* FIXME (#2543) */ copy *decl,
|
||||
*body,
|
||||
ex.span,
|
||||
ex.id,
|
||||
e,
|
||||
v
|
||||
);
|
||||
}
|
||||
expr_block(ref b) => (v.visit_block)((*b), e, v),
|
||||
expr_assign(a, b) => {
|
||||
(v.visit_expr)(b, e, v);
|
||||
(v.visit_expr)(a, e, v);
|
||||
}
|
||||
expr_copy(a) => (v.visit_expr)(a, e, v),
|
||||
expr_swap(a, b) => { (v.visit_expr)(a, e, v); (v.visit_expr)(b, e, v); }
|
||||
expr_assign_op(_, a, b) => {
|
||||
(v.visit_expr)(b, e, v);
|
||||
(v.visit_expr)(a, e, v);
|
||||
}
|
||||
expr_field(x, _, tys) => {
|
||||
(v.visit_expr)(x, e, v);
|
||||
for tys.each |tp| { (v.visit_ty)(*tp, e, v); }
|
||||
}
|
||||
expr_index(a, b) => {
|
||||
(v.visit_expr)(a, e, v);
|
||||
(v.visit_expr)(b, e, v);
|
||||
}
|
||||
expr_path(p) => visit_path(p, e, v),
|
||||
expr_break(_) => (),
|
||||
expr_again(_) => (),
|
||||
expr_ret(eo) => visit_expr_opt(eo, e, v),
|
||||
expr_log(_, lv, x) => {
|
||||
(v.visit_expr)(lv, e, v);
|
||||
(v.visit_expr)(x, e, v);
|
||||
}
|
||||
expr_mac(ref mac) => visit_mac((*mac), e, v),
|
||||
expr_paren(x) => (v.visit_expr)(x, e, v),
|
||||
expr_vstore(x, _) => (v.visit_expr)(x, e, v),
|
||||
expr_vec(ref es, _) => visit_exprs(*es, e, v),
|
||||
expr_repeat(element, count, _) => {
|
||||
(v.visit_expr)(element, e, v);
|
||||
(v.visit_expr)(count, e, v);
|
||||
}
|
||||
expr_rec(ref flds, base) => {
|
||||
for flds.each |f| { (v.visit_expr)(f.node.expr, e, v); }
|
||||
visit_expr_opt(base, e, v);
|
||||
}
|
||||
expr_struct(p, ref flds, base) => {
|
||||
visit_path(p, e, v);
|
||||
for flds.each |f| { (v.visit_expr)(f.node.expr, e, v); }
|
||||
visit_expr_opt(base, e, v);
|
||||
}
|
||||
expr_tup(ref elts) => {
|
||||
for elts.each |el| { (v.visit_expr)(*el, e, v) }
|
||||
}
|
||||
expr_call(callee, ref args, _) => {
|
||||
visit_exprs(*args, e, v);
|
||||
(v.visit_expr)(callee, e, v);
|
||||
}
|
||||
expr_method_call(callee, _, ref tys, ref args, _) => {
|
||||
visit_exprs(*args, e, v);
|
||||
for tys.each |tp| { (v.visit_ty)(*tp, e, v); }
|
||||
(v.visit_expr)(callee, e, v);
|
||||
}
|
||||
expr_binary(_, a, b) => {
|
||||
(v.visit_expr)(a, e, v);
|
||||
(v.visit_expr)(b, e, v);
|
||||
}
|
||||
expr_addr_of(_, x) | expr_unary(_, x) |
|
||||
expr_loop_body(x) | expr_do_body(x) |
|
||||
expr_assert(x) => (v.visit_expr)(x, e, v),
|
||||
expr_lit(_) => (),
|
||||
expr_cast(x, t) => {
|
||||
(v.visit_expr)(x, e, v);
|
||||
(v.visit_ty)(t, e, v);
|
||||
}
|
||||
expr_if(x, ref b, eo) => {
|
||||
(v.visit_expr)(x, e, v);
|
||||
(v.visit_block)(b, e, v);
|
||||
visit_expr_opt(eo, e, v);
|
||||
}
|
||||
expr_while(x, ref b) => {
|
||||
(v.visit_expr)(x, e, v);
|
||||
(v.visit_block)(b, e, v);
|
||||
}
|
||||
expr_loop(ref b, _) => (v.visit_block)(b, e, v),
|
||||
expr_match(x, ref arms) => {
|
||||
(v.visit_expr)(x, e, v);
|
||||
for arms.each |a| { (v.visit_arm)(a, e, v); }
|
||||
}
|
||||
expr_fn(proto, ref decl, ref body, _) => {
|
||||
(v.visit_fn)(
|
||||
&fk_anon(proto),
|
||||
decl,
|
||||
body,
|
||||
ex.span,
|
||||
ex.id,
|
||||
e,
|
||||
v
|
||||
);
|
||||
}
|
||||
expr_fn_block(ref decl, ref body) => {
|
||||
(v.visit_fn)(
|
||||
&fk_fn_block,
|
||||
decl,
|
||||
body,
|
||||
ex.span,
|
||||
ex.id,
|
||||
e,
|
||||
v
|
||||
);
|
||||
}
|
||||
expr_block(ref b) => (v.visit_block)(b, e, v),
|
||||
expr_assign(a, b) => {
|
||||
(v.visit_expr)(b, e, v);
|
||||
(v.visit_expr)(a, e, v);
|
||||
}
|
||||
expr_copy(a) => (v.visit_expr)(a, e, v),
|
||||
expr_swap(a, b) => {
|
||||
(v.visit_expr)(a, e, v);
|
||||
(v.visit_expr)(b, e, v);
|
||||
}
|
||||
expr_assign_op(_, a, b) => {
|
||||
(v.visit_expr)(b, e, v);
|
||||
(v.visit_expr)(a, e, v);
|
||||
}
|
||||
expr_field(x, _, ref tys) => {
|
||||
(v.visit_expr)(x, e, v);
|
||||
for tys.each |tp| { (v.visit_ty)(*tp, e, v); }
|
||||
}
|
||||
expr_index(a, b) => {
|
||||
(v.visit_expr)(a, e, v);
|
||||
(v.visit_expr)(b, e, v);
|
||||
}
|
||||
expr_path(p) => visit_path(p, e, v),
|
||||
expr_break(_) => (),
|
||||
expr_again(_) => (),
|
||||
expr_ret(eo) => visit_expr_opt(eo, e, v),
|
||||
expr_log(_, lv, x) => {
|
||||
(v.visit_expr)(lv, e, v);
|
||||
(v.visit_expr)(x, e, v);
|
||||
}
|
||||
expr_mac(ref mac) => visit_mac((*mac), e, v),
|
||||
expr_paren(x) => (v.visit_expr)(x, e, v),
|
||||
}
|
||||
(v.visit_expr_post)(ex, e, v);
|
||||
}
|
||||
|
||||
pub fn visit_arm<E>(a: arm, e: E, v: vt<E>) {
|
||||
pub fn visit_arm<E>(a: &arm, e: E, v: vt<E>) {
|
||||
for a.pats.each |p| { (v.visit_pat)(*p, e, v); }
|
||||
visit_expr_opt(a.guard, e, v);
|
||||
(v.visit_block)(a.body, e, v);
|
||||
(v.visit_block)(&a.body, e, v);
|
||||
}
|
||||
|
||||
// Simpler, non-context passing interface. Always walks the whole tree, simply
|
||||
|
@ -567,18 +585,18 @@ pub struct SimpleVisitor {
|
|||
visit_foreign_item: fn@(@foreign_item),
|
||||
visit_item: fn@(@item),
|
||||
visit_local: fn@(@local),
|
||||
visit_block: fn@(ast::blk),
|
||||
visit_block: fn@(&blk),
|
||||
visit_stmt: fn@(@stmt),
|
||||
visit_arm: fn@(arm),
|
||||
visit_arm: fn@(&arm),
|
||||
visit_pat: fn@(@pat),
|
||||
visit_decl: fn@(@decl),
|
||||
visit_expr: fn@(@expr),
|
||||
visit_expr_post: fn@(@expr),
|
||||
visit_ty: fn@(@Ty),
|
||||
visit_ty_params: fn@(&[ty_param]),
|
||||
visit_fn: fn@(&fn_kind, fn_decl, blk, span, node_id),
|
||||
visit_ty_method: fn@(ty_method),
|
||||
visit_trait_method: fn@(trait_method),
|
||||
visit_fn: fn@(&fn_kind, &fn_decl, &blk, span, node_id),
|
||||
visit_ty_method: fn@(&ty_method),
|
||||
visit_trait_method: fn@(&trait_method),
|
||||
visit_struct_def: fn@(@struct_def, ident, &[ty_param], node_id),
|
||||
visit_struct_field: fn@(@struct_field),
|
||||
visit_struct_method: fn@(@method)
|
||||
|
@ -604,10 +622,10 @@ pub fn default_simple_visitor() -> @SimpleVisitor {
|
|||
visit_expr_post: |_e| { },
|
||||
visit_ty: simple_ignore_ty,
|
||||
visit_ty_params: fn@(_ps: &[ty_param]) { },
|
||||
visit_fn: fn@(_fk: &fn_kind, _d: fn_decl, _b: blk, _sp: span,
|
||||
visit_fn: fn@(_fk: &fn_kind, _d: &fn_decl, _b: &blk, _sp: span,
|
||||
_id: node_id) { },
|
||||
visit_ty_method: fn@(_m: ty_method) { },
|
||||
visit_trait_method: fn@(_m: trait_method) { },
|
||||
visit_ty_method: fn@(_m: &ty_method) { },
|
||||
visit_trait_method: fn@(_m: &trait_method) { },
|
||||
visit_struct_def: fn@(_sd: @struct_def, _nm: ident,
|
||||
_tps: &[ty_param], _id: node_id) { },
|
||||
visit_struct_field: fn@(_f: @struct_field) { },
|
||||
|
@ -644,7 +662,7 @@ pub fn mk_simple_visitor(v: simple_visitor) -> vt<()> {
|
|||
f(l);
|
||||
visit_local(l, e, v);
|
||||
}
|
||||
fn v_block(f: fn@(ast::blk), bl: ast::blk, &&e: (), v: vt<()>) {
|
||||
fn v_block(f: fn@(&blk), bl: &blk, &&e: (), v: vt<()>) {
|
||||
f(bl);
|
||||
visit_block(bl, e, v);
|
||||
}
|
||||
|
@ -652,7 +670,7 @@ pub fn mk_simple_visitor(v: simple_visitor) -> vt<()> {
|
|||
f(st);
|
||||
visit_stmt(st, e, v);
|
||||
}
|
||||
fn v_arm(f: fn@(arm), a: arm, &&e: (), v: vt<()>) {
|
||||
fn v_arm(f: fn@(&arm), a: &arm, &&e: (), v: vt<()>) {
|
||||
f(a);
|
||||
visit_arm(a, e, v);
|
||||
}
|
||||
|
@ -675,11 +693,11 @@ pub fn mk_simple_visitor(v: simple_visitor) -> vt<()> {
|
|||
f(ty);
|
||||
visit_ty(ty, e, v);
|
||||
}
|
||||
fn v_ty_method(f: fn@(ty_method), ty: ty_method, &&e: (), v: vt<()>) {
|
||||
fn v_ty_method(f: fn@(&ty_method), ty: &ty_method, &&e: (), v: vt<()>) {
|
||||
f(ty);
|
||||
visit_ty_method(ty, e, v);
|
||||
}
|
||||
fn v_trait_method(f: fn@(trait_method), m: trait_method, &&e: (),
|
||||
fn v_trait_method(f: fn@(&trait_method), m: &trait_method, &&e: (),
|
||||
v: vt<()>) {
|
||||
f(m);
|
||||
visit_trait_method(m, e, v);
|
||||
|
@ -697,9 +715,16 @@ pub fn mk_simple_visitor(v: simple_visitor) -> vt<()> {
|
|||
f(ps);
|
||||
visit_ty_params(ps, e, v);
|
||||
}
|
||||
fn v_fn(f: fn@(&fn_kind, fn_decl, blk, span, node_id),
|
||||
fk: &fn_kind, decl: fn_decl, body: blk, sp: span,
|
||||
id: node_id, &&e: (), v: vt<()>) {
|
||||
fn v_fn(
|
||||
f: fn@(&fn_kind, &fn_decl, &blk, span, node_id),
|
||||
fk: &fn_kind,
|
||||
decl: &fn_decl,
|
||||
body: &blk,
|
||||
sp: span,
|
||||
id: node_id,
|
||||
&&e: (),
|
||||
v: vt<()>
|
||||
) {
|
||||
f(fk, decl, body, sp, id);
|
||||
visit_fn(fk, decl, body, sp, id, e, v);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue