]> git.lizzy.rs Git - rust.git/commitdiff
pp: also print bounds in paths with no generic params
authorBenjamin Herr <ben@0x539.de>
Tue, 17 Sep 2013 20:13:47 +0000 (22:13 +0200)
committerBenjamin Herr <ben@0x539.de>
Tue, 17 Sep 2013 21:41:42 +0000 (23:41 +0200)
Since 3b6314c3 the pretty printer seems to only print trait bounds for
`ast::ty_path(...)`s that have a generics arguments list. That seems
wrong, so let's always print them.

Closes #9253, un-xfails test for #7673.

src/libsyntax/print/pprust.rs
src/test/pretty/path-type-bounds.rs [new file with mode: 0644]
src/test/run-pass/issue-7673-cast-generically-implemented-trait.rs

index ec84cbda97360392abce5a27964b7940a2f2894a..b5868cbc63db09a0b16135f4b9c9be3eba91e193 100644 (file)
@@ -1535,15 +1535,15 @@ fn print_path_(s: @ps,
 
         print_ident(s, segment.identifier);
 
-        if segment.lifetime.is_some() || !segment.types.is_empty() {
-            // If this is the last segment, print the bounds.
-            if i == path.segments.len() - 1 {
-                match *opt_bounds {
-                    None => {}
-                    Some(ref bounds) => print_bounds(s, bounds, true),
-                }
+        // If this is the last segment, print the bounds.
+        if i == path.segments.len() - 1 {
+            match *opt_bounds {
+                None => {}
+                Some(ref bounds) => print_bounds(s, bounds, true),
             }
+        }
 
+        if segment.lifetime.is_some() || !segment.types.is_empty() {
             if colons_before_params {
                 word(s.s, "::")
             }
diff --git a/src/test/pretty/path-type-bounds.rs b/src/test/pretty/path-type-bounds.rs
new file mode 100644 (file)
index 0000000..a62fbde
--- /dev/null
@@ -0,0 +1,13 @@
+// pp-exact
+
+trait Tr { }
+impl Tr for int;
+
+fn foo(x: ~Tr: Freeze) -> ~Tr: Freeze { x }
+
+fn main() {
+    let x: ~Tr: Freeze;
+
+    ~1 as ~Tr: Freeze;
+}
+
index 1492b5895bae59e75c7e02f9934787f4cc33c32e..2f2b736294a5e115c3349c5fc1339f2d60d51e6a 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// xfail-pretty #9253 pretty printer doesn't preserve the bounds on trait objects
-
 /*
 
 #7673 Polymorphically creating traits barely works