summary refs log tree commit diff
path: root/src/libsyntax/print/pprust.rs
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2014-11-07 06:53:45 -0500
committerNiko Matsakis <niko@alum.mit.edu>2014-11-07 15:51:30 -0500
commit244231720d29db856c5a28c0dda6c2efd7c9219a (patch)
tree41648e7c6c16102a7a602be441b4f1cdad8e7411 /src/libsyntax/print/pprust.rs
parentc18a1327e3ccf02ae9f755ca280d53177eeb298d (diff)
downloadrust-244231720d29db856c5a28c0dda6c2efd7c9219a.tar.gz
rust-244231720d29db856c5a28c0dda6c2efd7c9219a.zip
Update parser with `for` syntax
Diffstat (limited to 'src/libsyntax/print/pprust.rs')
-rw-r--r--src/libsyntax/print/pprust.rs31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index 63e2c5499e8..5b57a875c4a 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -743,6 +743,9 @@ impl<'a> State<'a> {
             ast::TyPath(ref path, ref bounds, _) => {
                 try!(self.print_bounded_path(path, bounds));
             }
+            ast::TyPolyTraitRef(ref poly_trait_ref) => {
+                try!(self.print_poly_trait_ref(&**poly_trait_ref));
+            }
             ast::TyQPath(ref qpath) => {
                 try!(word(&mut self.s, "<"));
                 try!(self.print_type(&*qpath.for_type));
@@ -960,7 +963,7 @@ impl<'a> State<'a> {
                 try!(self.print_ident(item.ident));
                 try!(self.print_generics(generics));
                 match unbound {
-                    &Some(TraitTyParamBound(ref tref)) => {
+                    &Some(ref tref) => {
                         try!(space(&mut self.s));
                         try!(self.word_space("for"));
                         try!(self.print_trait_ref(tref));
@@ -995,19 +998,21 @@ impl<'a> State<'a> {
     }
 
     fn print_trait_ref(&mut self, t: &ast::TraitRef) -> IoResult<()> {
-        if t.lifetimes.len() > 0 {
-            try!(self.print_generics(&ast::Generics {
-                lifetimes: t.lifetimes.clone(),
-                ty_params: OwnedSlice::empty(),
-                where_clause: ast::WhereClause {
-                    id: ast::DUMMY_NODE_ID,
-                    predicates: Vec::new(),
-                },
-            }));
-        }
         self.print_path(&t.path, false)
     }
 
+    fn print_poly_trait_ref(&mut self, t: &ast::PolyTraitRef) -> IoResult<()> {
+        if !t.bound_lifetimes.is_empty() {
+            try!(word(&mut self.s, "for<"));
+            for lifetime_def in t.bound_lifetimes.iter() {
+                try!(self.print_lifetime_def(lifetime_def));
+            }
+            try!(word(&mut self.s, ">"));
+        }
+
+        self.print_trait_ref(&t.trait_ref)
+    }
+
     pub fn print_enum_def(&mut self, enum_definition: &ast::EnumDef,
                           generics: &ast::Generics, ident: ast::Ident,
                           span: codemap::Span,
@@ -2383,7 +2388,7 @@ impl<'a> State<'a> {
 
                 try!(match *bound {
                     TraitTyParamBound(ref tref) => {
-                        self.print_trait_ref(tref)
+                        self.print_poly_trait_ref(tref)
                     }
                     RegionTyParamBound(ref lt) => {
                         self.print_lifetime(lt)
@@ -2450,7 +2455,7 @@ impl<'a> State<'a> {
 
     pub fn print_ty_param(&mut self, param: &ast::TyParam) -> IoResult<()> {
         match param.unbound {
-            Some(TraitTyParamBound(ref tref)) => {
+            Some(ref tref) => {
                 try!(self.print_trait_ref(tref));
                 try!(self.word_space("?"));
             }