diff options
| author | Felix S. Klock II <pnkfelix@pnkfx.org> | 2014-05-12 18:58:23 +0200 |
|---|---|---|
| committer | Felix S. Klock II <pnkfelix@pnkfx.org> | 2014-05-15 10:55:02 +0200 |
| commit | d6cf0dfbab35f40abaef345024701ff8112ed2d8 (patch) | |
| tree | 77b2c6ca9a79229480e771cf02cfb17b73af394f /src/libsyntax/visit.rs | |
| parent | 73a68cdba0d6e5ee28c9ef1ae80ec473f16cd9e9 (diff) | |
| download | rust-d6cf0dfbab35f40abaef345024701ff8112ed2d8.tar.gz rust-d6cf0dfbab35f40abaef345024701ff8112ed2d8.zip | |
syntax::visit: pub `walk_explicit_self` so impls can call it as defaults do.
drive-by: added some doc.
Diffstat (limited to 'src/libsyntax/visit.rs')
| -rw-r--r-- | src/libsyntax/visit.rs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index f820fbd784a..ce10d0db3ba 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -61,7 +61,17 @@ pub fn generics_of_fn(fk: &FnKind) -> Generics { } } +/// Each method of the Visitor trait is a hook to be potentially +/// overriden. Each method's default implementation recursively visits +/// the substructure of the input via the corresponding `walk` method; +/// e.g. the `visit_mod` method by default calls `visit::walk_mod`. +/// +/// If you want to ensure that your code handles every variant +/// explicitly, you need to override each method. (And you also need +/// to monitor future changes to `Visitor` in case a new method with a +/// new default implementation gets introduced.) pub trait Visitor<E: Clone> { + fn visit_ident(&mut self, _sp: Span, _ident: Ident, _e: E) { /*! Visit the idents */ } @@ -179,9 +189,9 @@ pub fn walk_local<E: Clone, V: Visitor<E>>(visitor: &mut V, local: &Local, env: } } -fn walk_explicit_self<E: Clone, V: Visitor<E>>(visitor: &mut V, - explicit_self: &ExplicitSelf, - env: E) { +pub fn walk_explicit_self<E: Clone, V: Visitor<E>>(visitor: &mut V, + explicit_self: &ExplicitSelf, + env: E) { match explicit_self.node { SelfStatic | SelfValue | SelfUniq => {} SelfRegion(ref lifetime, _) => { |
