summary refs log tree commit diff
path: root/src/comp/syntax
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-08-23 11:08:31 -0700
committerBrian Anderson <banderson@mozilla.com>2011-08-23 11:09:38 -0700
commit7b12924813912b4f8ca196ae3cd0c87985d6961e (patch)
treed73b6ec20290aa763b7e65c0182ef0239347a005 /src/comp/syntax
parentc274d16b7fdac7a1006dd43a1e27c54c46285540 (diff)
downloadrust-7b12924813912b4f8ca196ae3cd0c87985d6961e.tar.gz
rust-7b12924813912b4f8ca196ae3cd0c87985d6961e.zip
Fix pretty-printing of istr literals. Issue #855
Diffstat (limited to 'src/comp/syntax')
-rw-r--r--src/comp/syntax/parse/parser.rs3
-rw-r--r--src/comp/syntax/print/pprust.rs12
2 files changed, 13 insertions, 2 deletions
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs
index 527f6927010..495d1372d79 100644
--- a/src/comp/syntax/parse/parser.rs
+++ b/src/comp/syntax/parse/parser.rs
@@ -886,10 +886,11 @@ fn parse_bottom_expr(p: &parser) -> @ast::expr {
         p.bump();
         alt p.peek() {
           token::LIT_STR(s) {
+            let sp = p.get_span();
             p.bump();
             let lit =
                 @{node: ast::lit_str(p.get_str(s), ast::sk_unique),
-                  span: p.get_span()};
+                  span: sp};
             ex = ast::expr_lit(lit);
           }
           _ { ex = ast::expr_uniq(parse_expr(p)); }
diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs
index f0848fbdce5..2165be225b8 100644
--- a/src/comp/syntax/print/pprust.rs
+++ b/src/comp/syntax/print/pprust.rs
@@ -1468,7 +1468,17 @@ fn print_literal(s: &ps, lit: &@ast::lit) {
     maybe_print_comment(s, lit.span.lo);
     alt next_lit(s) {
       some(lt) {
-        if lt.pos == lit.span.lo { word(s.s, lt.lit); s.cur_lit += 1u; ret; }
+        if lt.pos == lit.span.lo {
+            // FIXME: This is a hack until istrs replace strings, since
+            // istrs are prefixed with a token that is not part of the literal
+            alt lit.node {
+              ast::lit_str(_, ast::sk_unique.) { word(s.s, "~"); }
+              _ { }
+            }
+            word(s.s, lt.lit);
+            s.cur_lit += 1u;
+            ret;
+        }
       }
       _ { }
     }