about summary refs log tree commit diff
path: root/src/libsyntax/print
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-03-26 19:32:01 -0700
committerbors <bors@rust-lang.org>2014-03-26 19:32:01 -0700
commitc329a17461b29da3c9f004154d32e4f153d727df (patch)
treef30825fe03a00cb0d9740372e386a31bc9e6fd56 /src/libsyntax/print
parentc83994e0f492d5e416537cb7ce1063662c0e44e7 (diff)
parent8118406ecf1fedf2949e8e6fa014086ac7b557e8 (diff)
downloadrust-c329a17461b29da3c9f004154d32e4f153d727df.tar.gz
rust-c329a17461b29da3c9f004154d32e4f153d727df.zip
auto merge of #13079 : alexcrichton/rust/colons, r=cmr
The previous syntax was `Foo:Bound<trait-parameters>`, but this is a little
ambiguous because it was being parsed as `Foo: (Bound<trait-parameters)` rather
than `Foo: (Bound) <trait-parameters>`

This commit changes the syntax to `Foo<trait-parameters>: Bound` in order to be
clear where the trait parameters are going.

Closes #9265
Diffstat (limited to 'src/libsyntax/print')
-rw-r--r--src/libsyntax/print/pprust.rs16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index e1d6f821ba9..6309f83abdd 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -1526,7 +1526,7 @@ impl<'a> State<'a> {
         }
 
         let mut first = true;
-        for (i, segment) in path.segments.iter().enumerate() {
+        for segment in path.segments.iter() {
             if first {
                 first = false
             } else {
@@ -1535,14 +1535,6 @@ impl<'a> State<'a> {
 
             try!(self.print_ident(segment.identifier));
 
-            // If this is the last segment, print the bounds.
-            if i == path.segments.len() - 1 {
-                match *opt_bounds {
-                    None => {}
-                    Some(ref bounds) => try!(self.print_bounds(bounds, true)),
-                }
-            }
-
             if !segment.lifetimes.is_empty() || !segment.types.is_empty() {
                 if colons_before_params {
                     try!(word(&mut self.s, "::"))
@@ -1571,7 +1563,11 @@ impl<'a> State<'a> {
                 try!(word(&mut self.s, ">"))
             }
         }
-        Ok(())
+
+        match *opt_bounds {
+            None => Ok(()),
+            Some(ref bounds) => self.print_bounds(bounds, true),
+        }
     }
 
     fn print_path(&mut self, path: &ast::Path,