]> git.lizzy.rs Git - rust.git/commit
Refactored syntax::fold.
authorMarvin Löbel <loebel.marvin@gmail.com>
Fri, 25 Jul 2014 19:00:33 +0000 (21:00 +0200)
committerMarvin Löbel <loebel.marvin@gmail.com>
Tue, 29 Jul 2014 10:31:53 +0000 (12:31 +0200)
commit26a39f23ce09b64c9718f3ee6535f7ca4e84c7e7
treeb54eabb2937ee9571f13f55edde2712d285f6e29
parent7375f4d842884b255be33c267651da48dac961f6
Refactored syntax::fold.

Prior to this, the code there had a few issues:

- Default implementations inconsistently either had the prefix `noop_` or
  not.
- Some default methods where implemented in terms of a public noop function
  for user code to call, others where implemented directly on the trait
  and did not allow users of the trait to reuse the code.
- Some of the default implementations where private, and thus not reusable
  for other implementors.
- There where some bugs where default implementations called other default
  implementations directly, rather than to the underlying Folder, with the
  result of some AST nodes never being visited even if the user implemented that
  method. (For example, the current Folder never folded struct fields)

This commit solves this situation somewhat radically by making _all_
`fold_...` functions in the module into Folder methods, and implementing
them all in terms of public `noop_...` functions for other implementors to
call out to.

Some public functions had to be renamed to fit the new system, so this is a
breaking change.

[breaking-change]
src/librustc/front/config.rs
src/libsyntax/ast.rs
src/libsyntax/ast_map/mod.rs
src/libsyntax/ext/expand.rs
src/libsyntax/fold.rs