about summary refs log tree commit diff
path: root/src/libsyntax/visit.rs
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2014-08-11 09:32:26 -0700
committerPatrick Walton <pcwalton@mimiga.net>2014-08-14 14:14:26 -0700
commit604af3f6c0be6ea428a55cfcb303fa1cd1c7958d (patch)
tree5d4c22c593c4701b829fdaad19e55ff803c84de7 /src/libsyntax/visit.rs
parenta8c8e3f80fd0355b2bb91337c6ad0bb0a38d5485 (diff)
downloadrust-604af3f6c0be6ea428a55cfcb303fa1cd1c7958d.tar.gz
rust-604af3f6c0be6ea428a55cfcb303fa1cd1c7958d.zip
librustc: Implement simple `where` clauses.
These `where` clauses are accepted everywhere generics are currently
accepted and desugar during type collection to the type parameter bounds
we have today.

A new keyword, `where`, has been added. Therefore, this is a breaking
change. Change uses of `where` to other identifiers.

[breaking-change]
Diffstat (limited to 'src/libsyntax/visit.rs')
-rw-r--r--src/libsyntax/visit.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs
index 18cbf797d03..ac1dbdc439c 100644
--- a/src/libsyntax/visit.rs
+++ b/src/libsyntax/visit.rs
@@ -27,6 +27,7 @@
 use abi::Abi;
 use ast::*;
 use ast;
+use ast_util;
 use codemap::Span;
 use parse;
 use owned_slice::OwnedSlice;
@@ -58,12 +59,7 @@ pub fn generics_of_fn(fk: &FnKind) -> Generics {
         FkMethod(_, generics, _) => {
             (*generics).clone()
         }
-        FkFnBlock(..) => {
-            Generics {
-                lifetimes: Vec::new(),
-                ty_params: OwnedSlice::empty(),
-            }
-        }
+        FkFnBlock(..) => ast_util::empty_generics(),
     }
 }
 
@@ -559,7 +555,11 @@ pub fn walk_generics<E: Clone, V: Visitor<E>>(visitor: &mut V,
             None => {}
         }
     }
-    walk_lifetime_decls(visitor, &generics.lifetimes, env);
+    walk_lifetime_decls(visitor, &generics.lifetimes, env.clone());
+    for predicate in generics.where_clause.predicates.iter() {
+        visitor.visit_ident(predicate.span, predicate.ident, env.clone());
+        walk_ty_param_bounds(visitor, &predicate.bounds, env.clone());
+    }
 }
 
 pub fn walk_fn_decl<E: Clone, V: Visitor<E>>(visitor: &mut V,