about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libsyntax/visit.rs19
-rw-r--r--src/test/run-pass/associated-types-resolve-lifetime.rs22
2 files changed, 33 insertions, 8 deletions
diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs
index 3535c6e267e..cf3efeeeb8f 100644
--- a/src/libsyntax/visit.rs
+++ b/src/libsyntax/visit.rs
@@ -555,14 +555,18 @@ pub fn walk_ty_param_bound<'v, V: Visitor<'v>>(visitor: &mut V,
     }
 }
 
+pub fn walk_ty_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v TyParam) {
+    visitor.visit_ident(param.span, param.ident);
+    walk_ty_param_bounds_helper(visitor, &param.bounds);
+    match param.default {
+        Some(ref ty) => visitor.visit_ty(&**ty),
+        None => {}
+    }
+}
+
 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),
-            None => {}
-        }
+        walk_ty_param(visitor, type_parameter);
     }
     walk_lifetime_decls_helper(visitor, &generics.lifetimes);
     for predicate in generics.where_clause.predicates.iter() {
@@ -665,8 +669,7 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_method: &'v Tr
         RequiredMethod(ref method_type) => visitor.visit_ty_method(method_type),
         ProvidedMethod(ref method) => walk_method_helper(visitor, &**method),
         TypeTraitItem(ref associated_type) => {
-            visitor.visit_ident(associated_type.ty_param.span,
-                                associated_type.ty_param.ident)
+            walk_ty_param(visitor, &associated_type.ty_param);
         }
     }
 }
diff --git a/src/test/run-pass/associated-types-resolve-lifetime.rs b/src/test/run-pass/associated-types-resolve-lifetime.rs
new file mode 100644
index 00000000000..1be09e1e068
--- /dev/null
+++ b/src/test/run-pass/associated-types-resolve-lifetime.rs
@@ -0,0 +1,22 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(associated_types)]
+
+trait Get<T> {
+    fn get(&self) -> T;
+}
+
+trait Trait<'a> {
+    type T: 'static;
+    type U: Get<&'a int>;
+}
+
+fn main() {}