diff options
| author | bors <bors@rust-lang.org> | 2014-05-15 02:41:50 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-05-15 02:41:50 -0700 |
| commit | fedffa785eb1def61d012e8e614d562afaf19a6e (patch) | |
| tree | 6b35c03df2a7c7d04399858d49b9a589575866e3 /src/libsyntax | |
| parent | 579e0a5f5555ed926cf9378ef61b034b0c316e76 (diff) | |
| parent | 5236af8c0ff33d60e30fdde367b476a1efa1d09e (diff) | |
| download | rust-fedffa785eb1def61d012e8e614d562afaf19a6e.tar.gz rust-fedffa785eb1def61d012e8e614d562afaf19a6e.zip | |
auto merge of #14145 : pnkfelix/rust/fsk-better-svh-via-visitor, r=alexcrichton
Teach SVH computation to ignore more implementation artifacts.
In particular, this version of strict version hash (SVH) works much
like the deriving(Hash)-based implementation did, except that it
deliberately:
1. skips over content known not affect the generated crates, and,
2. uses a content-based hash for names instead of using the value of
the `Name` index itself, which can differ depending on the order
in which strings are interned (which in turn is affected by
e.g. the presence of `--cfg` options on the command line).
Fix #14132.
Diffstat (limited to 'src/libsyntax')
| -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, _) => { |
