From e35c021aa44d9e86569592657f85943bae1815a5 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Thu, 1 Sep 2011 16:47:46 -0700 Subject: [PATCH] Parse "",str as istrs. Pretty print istrs as "",str. Issue #855 --- src/comp/front/attr.rs | 2 +- src/comp/syntax/ext/ident_to_str.rs | 2 +- src/comp/syntax/parse/parser.rs | 4 ++-- src/comp/syntax/print/pprust.rs | 9 +-------- 4 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/comp/front/attr.rs b/src/comp/front/attr.rs index 5d122ce771d..47e557a35e5 100644 --- a/src/comp/front/attr.rs +++ b/src/comp/front/attr.rs @@ -196,7 +196,7 @@ fn span<@T>(item: &T) -> ast::spanned { fn mk_name_value_item_str(name: ast::ident, value: &istr) -> @ast::meta_item { - let value_lit = span(ast::lit_str(value, ast::sk_rc)); + let value_lit = span(ast::lit_str(value, ast::sk_unique)); ret mk_name_value_item(name, value_lit); } diff --git a/src/comp/syntax/ext/ident_to_str.rs b/src/comp/syntax/ext/ident_to_str.rs index 298fef31ec5..d2c73bfb16f 100644 --- a/src/comp/syntax/ext/ident_to_str.rs +++ b/src/comp/syntax/ext/ident_to_str.rs @@ -20,6 +20,6 @@ fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr, ret make_new_lit(cx, sp, ast::lit_str(expr_to_ident(cx, args[0u], ~"expected an ident"), - ast::sk_rc)); + ast::sk_unique)); } diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index cf3c02cb03a..e22ebeb78d3 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -493,7 +493,7 @@ fn parse_ty(p: &parser, colons_before_params: bool) -> @ast::ty { } else if eat_word(p, ~"float") { t = ast::ty_float; } else if eat_word(p, ~"str") { - t = ast::ty_str; + t = ast::ty_istr; } else if eat_word(p, ~"istr") { t = ast::ty_istr; } else if eat_word(p, ~"char") { @@ -708,7 +708,7 @@ fn parse_lit(p: &parser) -> ast::lit { token::LIT_CHAR(c) { p.bump(); lit = ast::lit_char(c); } token::LIT_STR(s) { p.bump(); - lit = ast::lit_str(p.get_str(s), ast::sk_rc); + lit = ast::lit_str(p.get_str(s), ast::sk_unique); } token::LPAREN. { p.bump(); diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs index fa6891a0812..f1382341eb9 100644 --- a/src/comp/syntax/print/pprust.rs +++ b/src/comp/syntax/print/pprust.rs @@ -279,7 +279,7 @@ fn print_type(s: &ps, ty: &@ast::ty) { } ast::ty_char. { word(s.s, ~"char"); } ast::ty_str. { word(s.s, ~"str"); } - ast::ty_istr. { word(s.s, ~"istr"); } + ast::ty_istr. { word(s.s, ~"str"); } ast::ty_box(mt) { word(s.s, ~"@"); print_mt(s, mt); } ast::ty_vec(mt) { word(s.s, ~"["); @@ -1497,12 +1497,6 @@ fn print_literal(s: &ps, lit: &@ast::lit) { alt next_lit(s) { some(lt) { 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; @@ -1512,7 +1506,6 @@ fn print_literal(s: &ps, lit: &@ast::lit) { } alt lit.node { ast::lit_str(st, kind) { - if kind == ast::sk_unique { word(s.s, ~"~"); } print_string(s, st); } ast::lit_char(ch) {