diff options
| author | bors <bors@rust-lang.org> | 2013-08-15 04:56:06 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-08-15 04:56:06 -0700 |
| commit | 77739a70849293f67aba8ce3379e050cd319d1ce (patch) | |
| tree | 624b23133a7c34d88d6286308159e3e33444c8a0 /src/libsyntax/ext | |
| parent | 790e6bb3972c3b167a8e0314305740a20f62d2f0 (diff) | |
| parent | ef854c9b04cf916241587ea1764b86027e380e8f (diff) | |
| download | rust-77739a70849293f67aba8ce3379e050cd319d1ce.tar.gz rust-77739a70849293f67aba8ce3379e050cd319d1ce.zip | |
auto merge of #8527 : pnkfelix/rust/fsk-visitor-vpar-defaults-step1, r=nikomatsakis
Rewriting visit.rs to operate on a borrowed `&mut V` where `<V:Visitor>`
r? @nikomatsakis
r? @pcwalton
This is the first in a planned series of incremental pull requests. (There will probably be five pull requests including this one, though they can be combined or split as necessary.)
Part of #7081. (But definitely does *not* complete it, not on its own, and not even after all five parts land; there are still a few loose ends to tie up or trim afterwards.)
The bulk of this change for this particular PR is pnkfelix@3d83010, which has the changes necessary to visit.rs to support everything else that comes later. The other commits are illustrating the standard mechanical transformation that I am applying.
One important point for nearly *all* of these pull requests: I was deliberately *not* trying to be intelligent in the transformation.
* My goal was to minimize code churn, and make the transformation as mechanical as possible.
* For example, I kept the separation between the Visitor struct (corresponding to the earlier vtable of functions that were potentially closed over local state) and the explicitly passed (and clones) visitor Env. I am certain that this is almost always unnecessary, and a later task will be to go through an meld the Env's into the Visitors as appropriate. (My original goal had been to make such melding part of this task; that's why I turned them into a (Env, vtable) tuple way back when. But I digress.)
* Also, my main goal here was to get rid of the record of `@fn`'s as described by the oldvisit.rs API. (This series gets rid of all but one such case; I'm still investigating that.) There is *still* plenty of `@`-boxing left to be removed, I'm sure, and even still some `@fn`'s too; removing all of those is not the goal here; its just to get rid of the encoded protocol of `@fn`'s in the (old)visit API.
To see where things will be going in the future (i.e., to get a sneak-preview of future pull-requests in the series), see:
* https://github.com/pnkfelix/rust/commits/fsk-visitor-vpar-defaults-step1 (that's this one)
* https://github.com/pnkfelix/rust/commits/fsk-visitor-vpar-defaults-step2
* https://github.com/pnkfelix/rust/commits/fsk-visitor-vpar-defaults-step3
* https://github.com/pnkfelix/rust/commits/fsk-visitor-vpar-defaults-step4
* https://github.com/pnkfelix/rust/commits/fsk-visitor-vpar-defaults-step5
* Note that between step 4 and step 5 there is just a single commit, but its a doozy because its the only case where my mechanical transformation did not apply, and thus more serious rewriting was necessary. See commit pnkfelix@da902b2ff3b1e0bee9fc63cf00c449cceea8abf7
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 74 |
1 files changed, 37 insertions, 37 deletions
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 1547446957e..c188326a4f1 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -522,7 +522,7 @@ struct NewNameFinderContext { } impl Visitor<()> for NewNameFinderContext { - fn visit_pat(@mut self, pattern: @ast::pat, _: ()) { + fn visit_pat(&mut self, pattern: @ast::pat, _: ()) { match *pattern { // we found a pat_ident! ast::pat { @@ -548,74 +548,74 @@ impl Visitor<()> for NewNameFinderContext { } } // use the default traversal for non-pat_idents - _ => visit::visit_pat(self as @mut Visitor<()>, pattern, ()) + _ => visit::walk_pat(self, pattern, ()) } } // XXX: Methods below can become default methods. - fn visit_mod(@mut self, module: &ast::_mod, _: span, _: NodeId, _: ()) { - visit::visit_mod(self as @mut Visitor<()>, module, ()) + fn visit_mod(&mut self, module: &ast::_mod, _: span, _: NodeId, _: ()) { + visit::walk_mod(self, module, ()) } - fn visit_view_item(@mut self, view_item: &ast::view_item, _: ()) { - visit::visit_view_item(self as @mut Visitor<()>, view_item, ()) + fn visit_view_item(&mut self, view_item: &ast::view_item, _: ()) { + visit::walk_view_item(self, view_item, ()) } - fn visit_item(@mut self, item: @ast::item, _: ()) { - visit::visit_item(self as @mut Visitor<()>, item, ()) + fn visit_item(&mut self, item: @ast::item, _: ()) { + visit::walk_item(self, item, ()) } - fn visit_foreign_item(@mut self, + fn visit_foreign_item(&mut self, foreign_item: @ast::foreign_item, _: ()) { - visit::visit_foreign_item(self as @mut Visitor<()>, foreign_item, ()) + visit::walk_foreign_item(self, foreign_item, ()) } - fn visit_local(@mut self, local: @ast::Local, _: ()) { - visit::visit_local(self as @mut Visitor<()>, local, ()) + fn visit_local(&mut self, local: @ast::Local, _: ()) { + visit::walk_local(self, local, ()) } - fn visit_block(@mut self, block: &ast::Block, _: ()) { - visit::visit_block(self as @mut Visitor<()>, block, ()) + fn visit_block(&mut self, block: &ast::Block, _: ()) { + visit::walk_block(self, block, ()) } - fn visit_stmt(@mut self, stmt: @ast::stmt, _: ()) { - visit::visit_stmt(self as @mut Visitor<()>, stmt, ()) + fn visit_stmt(&mut self, stmt: @ast::stmt, _: ()) { + visit::walk_stmt(self, stmt, ()) } - fn visit_arm(@mut self, arm: &ast::arm, _: ()) { - visit::visit_arm(self as @mut Visitor<()>, arm, ()) + fn visit_arm(&mut self, arm: &ast::arm, _: ()) { + visit::walk_arm(self, arm, ()) } - fn visit_decl(@mut self, decl: @ast::decl, _: ()) { - visit::visit_decl(self as @mut Visitor<()>, decl, ()) + fn visit_decl(&mut self, decl: @ast::decl, _: ()) { + visit::walk_decl(self, decl, ()) } - fn visit_expr(@mut self, expr: @ast::expr, _: ()) { - visit::visit_expr(self as @mut Visitor<()>, expr, ()) + fn visit_expr(&mut self, expr: @ast::expr, _: ()) { + visit::walk_expr(self, expr, ()) } - fn visit_expr_post(@mut self, _: @ast::expr, _: ()) { + fn visit_expr_post(&mut self, _: @ast::expr, _: ()) { // Empty! } - fn visit_ty(@mut self, typ: &ast::Ty, _: ()) { - visit::visit_ty(self as @mut Visitor<()>, typ, ()) + fn visit_ty(&mut self, typ: &ast::Ty, _: ()) { + visit::walk_ty(self, typ, ()) } - fn visit_generics(@mut self, generics: &ast::Generics, _: ()) { - visit::visit_generics(self as @mut Visitor<()>, generics, ()) + fn visit_generics(&mut self, generics: &ast::Generics, _: ()) { + visit::walk_generics(self, generics, ()) } - fn visit_fn(@mut self, + fn visit_fn(&mut self, function_kind: &visit::fn_kind, function_declaration: &ast::fn_decl, block: &ast::Block, span: span, node_id: NodeId, _: ()) { - visit::visit_fn(self as @mut Visitor<()>, + visit::walk_fn(self, function_kind, function_declaration, block, @@ -624,23 +624,23 @@ impl Visitor<()> for NewNameFinderContext { ()) } - fn visit_ty_method(@mut self, ty_method: &ast::TypeMethod, _: ()) { - visit::visit_ty_method(self as @mut Visitor<()>, ty_method, ()) + fn visit_ty_method(&mut self, ty_method: &ast::TypeMethod, _: ()) { + visit::walk_ty_method(self, ty_method, ()) } - fn visit_trait_method(@mut self, + fn visit_trait_method(&mut self, trait_method: &ast::trait_method, _: ()) { - visit::visit_trait_method(self as @mut Visitor<()>, trait_method, ()) + visit::walk_trait_method(self, trait_method, ()) } - fn visit_struct_def(@mut self, + fn visit_struct_def(&mut self, struct_def: @ast::struct_def, ident: ident, generics: &ast::Generics, node_id: NodeId, _: ()) { - visit::visit_struct_def(self as @mut Visitor<()>, + visit::walk_struct_def(self, struct_def, ident, generics, @@ -648,10 +648,10 @@ impl Visitor<()> for NewNameFinderContext { ()) } - fn visit_struct_field(@mut self, + fn visit_struct_field(&mut self, struct_field: @ast::struct_field, _: ()) { - visit::visit_struct_field(self as @mut Visitor<()>, struct_field, ()) + visit::walk_struct_field(self, struct_field, ()) } } |
