about summary refs log tree commit diff
path: root/src/libsyntax/visit.rs
diff options
context:
space:
mode:
authorJakub Bukaj <jakub@jakub.cc>2014-11-18 17:39:16 +0100
committerJakub Bukaj <jakub@jakub.cc>2014-11-18 23:07:14 +0100
commitbde225e2fafc7f593cfa5a9e1e6c750264682b71 (patch)
tree64f06c4455fbe97f90675aa9d2476cb3e504e87f /src/libsyntax/visit.rs
parentc8d6e3b2c2a780eff92299da5d1c02e081617088 (diff)
downloadrust-bde225e2fafc7f593cfa5a9e1e6c750264682b71.tar.gz
rust-bde225e2fafc7f593cfa5a9e1e6c750264682b71.zip
Feature gate non-ASCII lifetime identifiers
Fixes #19069.
Diffstat (limited to 'src/libsyntax/visit.rs')
-rw-r--r--src/libsyntax/visit.rs26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs
index efe1e18eda9..e98cc3b9c71 100644
--- a/src/libsyntax/visit.rs
+++ b/src/libsyntax/visit.rs
@@ -55,8 +55,11 @@ pub enum FnKind<'a> {
 /// new default implementation gets introduced.)
 pub trait Visitor<'v> {
 
-    fn visit_ident(&mut self, _sp: Span, _ident: Ident) {
-        /*! Visit the idents */
+    fn visit_name(&mut self, _span: Span, _name: Name) {
+        // Nothing to do.
+    }
+    fn visit_ident(&mut self, span: Span, ident: Ident) {
+        self.visit_name(span, ident.name);
     }
     fn visit_mod(&mut self, m: &'v Mod, _s: Span, _n: NodeId) { walk_mod(self, m) }
     fn visit_view_item(&mut self, i: &'v ViewItem) { walk_view_item(self, i) }
@@ -102,11 +105,11 @@ pub trait Visitor<'v> {
             None => ()
         }
     }
-    fn visit_lifetime_ref(&mut self, _lifetime: &'v Lifetime) {
-        /*! Visits a reference to a lifetime */
+    fn visit_lifetime_ref(&mut self, lifetime: &'v Lifetime) {
+        self.visit_name(lifetime.span, lifetime.name)
     }
-    fn visit_lifetime_decl(&mut self, _lifetime: &'v LifetimeDef) {
-        /*! Visits a declaration of a lifetime */
+    fn visit_lifetime_def(&mut self, lifetime: &'v LifetimeDef) {
+        walk_lifetime_def(self, lifetime)
     }
     fn visit_explicit_self(&mut self, es: &'v ExplicitSelf) {
         walk_explicit_self(self, es)
@@ -207,6 +210,14 @@ pub fn walk_local<'v, V: Visitor<'v>>(visitor: &mut V, local: &'v Local) {
     walk_expr_opt(visitor, &local.init);
 }
 
+pub fn walk_lifetime_def<'v, V: Visitor<'v>>(visitor: &mut V,
+                                              lifetime_def: &'v LifetimeDef) {
+    visitor.visit_lifetime_ref(&lifetime_def.lifetime);
+    for bound in lifetime_def.bounds.iter() {
+        visitor.visit_lifetime_ref(bound);
+    }
+}
+
 pub fn walk_explicit_self<'v, V: Visitor<'v>>(visitor: &mut V,
                                               explicit_self: &'v ExplicitSelf) {
     match explicit_self.node {
@@ -424,7 +435,7 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) {
 pub fn walk_lifetime_decls_helper<'v, V: Visitor<'v>>(visitor: &mut V,
                                                       lifetimes: &'v Vec<LifetimeDef>) {
     for l in lifetimes.iter() {
-        visitor.visit_lifetime_decl(l);
+        visitor.visit_lifetime_def(l);
     }
 }
 
@@ -555,6 +566,7 @@ pub fn walk_ty_param_bound<'v, V: Visitor<'v>>(visitor: &mut V,
 
 pub fn walk_generics<'v, V: Visitor<'v>>(visitor: &mut V, generics: &'v Generics) {
     for type_parameter in generics.ty_params.iter() {
+        visitor.visit_ident(type_parameter.span, type_parameter.ident);
         walk_ty_param_bounds_helper(visitor, &type_parameter.bounds);
         match type_parameter.default {
             Some(ref ty) => visitor.visit_ty(&**ty),