about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMichael Sullivan <sully@msully.net>2012-07-13 15:24:41 -0700
committerMichael Sullivan <sully@msully.net>2012-07-13 17:03:54 -0700
commitf5e69d611e83c392cb83837ed3e6e440cc180d63 (patch)
tree3f18cfd3461f8e2b777e2a15f2ba13f457158bf6 /src
parent985b52be6df504ce6dcef29df61ea20ab9c9323f (diff)
Change the pretty printer to print vstores for strs in prefix notation.
Diffstat (limited to 'src')
-rw-r--r--src/libsyntax/print/pprust.rs26
-rw-r--r--src/rustc/util/ppaux.rs18
-rw-r--r--src/test/compile-fail/bad-const-type.rs2
-rw-r--r--src/test/compile-fail/binop-bitxor-str.rs2
-rw-r--r--src/test/compile-fail/fail-type-err.rs2
-rw-r--r--src/test/compile-fail/map-types.rs2
-rw-r--r--src/test/compile-fail/minus-string.rs2
-rw-r--r--src/test/compile-fail/missing-do.rs2
8 files changed, 27 insertions, 29 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index c802e40dd05..c0cbf78c5cf 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -379,18 +379,15 @@ fn print_type_ex(s: ps, &&ty: @ast::ty, print_colons: bool) {
         word(s.s, constrs_str(cs, ty_constr_to_str));
       }
       ast::ty_vstore(t, v) {
-        // If it is a vector, print it in prefix notation.
-        // Someday it will all be like this.
-        let is_fixed = alt v { ast::vstore_fixed(_) { true } _ { false } };
-        alt t.node {
-          ast::ty_vec(*) if !is_fixed {
-            print_vstore(s, v);
+        alt v {
+          ast::vstore_fixed(_) {
             print_type(s, t);
+            word(s.s, "/");
+            print_vstore(s, v);
           }
           _ {
-            print_type(s, t);
-            word(s.s, "/");
             print_vstore(s, v);
+            print_type(s, t);
           }
         }
       }
@@ -888,18 +885,15 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
     s.ann.pre(ann_node);
     alt expr.node {
       ast::expr_vstore(e, v) {
-        // If it is a vector, print it in prefix notation.
-        // Someday it will all be like this.
-        let is_fixed = alt v { ast::vstore_fixed(_) { true } _ { false } };
-        alt e.node {
-          ast::expr_vec(*) if !is_fixed {
-            print_vstore(s, v);
+        alt v {
+          ast::vstore_fixed(_) {
             print_expr(s, e);
+            word(s.s, "/");
+            print_vstore(s, v);
           }
           _ {
-            print_expr(s, e);
-            word(s.s, "/");
             print_vstore(s, v);
+            print_expr(s, e);
           }
         }
       }
diff --git a/src/rustc/util/ppaux.rs b/src/rustc/util/ppaux.rs
index 91edf4bb0d7..01593ecea2c 100644
--- a/src/rustc/util/ppaux.rs
+++ b/src/rustc/util/ppaux.rs
@@ -100,6 +100,15 @@ fn vstore_to_str(cx: ctxt, vs: ty::vstore) -> str {
     }
 }
 
+fn vstore_ty_to_str(cx: ctxt, ty: str, vs: ty::vstore) -> str {
+    alt vs {
+      ty::vstore_fixed(_) {
+        #fmt["%s/%s", ty, vstore_to_str(cx, vs)]
+      }
+      _ { #fmt["%s%s", vstore_to_str(cx, vs), ty] }
+    }
+}
+
 fn tys_to_str(cx: ctxt, ts: ~[t]) -> str {
     let mut rs = "";
     for ts.each |t| { rs += ty_to_str(cx, t); }
@@ -223,14 +232,9 @@ fn ty_to_str(cx: ctxt, typ: t) -> str {
         parameterized(cx, base, substs.self_r, substs.tps)
       }
       ty_evec(mt, vs) {
-        alt vs {
-          ty::vstore_fixed(_) {
-            #fmt["[%s]/%s", mt_to_str(cx, mt), vstore_to_str(cx, vs)]
-          }
-          _ { #fmt["%s[%s]", vstore_to_str(cx, vs), mt_to_str(cx, mt)] }
-        }
+        vstore_ty_to_str(cx, #fmt["[%s]", mt_to_str(cx, mt)], vs)
       }
-      ty_estr(vs) { #fmt["str/%s", vstore_to_str(cx, vs)] }
+      ty_estr(vs) { vstore_ty_to_str(cx, "str", vs) }
       ty_opaque_box { "@?" }
       ty_constr(t, _) { "@?" }
       ty_opaque_closure_ptr(ck_block) { "closure&" }
diff --git a/src/test/compile-fail/bad-const-type.rs b/src/test/compile-fail/bad-const-type.rs
index 8b86db098e5..7c0601e7aa6 100644
--- a/src/test/compile-fail/bad-const-type.rs
+++ b/src/test/compile-fail/bad-const-type.rs
@@ -1,4 +1,4 @@
-// error-pattern:expected `str/~` but found `int`
+// error-pattern:expected `~str` but found `int`
 
 const i: str = 10i;
 fn main() { log(debug, i); }
diff --git a/src/test/compile-fail/binop-bitxor-str.rs b/src/test/compile-fail/binop-bitxor-str.rs
index 53bb7d8f53d..b698eb7c426 100644
--- a/src/test/compile-fail/binop-bitxor-str.rs
+++ b/src/test/compile-fail/binop-bitxor-str.rs
@@ -1,3 +1,3 @@
-// error-pattern:^ cannot be applied to type `str/~`
+// error-pattern:^ cannot be applied to type `~str`
 
 fn main() { let x = "a" ^ "b"; }
diff --git a/src/test/compile-fail/fail-type-err.rs b/src/test/compile-fail/fail-type-err.rs
index 3f9bda61c80..e3324cb59b4 100644
--- a/src/test/compile-fail/fail-type-err.rs
+++ b/src/test/compile-fail/fail-type-err.rs
@@ -1,2 +1,2 @@
-// error-pattern:expected `str/~` but found `~[int]`
+// error-pattern:expected `~str` but found `~[int]`
 fn main() { fail ~[0i]; }
diff --git a/src/test/compile-fail/map-types.rs b/src/test/compile-fail/map-types.rs
index 9386c152648..b929ab0a1ce 100644
--- a/src/test/compile-fail/map-types.rs
+++ b/src/test/compile-fail/map-types.rs
@@ -8,5 +8,5 @@ import std::map::map;
 fn main() {
     let x: map<str,str> = map::str_hash::<str>() as map::<str,str>;
     let y: map<uint,str> = x;
-    //~^ ERROR mismatched types: expected `std::map::map<uint,str/~>`
+    //~^ ERROR mismatched types: expected `std::map::map<uint,~str>`
 }
diff --git a/src/test/compile-fail/minus-string.rs b/src/test/compile-fail/minus-string.rs
index 043d46f121b..00037ce0fda 100644
--- a/src/test/compile-fail/minus-string.rs
+++ b/src/test/compile-fail/minus-string.rs
@@ -1,3 +1,3 @@
-// error-pattern:cannot apply unary operator `-` to type `str/~`
+// error-pattern:cannot apply unary operator `-` to type `~str`
 
 fn main() { -"foo"; }
diff --git a/src/test/compile-fail/missing-do.rs b/src/test/compile-fail/missing-do.rs
index 31595875058..a54c5961d55 100644
--- a/src/test/compile-fail/missing-do.rs
+++ b/src/test/compile-fail/missing-do.rs
@@ -3,7 +3,7 @@
 fn foo(f: fn()) { f() }
 
 fn main() {
-    "" || 42; //~ ERROR binary operation || cannot be applied to type `str/~`
+    "" || 42; //~ ERROR binary operation || cannot be applied to type `~str`
     foo || {}; //~ ERROR binary operation || cannot be applied to type `extern fn(fn())`
     //~^ NOTE did you forget the 'do' keyword for the call?
 }