diff options
| author | Michael Sullivan <sully@msully.net> | 2012-07-13 22:57:48 -0700 |
|---|---|---|
| committer | Michael Sullivan <sully@msully.net> | 2012-07-14 01:03:43 -0700 |
| commit | 92743dc2a6a14d042d4b278e4a4dde5ca198c886 (patch) | |
| tree | 2626211c99906387257880f127f96fee66a0bb4e /src/libsyntax/ext | |
| parent | 5c5065e8bdd1a7b28810fea4b940577ff17c112c (diff) | |
| download | rust-92743dc2a6a14d042d4b278e4a4dde5ca198c886.tar.gz rust-92743dc2a6a14d042d4b278e4a4dde5ca198c886.zip | |
Move the world over to using the new style string literals and types. Closes #2907.
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/auto_serialize.rs | 62 | ||||
| -rw-r--r-- | src/libsyntax/ext/base.rs | 70 | ||||
| -rw-r--r-- | src/libsyntax/ext/build.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/concat_idents.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/ext/env.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 22 | ||||
| -rw-r--r-- | src/libsyntax/ext/fmt.rs | 96 | ||||
| -rw-r--r-- | src/libsyntax/ext/ident_to_str.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/log_syntax.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/pipes/ast_builder.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/pipes/parse_proto.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/pipes/pipec.rs | 70 | ||||
| -rw-r--r-- | src/libsyntax/ext/qquote.rs | 85 | ||||
| -rw-r--r-- | src/libsyntax/ext/simplext.rs | 104 | ||||
| -rw-r--r-- | src/libsyntax/ext/source_util.rs | 24 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/earley_parser.rs | 40 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/macro_rules.rs | 18 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/transcribe.rs | 10 |
18 files changed, 316 insertions, 315 deletions
diff --git a/src/libsyntax/ext/auto_serialize.rs b/src/libsyntax/ext/auto_serialize.rs index d3286fbc80f..ac2829643be 100644 --- a/src/libsyntax/ext/auto_serialize.rs +++ b/src/libsyntax/ext/auto_serialize.rs @@ -84,15 +84,15 @@ mod syntax { export parse; } -type ser_tps_map = map::hashmap<str, fn@(@ast::expr) -> ~[@ast::stmt]>; -type deser_tps_map = map::hashmap<str, fn@() -> @ast::expr>; +type ser_tps_map = map::hashmap<~str, fn@(@ast::expr) -> ~[@ast::stmt]>; +type deser_tps_map = map::hashmap<~str, fn@() -> @ast::expr>; fn expand(cx: ext_ctxt, span: span, _mitem: ast::meta_item, in_items: ~[@ast::item]) -> ~[@ast::item] { fn not_auto_serialize(a: ast::attribute) -> bool { - attr::get_attr_name(a) != @"auto_serialize"/~ + attr::get_attr_name(a) != @~"auto_serialize" } fn filter_attrs(item: @ast::item) -> @ast::item { @@ -114,7 +114,7 @@ fn expand(cx: ext_ctxt, } _ { - cx.span_err(span, "#[auto_serialize] can only be \ + cx.span_err(span, ~"#[auto_serialize] can only be \ applied to type and enum \ definitions"); ~[in_item] @@ -125,11 +125,11 @@ fn expand(cx: ext_ctxt, impl helpers for ext_ctxt { fn helper_path(base_path: @ast::path, - helper_name: str) -> @ast::path { + helper_name: ~str) -> @ast::path { let head = vec::init(base_path.idents); let tail = vec::last(base_path.idents); self.path(base_path.span, - vec::append(head, ~[@(helper_name + "_" + *tail)])) + vec::append(head, ~[@(helper_name + ~"_" + *tail)])) } fn path(span: span, strs: ~[ast::ident]) -> @ast::path { @@ -154,7 +154,7 @@ impl helpers for ext_ctxt { let args = do vec::map(input_tys) |ty| { {mode: ast::expl(ast::by_ref), ty: ty, - ident: @""/~, + ident: @~"", id: self.next_id()} }; @@ -219,7 +219,7 @@ impl helpers for ext_ctxt { ast::expr_alt(v, arms, ast::alt_exhaustive))) } - fn lit_str(span: span, s: @str/~) -> @ast::expr { + fn lit_str(span: span, s: @~str) -> @ast::expr { self.expr( span, ast::expr_vstore( @@ -297,7 +297,7 @@ fn ser_path(cx: ext_ctxt, tps: ser_tps_map, path: @ast::path, cx.expr( path.span, ast::expr_path( - cx.helper_path(path, "serialize"))); + cx.helper_path(path, ~"serialize"))); let ty_args = do vec::map(path.types) |ty| { let sv_stmts = ser_ty(cx, tps, ty, cx.clone(s), #ast{ __v }); @@ -354,7 +354,7 @@ fn is_vec_or_str(ty: @ast::ty) -> bool { // This may be wrong if the user has shadowed (!) str ast::ty_path(@{span: _, global: _, idents: ids, rp: none, types: _}, _) - if ids == ~[@"str"/~] { true } + if ids == ~[@~"str"] { true } _ { false } } } @@ -392,7 +392,7 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map, } ast::ty_ptr(_) | ast::ty_rptr(_, _) { - cx.span_err(ty.span, "cannot serialize pointer types"); + cx.span_err(ty.span, ~"cannot serialize pointer types"); ~[] } @@ -414,7 +414,7 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map, } ast::ty_fn(_, _) { - cx.span_err(ty.span, "cannot serialize function types"); + cx.span_err(ty.span, ~"cannot serialize function types"); ~[] } @@ -471,12 +471,12 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map, } ast::ty_mac(_) { - cx.span_err(ty.span, "cannot serialize macro types"); + cx.span_err(ty.span, ~"cannot serialize macro types"); ~[] } ast::ty_infer { - cx.span_err(ty.span, "cannot serialize inferred types"); + cx.span_err(ty.span, ~"cannot serialize inferred types"); ~[] } @@ -503,7 +503,7 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map, } ast::ty_vstore(_, _) { - cx.span_unimpl(ty.span, "serialization for vstore types"); + cx.span_unimpl(ty.span, ~"serialization for vstore types"); } } @@ -525,7 +525,7 @@ fn mk_ser_fn(cx: ext_ctxt, span: span, name: ast::ident, ty: cx.ty_fn(span, ~[cx.ty_path(span, ~[tp.ident], ~[])], cx.ty_nil(span)), - ident: @("__s" + *tp.ident), + ident: @(~"__s" + *tp.ident), id: cx.next_id()}); #debug["tp_inputs = %?", tp_inputs]; @@ -533,12 +533,12 @@ fn mk_ser_fn(cx: ext_ctxt, span: span, name: ast::ident, let ser_inputs: ~[ast::arg] = vec::append(~[{mode: ast::expl(ast::by_ref), - ty: cx.ty_path(span, ~[@"__S"/~], ~[]), - ident: @"__s"/~, + ty: cx.ty_path(span, ~[@~"__S"], ~[]), + ident: @~"__s", id: cx.next_id()}, {mode: ast::expl(ast::by_ref), ty: v_ty, - ident: @"__v"/~, + ident: @~"__v", id: cx.next_id()}], tp_inputs); @@ -556,12 +556,12 @@ fn mk_ser_fn(cx: ext_ctxt, span: span, name: ast::ident, let ser_bnds = @~[ ast::bound_trait(cx.ty_path(span, - ~[@"std"/~, @"serialization"/~, - @"serializer"/~], + ~[@~"std", @~"serialization", + @~"serializer"], ~[]))]; let ser_tps: ~[ast::ty_param] = - vec::append(~[{ident: @"__S"/~, + vec::append(~[{ident: @~"__S", id: cx.next_id(), bounds: ser_bnds}], vec::map(tps, |tp| cx.clone_ty_param(tp))); @@ -573,7 +573,7 @@ fn mk_ser_fn(cx: ext_ctxt, span: span, name: ast::ident, let ser_blk = cx.blk(span, f(cx, tps_map, #ast{ __s }, #ast{ __v })); - @{ident: @("serialize_" + *name), + @{ident: @(~"serialize_" + *name), attrs: ~[], id: cx.next_id(), node: ast::item_fn({inputs: ser_inputs, @@ -598,7 +598,7 @@ fn deser_path(cx: ext_ctxt, tps: deser_tps_map, path: @ast::path, cx.expr( path.span, ast::expr_path( - cx.helper_path(path, "deserialize"))); + cx.helper_path(path, ~"deserialize"))); let ty_args = do vec::map(path.types) |ty| { let dv_expr = deser_ty(cx, tps, ty, cx.clone(d)); @@ -726,7 +726,7 @@ fn deser_ty(cx: ext_ctxt, tps: deser_tps_map, } ast::ty_vstore(_, _) { - cx.span_unimpl(ty.span, "deserialization for vstore types"); + cx.span_unimpl(ty.span, ~"deserialization for vstore types"); } } } @@ -746,15 +746,15 @@ fn mk_deser_fn(cx: ext_ctxt, span: span, ty: cx.ty_fn(span, ~[], cx.ty_path(span, ~[tp.ident], ~[])), - ident: @("__d" + *tp.ident), + ident: @(~"__d" + *tp.ident), id: cx.next_id()}); #debug["tp_inputs = %?", tp_inputs]; let deser_inputs: ~[ast::arg] = vec::append(~[{mode: ast::expl(ast::by_ref), - ty: cx.ty_path(span, ~[@"__D"/~], ~[]), - ident: @"__d"/~, + ty: cx.ty_path(span, ~[@~"__D"], ~[]), + ident: @~"__d", id: cx.next_id()}], tp_inputs); @@ -772,11 +772,11 @@ fn mk_deser_fn(cx: ext_ctxt, span: span, let deser_bnds = @~[ ast::bound_trait(cx.ty_path( span, - ~[@"std"/~, @"serialization"/~, @"deserializer"/~], + ~[@~"std", @~"serialization", @~"deserializer"], ~[]))]; let deser_tps: ~[ast::ty_param] = - vec::append(~[{ident: @"__D"/~, + vec::append(~[{ident: @~"__D", id: cx.next_id(), bounds: deser_bnds}], vec::map(tps, |tp| { @@ -788,7 +788,7 @@ fn mk_deser_fn(cx: ext_ctxt, span: span, let deser_blk = cx.expr_blk(f(cx, tps_map, #ast(expr){__d})); - @{ident: @("deserialize_" + *name), + @{ident: @(~"deserialize_" + *name), attrs: ~[], id: cx.next_id(), node: ast::item_fn({inputs: deser_inputs, diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 7b08b18596e..b7d17a9d652 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -42,47 +42,47 @@ enum syntax_extension { // A temporary hard-coded map of methods for expanding syntax extension // AST nodes into full ASTs -fn syntax_expander_table() -> hashmap<str, syntax_extension> { +fn syntax_expander_table() -> hashmap<~str, syntax_extension> { fn builtin(f: syntax_expander_) -> syntax_extension {normal({expander: f, span: none})} fn builtin_item_tt(f: syntax_expander_tt_item_) -> syntax_extension { item_tt({expander: f, span: none}) } let syntax_expanders = str_hash::<syntax_extension>(); - syntax_expanders.insert("macro", + syntax_expanders.insert(~"macro", macro_defining(ext::simplext::add_new_extension)); - syntax_expanders.insert("macro_rules", + syntax_expanders.insert(~"macro_rules", builtin_item_tt( ext::tt::macro_rules::add_new_extension)); - syntax_expanders.insert("fmt", builtin(ext::fmt::expand_syntax_ext)); - syntax_expanders.insert("auto_serialize", + syntax_expanders.insert(~"fmt", builtin(ext::fmt::expand_syntax_ext)); + syntax_expanders.insert(~"auto_serialize", item_decorator(ext::auto_serialize::expand)); - syntax_expanders.insert("env", builtin(ext::env::expand_syntax_ext)); - syntax_expanders.insert("concat_idents", + syntax_expanders.insert(~"env", builtin(ext::env::expand_syntax_ext)); + syntax_expanders.insert(~"concat_idents", builtin(ext::concat_idents::expand_syntax_ext)); - syntax_expanders.insert("ident_to_str", + syntax_expanders.insert(~"ident_to_str", builtin(ext::ident_to_str::expand_syntax_ext)); - syntax_expanders.insert("log_syntax", + syntax_expanders.insert(~"log_syntax", builtin(ext::log_syntax::expand_syntax_ext)); - syntax_expanders.insert("ast", + syntax_expanders.insert(~"ast", builtin(ext::qquote::expand_ast)); - syntax_expanders.insert("line", + syntax_expanders.insert(~"line", builtin(ext::source_util::expand_line)); - syntax_expanders.insert("col", + syntax_expanders.insert(~"col", builtin(ext::source_util::expand_col)); - syntax_expanders.insert("file", + syntax_expanders.insert(~"file", builtin(ext::source_util::expand_file)); - syntax_expanders.insert("stringify", + syntax_expanders.insert(~"stringify", builtin(ext::source_util::expand_stringify)); - syntax_expanders.insert("include", + syntax_expanders.insert(~"include", builtin(ext::source_util::expand_include)); - syntax_expanders.insert("include_str", + syntax_expanders.insert(~"include_str", builtin(ext::source_util::expand_include_str)); - syntax_expanders.insert("include_bin", + syntax_expanders.insert(~"include_bin", builtin(ext::source_util::expand_include_bin)); - syntax_expanders.insert("mod", + syntax_expanders.insert(~"mod", builtin(ext::source_util::expand_mod)); - syntax_expanders.insert("proto", + syntax_expanders.insert(~"proto", builtin_item_tt(ext::pipes::expand_proto)); ret syntax_expanders; } @@ -98,11 +98,11 @@ iface ext_ctxt { fn mod_path() -> ~[ast::ident]; fn bt_push(ei: codemap::expn_info_); fn bt_pop(); - fn span_fatal(sp: span, msg: str) -> !; - fn span_err(sp: span, msg: str); - fn span_unimpl(sp: span, msg: str) -> !; - fn span_bug(sp: span, msg: str) -> !; - fn bug(msg: str) -> !; + fn span_fatal(sp: span, msg: ~str) -> !; + fn span_err(sp: span, msg: ~str); + fn span_unimpl(sp: span, msg: ~str) -> !; + fn span_bug(sp: span, msg: ~str) -> !; + fn bug(msg: ~str) -> !; fn next_id() -> ast::node_id; } @@ -137,26 +137,26 @@ fn mk_ctxt(parse_sess: parse::parse_sess, some(@expanded_from({call_site: {expn_info: prev, _}, _})) { self.backtrace = prev } - _ { self.bug("tried to pop without a push"); } + _ { self.bug(~"tried to pop without a push"); } } } - fn span_fatal(sp: span, msg: str) -> ! { + fn span_fatal(sp: span, msg: ~str) -> ! { self.print_backtrace(); self.parse_sess.span_diagnostic.span_fatal(sp, msg); } - fn span_err(sp: span, msg: str) { + fn span_err(sp: span, msg: ~str) { self.print_backtrace(); self.parse_sess.span_diagnostic.span_err(sp, msg); } - fn span_unimpl(sp: span, msg: str) -> ! { + fn span_unimpl(sp: span, msg: ~str) -> ! { self.print_backtrace(); self.parse_sess.span_diagnostic.span_unimpl(sp, msg); } - fn span_bug(sp: span, msg: str) -> ! { + fn span_bug(sp: span, msg: ~str) -> ! { self.print_backtrace(); self.parse_sess.span_diagnostic.span_bug(sp, msg); } - fn bug(msg: str) -> ! { + fn bug(msg: ~str) -> ! { self.print_backtrace(); self.parse_sess.span_diagnostic.handler().bug(msg); } @@ -173,7 +173,7 @@ fn mk_ctxt(parse_sess: parse::parse_sess, ret imp as ext_ctxt } -fn expr_to_str(cx: ext_ctxt, expr: @ast::expr, error: str) -> str { +fn expr_to_str(cx: ext_ctxt, expr: @ast::expr, error: ~str) -> ~str { alt expr.node { ast::expr_lit(l) { alt l.node { @@ -185,7 +185,7 @@ fn expr_to_str(cx: ext_ctxt, expr: @ast::expr, error: str) -> str { } } -fn expr_to_ident(cx: ext_ctxt, expr: @ast::expr, error: str) -> ast::ident { +fn expr_to_ident(cx: ext_ctxt, expr: @ast::expr, error: ~str) -> ast::ident { alt expr.node { ast::expr_path(p) { if vec::len(p.types) > 0u || vec::len(p.idents) != 1u { @@ -197,12 +197,12 @@ fn expr_to_ident(cx: ext_ctxt, expr: @ast::expr, error: str) -> ast::ident { } fn get_mac_args_no_max(cx: ext_ctxt, sp: span, arg: ast::mac_arg, - min: uint, name: str) -> ~[@ast::expr] { + min: uint, name: ~str) -> ~[@ast::expr] { ret get_mac_args(cx, sp, arg, min, none, name); } fn get_mac_args(cx: ext_ctxt, sp: span, arg: ast::mac_arg, - min: uint, max: option<uint>, name: str) -> ~[@ast::expr] { + min: uint, max: option<uint>, name: ~str) -> ~[@ast::expr] { alt arg { some(expr) { alt expr.node { @@ -235,7 +235,7 @@ fn get_mac_body(cx: ext_ctxt, sp: span, args: ast::mac_body) { alt (args) { some(body) {body} - none {cx.span_fatal(sp, "missing macro body")} + none {cx.span_fatal(sp, ~"missing macro body")} } } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index a2ed799819c..5eca1e8e17c 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -77,11 +77,11 @@ fn mk_fixed_vec_e(cx: ext_ctxt, sp: span, exprs: ~[@ast::expr]) -> @ast::expr { mk_vstore_e(cx, sp, mk_base_vec_e(cx, sp, exprs), ast::vstore_fixed(none)) } -fn mk_base_str(cx: ext_ctxt, sp: span, s: str) -> @ast::expr { +fn mk_base_str(cx: ext_ctxt, sp: span, s: ~str) -> @ast::expr { let lit = ast::lit_str(@s); ret mk_lit(cx, sp, lit); } -fn mk_uniq_str(cx: ext_ctxt, sp: span, s: str) -> @ast::expr { +fn mk_uniq_str(cx: ext_ctxt, sp: span, s: ~str) -> @ast::expr { mk_vstore_e(cx, sp, mk_base_str(cx, sp, s), ast::vstore_uniq) } diff --git a/src/libsyntax/ext/concat_idents.rs b/src/libsyntax/ext/concat_idents.rs index f5d13df75d6..b3545cc635d 100644 --- a/src/libsyntax/ext/concat_idents.rs +++ b/src/libsyntax/ext/concat_idents.rs @@ -2,10 +2,10 @@ import base::*; fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - let args = get_mac_args_no_max(cx,sp,arg,1u,"concat_idents"); - let mut res = ""; + let args = get_mac_args_no_max(cx,sp,arg,1u,~"concat_idents"); + let mut res = ~""; for args.each |e| { - res += *expr_to_ident(cx, e, "expected an ident"); + res += *expr_to_ident(cx, e, ~"expected an ident"); } ret @{id: cx.next_id(), diff --git a/src/libsyntax/ext/env.rs b/src/libsyntax/ext/env.rs index 26f5bbc7715..e03fc2ce47b 100644 --- a/src/libsyntax/ext/env.rs +++ b/src/libsyntax/ext/env.rs @@ -10,14 +10,14 @@ export expand_syntax_ext; fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - let args = get_mac_args(cx, sp, arg, 1u, option::some(1u), "env"); + let args = get_mac_args(cx, sp, arg, 1u, option::some(1u), ~"env"); // FIXME (#2248): if this was more thorough it would manufacture an // option<str> rather than just an maybe-empty string. - let var = expr_to_str(cx, args[0], "#env requires a string"); + let var = expr_to_str(cx, args[0], ~"#env requires a string"); alt os::getenv(var) { - option::none { ret mk_uniq_str(cx, sp, ""); } + option::none { ret mk_uniq_str(cx, sp, ~""); } option::some(s) { ret mk_uniq_str(cx, sp, s); } } } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 05c7e6f1c5a..2a41afc9743 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -10,7 +10,7 @@ import parse::{parser, parse_expr_from_source_str, new_parser_from_tt}; import codemap::{span, expanded_from}; -fn expand_expr(exts: hashmap<str, syntax_extension>, cx: ext_ctxt, +fn expand_expr(exts: hashmap<~str, syntax_extension>, cx: ext_ctxt, e: expr_, s: span, fld: ast_fold, orig: fn@(expr_, span, ast_fold) -> (expr_, span)) -> (expr_, span) @@ -54,7 +54,7 @@ fn expand_expr(exts: hashmap<str, syntax_extension>, cx: ext_ctxt, } some(item_tt(*)) { cx.span_fatal(pth.span, - "cannot use item macros in this context"); + ~"cannot use item macros in this context"); } } } @@ -91,14 +91,14 @@ fn expand_expr(exts: hashmap<str, syntax_extension>, cx: ext_ctxt, } } - _ { cx.span_bug(mac.span, "naked syntactic bit") } + _ { cx.span_bug(mac.span, ~"naked syntactic bit") } } } _ { orig(e, s, fld) } }; } -fn expand_mod_items(exts: hashmap<str, syntax_extension>, cx: ext_ctxt, +fn expand_mod_items(exts: hashmap<~str, syntax_extension>, cx: ext_ctxt, module: ast::_mod, fld: ast_fold, orig: fn@(ast::_mod, ast_fold) -> ast::_mod) -> ast::_mod @@ -133,7 +133,7 @@ fn expand_mod_items(exts: hashmap<str, syntax_extension>, cx: ext_ctxt, } /* record module we enter for `#mod` */ -fn expand_item(exts: hashmap<str, syntax_extension>, +fn expand_item(exts: hashmap<~str, syntax_extension>, cx: ext_ctxt, &&it: @ast::item, fld: ast_fold, orig: fn@(&&@ast::item, ast_fold) -> option<@ast::item>) -> option<@ast::item> @@ -160,7 +160,7 @@ fn expand_item(exts: hashmap<str, syntax_extension>, } } -fn expand_item_mac(exts: hashmap<str, syntax_extension>, +fn expand_item_mac(exts: hashmap<~str, syntax_extension>, cx: ext_ctxt, &&it: @ast::item, fld: ast_fold) -> option<@ast::item> { alt it.node { @@ -179,7 +179,7 @@ fn expand_item_mac(exts: hashmap<str, syntax_extension>, let maybe_it = alt expanded { mr_item(it) { fld.fold_item(it) } mr_expr(e) { cx.span_fatal(pth.span, - "expr macro in item position: " + + ~"expr macro in item position: " + *extname) } mr_def(mdef) { exts.insert(*mdef.ident, mdef.ext); @@ -194,7 +194,7 @@ fn expand_item_mac(exts: hashmap<str, syntax_extension>, } } _ { - cx.span_bug(it.span, "invalid item macro invocation"); + cx.span_bug(it.span, ~"invalid item macro invocation"); } } } @@ -209,9 +209,9 @@ fn new_span(cx: ext_ctxt, sp: span) -> span { // is substantially more mature, these should move from here, into a // compiled part of libcore at very least. -fn core_macros() -> str { +fn core_macros() -> ~str { ret -"{ +~"{ #macro([#error[f, ...], log(core::error, #fmt[f, ...])]); #macro([#warn[f, ...], log(core::warn, #fmt[f, ...])]); #macro([#info[f, ...], log(core::info, #fmt[f, ...])]); @@ -231,7 +231,7 @@ fn expand_crate(parse_sess: parse::parse_sess, new_span: |a|new_span(cx, a) with *afp}; let f = make_fold(f_pre); - let cm = parse_expr_from_source_str("<core-macros>", + let cm = parse_expr_from_source_str(~"<core-macros>", @core_macros(), cfg, parse_sess); diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs index 16357ec7e26..53b5db8b6a6 100644 --- a/src/libsyntax/ext/fmt.rs +++ b/src/libsyntax/ext/fmt.rs @@ -13,17 +13,17 @@ export expand_syntax_ext; fn expand_syntax_ext(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - let args = get_mac_args_no_max(cx, sp, arg, 1u, "fmt"); + let args = get_mac_args_no_max(cx, sp, arg, 1u, ~"fmt"); let fmt = expr_to_str(cx, args[0], - "first argument to #fmt must be a string literal."); + ~"first argument to #fmt must be a string literal."); let fmtspan = args[0].span; #debug("Format string:"); log(debug, fmt); - fn parse_fmt_err_(cx: ext_ctxt, sp: span, msg: str) -> ! { + fn parse_fmt_err_(cx: ext_ctxt, sp: span, msg: ~str) -> ! { cx.span_fatal(sp, msg); } - let parse_fmt_err = fn@(s: str) -> ! { + let parse_fmt_err = fn@(s: ~str) -> ! { parse_fmt_err_(cx, fmtspan, s) }; let pieces = parse_fmt_string(fmt, parse_fmt_err); @@ -38,7 +38,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: ~[piece], args: ~[@ast::expr]) -> @ast::expr { fn make_path_vec(_cx: ext_ctxt, ident: ast::ident) -> ~[ast::ident] { - ret ~[@"extfmt"/~, @"rt"/~, ident]; + ret ~[@~"extfmt", @~"rt", ident]; } fn make_rt_path_expr(cx: ext_ctxt, sp: span, ident: ast::ident) -> @ast::expr { @@ -50,14 +50,14 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, fn make_rt_conv_expr(cx: ext_ctxt, sp: span, cnv: conv) -> @ast::expr { fn make_flags(cx: ext_ctxt, sp: span, flags: ~[flag]) -> @ast::expr { - let mut tmp_expr = make_rt_path_expr(cx, sp, @"flag_none"/~); + let mut tmp_expr = make_rt_path_expr(cx, sp, @~"flag_none"); for flags.each |f| { let fstr = alt f { - flag_left_justify { "flag_left_justify" } - flag_left_zero_pad { "flag_left_zero_pad" } - flag_space_for_sign { "flag_space_for_sign" } - flag_sign_always { "flag_sign_always" } - flag_alternate { "flag_alternate" } + flag_left_justify { ~"flag_left_justify" } + flag_left_zero_pad { ~"flag_left_zero_pad" } + flag_space_for_sign { ~"flag_space_for_sign" } + flag_sign_always { ~"flag_sign_always" } + flag_alternate { ~"flag_alternate" } }; tmp_expr = mk_binary(cx, sp, ast::bitor, tmp_expr, make_rt_path_expr(cx, sp, @fstr)); @@ -67,15 +67,15 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, fn make_count(cx: ext_ctxt, sp: span, cnt: count) -> @ast::expr { alt cnt { count_implied { - ret make_rt_path_expr(cx, sp, @"count_implied"/~); + ret make_rt_path_expr(cx, sp, @~"count_implied"); } count_is(c) { let count_lit = mk_int(cx, sp, c); - let count_is_path = make_path_vec(cx, @"count_is"/~); + let count_is_path = make_path_vec(cx, @~"count_is"); let count_is_args = ~[count_lit]; ret mk_call(cx, sp, count_is_path, count_is_args); } - _ { cx.span_unimpl(sp, "unimplemented #fmt conversion"); } + _ { cx.span_unimpl(sp, ~"unimplemented #fmt conversion"); } } } fn make_ty(cx: ext_ctxt, sp: span, t: ty) -> @ast::expr { @@ -83,13 +83,13 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, alt t { ty_hex(c) { alt c { - case_upper { rt_type = "ty_hex_upper"; } - case_lower { rt_type = "ty_hex_lower"; } + case_upper { rt_type = ~"ty_hex_upper"; } + case_lower { rt_type = ~"ty_hex_lower"; } } } - ty_bits { rt_type = "ty_bits"; } - ty_octal { rt_type = "ty_octal"; } - _ { rt_type = "ty_default"; } + ty_bits { rt_type = ~"ty_bits"; } + ty_octal { rt_type = ~"ty_octal"; } + _ { rt_type = ~"ty_default"; } } ret make_rt_path_expr(cx, sp, @rt_type); } @@ -97,10 +97,10 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, width_expr: @ast::expr, precision_expr: @ast::expr, ty_expr: @ast::expr) -> @ast::expr { ret mk_rec_e(cx, sp, - ~[{ident: @"flags"/~, ex: flags_expr}, - {ident: @"width"/~, ex: width_expr}, - {ident: @"precision"/~, ex: precision_expr}, - {ident: @"ty"/~, ex: ty_expr}]); + ~[{ident: @~"flags", ex: flags_expr}, + {ident: @~"width", ex: width_expr}, + {ident: @~"precision", ex: precision_expr}, + {ident: @~"ty", ex: ty_expr}]); } let rt_conv_flags = make_flags(cx, sp, cnv.flags); let rt_conv_width = make_count(cx, sp, cnv.width); @@ -109,9 +109,9 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, ret make_conv_rec(cx, sp, rt_conv_flags, rt_conv_width, rt_conv_precision, rt_conv_ty); } - fn make_conv_call(cx: ext_ctxt, sp: span, conv_type: str, cnv: conv, + fn make_conv_call(cx: ext_ctxt, sp: span, conv_type: ~str, cnv: conv, arg: @ast::expr) -> @ast::expr { - let fname = "conv_" + conv_type; + let fname = ~"conv_" + conv_type; let path = make_path_vec(cx, @fname); let cnv_expr = make_rt_conv_expr(cx, sp, cnv); let args = ~[cnv_expr, arg]; @@ -131,7 +131,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, _ { ret false; } } } - let unsupported = "conversion not supported in #fmt string"; + let unsupported = ~"conversion not supported in #fmt string"; alt cnv.param { option::none { } _ { cx.span_unimpl(sp, unsupported); } @@ -142,15 +142,15 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, flag_sign_always { if !is_signed_type(cnv) { cx.span_fatal(sp, - "+ flag only valid in " + - "signed #fmt conversion"); + ~"+ flag only valid in " + + ~"signed #fmt conversion"); } } flag_space_for_sign { if !is_signed_type(cnv) { cx.span_fatal(sp, - "space flag only valid in " + - "signed #fmt conversions"); + ~"space flag only valid in " + + ~"signed #fmt conversions"); } } flag_left_zero_pad { } @@ -168,27 +168,27 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, _ { cx.span_unimpl(sp, unsupported); } } alt cnv.ty { - ty_str { ret make_conv_call(cx, arg.span, "str", cnv, arg); } + ty_str { ret make_conv_call(cx, arg.span, ~"str", cnv, arg); } ty_int(sign) { alt sign { - signed { ret make_conv_call(cx, arg.span, "int", cnv, arg); } + signed { ret make_conv_call(cx, arg.span, ~"int", cnv, arg); } unsigned { - ret make_conv_call(cx, arg.span, "uint", cnv, arg); + ret make_conv_call(cx, arg.span, ~"uint", cnv, arg); } } } - ty_bool { ret make_conv_call(cx, arg.span, "bool", cnv, arg); } - ty_char { ret make_conv_call(cx, arg.span, "char", cnv, arg); } - ty_hex(_) { ret make_conv_call(cx, arg.span, "uint", cnv, arg); } - ty_bits { ret make_conv_call(cx, arg.span, "uint", cnv, arg); } - ty_octal { ret make_conv_call(cx, arg.span, "uint", cnv, arg); } - ty_float { ret make_conv_call(cx, arg.span, "float", cnv, arg); } - ty_poly { ret make_conv_call(cx, arg.span, "poly", cnv, arg); } + ty_bool { ret make_conv_call(cx, arg.span, ~"bool", cnv, arg); } + ty_char { ret make_conv_call(cx, arg.span, ~"char", cnv, arg); } + ty_hex(_) { ret make_conv_call(cx, arg.span, ~"uint", cnv, arg); } + ty_bits { ret make_conv_call(cx, arg.span, ~"uint", cnv, arg); } + ty_octal { ret make_conv_call(cx, arg.span, ~"uint", cnv, arg); } + ty_float { ret make_conv_call(cx, arg.span, ~"float", cnv, arg); } + ty_poly { ret make_conv_call(cx, arg.span, ~"poly", cnv, arg); } } } fn log_conv(c: conv) { alt c.param { - some(p) { log(debug, "param: " + int::to_str(p, 10u)); } + some(p) { log(debug, ~"param: " + int::to_str(p, 10u)); } _ { #debug("param: none"); } } for c.flags.each |f| { @@ -202,20 +202,20 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, } alt c.width { count_is(i) { log(debug, - "width: count is " + int::to_str(i, 10u)); } + ~"width: count is " + int::to_str(i, 10u)); } count_is_param(i) { log(debug, - "width: count is param " + int::to_str(i, 10u)); + ~"width: count is param " + int::to_str(i, 10u)); } count_is_next_param { #debug("width: count is next param"); } count_implied { #debug("width: count is implied"); } } alt c.precision { count_is(i) { log(debug, - "prec: count is " + int::to_str(i, 10u)); } + ~"prec: count is " + int::to_str(i, 10u)); } count_is_param(i) { log(debug, - "prec: count is param " + int::to_str(i, 10u)); + ~"prec: count is param " + int::to_str(i, 10u)); } count_is_next_param { #debug("prec: count is next param"); } count_implied { #debug("prec: count is implied"); } @@ -255,8 +255,8 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, n += 1u; if n >= nargs { cx.span_fatal(sp, - "not enough arguments to #fmt " + - "for the given format string"); + ~"not enough arguments to #fmt " + + ~"for the given format string"); } #debug("Building conversion:"); log_conv(conv); @@ -275,7 +275,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, } let arg_vec = mk_fixed_vec_e(cx, fmt_sp, piece_exprs); - ret mk_call(cx, fmt_sp, ~[@"str"/~, @"concat"/~], ~[arg_vec]); + ret mk_call(cx, fmt_sp, ~[@~"str", @~"concat"], ~[arg_vec]); } // // Local Variables: diff --git a/src/libsyntax/ext/ident_to_str.rs b/src/libsyntax/ext/ident_to_str.rs index 233089b9874..54f97912f3d 100644 --- a/src/libsyntax/ext/ident_to_str.rs +++ b/src/libsyntax/ext/ident_to_str.rs @@ -4,8 +4,8 @@ import option; fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - let args = get_mac_args(cx,sp,arg,1u,option::some(1u),"ident_to_str"); + let args = get_mac_args(cx,sp,arg,1u,option::some(1u),~"ident_to_str"); ret mk_uniq_str(cx, sp, *expr_to_ident(cx, args[0u], - "expected an ident")); + ~"expected an ident")); } diff --git a/src/libsyntax/ext/log_syntax.rs b/src/libsyntax/ext/log_syntax.rs index 06941fc5d38..70d83b164c8 100644 --- a/src/libsyntax/ext/log_syntax.rs +++ b/src/libsyntax/ext/log_syntax.rs @@ -3,11 +3,11 @@ import io::writer_util; fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - let args = get_mac_args_no_max(cx,sp,arg,0u,"log_syntax"); + let args = get_mac_args_no_max(cx,sp,arg,0u,~"log_syntax"); cx.print_backtrace(); io::stdout().write_line( str::connect(vec::map(args, - |&&ex| print::pprust::expr_to_str(ex)), ", ") + |&&ex| print::pprust::expr_to_str(ex)), ~", ") ); //trivial expression diff --git a/src/libsyntax/ext/pipes/ast_builder.rs b/src/libsyntax/ext/pipes/ast_builder.rs index fda557f15b6..cb0abe9e8e5 100644 --- a/src/libsyntax/ext/pipes/ast_builder.rs +++ b/src/libsyntax/ext/pipes/ast_builder.rs @@ -7,7 +7,7 @@ import ast::{ident, node_id}; import codemap::span; import ext::base::mk_ctxt; -fn ident(s: str) -> ast::ident { +fn ident(s: ~str) -> ast::ident { @(copy s) } diff --git a/src/libsyntax/ext/pipes/parse_proto.rs b/src/libsyntax/ext/pipes/parse_proto.rs index 4a3c9e4afec..cf29c409e6b 100644 --- a/src/libsyntax/ext/pipes/parse_proto.rs +++ b/src/libsyntax/ext/pipes/parse_proto.rs @@ -28,8 +28,8 @@ impl proto_parser for parser { }; self.bump(); let dir = alt dir { - @"send"/~ { send } - @"recv"/~ { recv } + @~"send" { send } + @~"recv" { recv } _ { fail } }; diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index e55900968e8..9406458d1ac 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -23,10 +23,10 @@ enum direction { } impl of to_str for direction { - fn to_str() -> str { + fn to_str() -> ~str { alt self { - send { "send" } - recv { "recv" } + send { ~"send" } + recv { ~"recv" } } } } @@ -68,35 +68,35 @@ impl methods for message { message(id, tys, this, next, next_tys) { let next = this.proto.get_state(next); assert next_tys.len() == next.ty_params.len(); - let arg_names = tys.mapi(|i, _ty| @("x_" + i.to_str())); + let arg_names = tys.mapi(|i, _ty| @(~"x_" + i.to_str())); let args_ast = (arg_names, tys).map( |n, t| cx.arg_mode(n, t, ast::by_copy) ); let args_ast = vec::append( - ~[cx.arg_mode(@"pipe"/~, + ~[cx.arg_mode(@~"pipe", cx.ty_path(path(this.data_name()) .add_tys(cx.ty_vars(this.ty_params))), ast::by_copy)], args_ast); let pat = alt (this.dir, next.dir) { - (send, send) { "(c, s)" } - (send, recv) { "(s, c)" } - (recv, send) { "(s, c)" } - (recv, recv) { "(c, s)" } + (send, send) { ~"(c, s)" } + (send, recv) { ~"(s, c)" } + (recv, send) { ~"(s, c)" } + (recv, recv) { ~"(c, s)" } }; let mut body = #fmt("{ let %s = pipes::entangle();\n", pat); body += #fmt("let message = %s::%s(%s);\n", *this.proto.name, *self.name(), - str::connect(vec::append_one(arg_names, @"s"/~) + str::connect(vec::append_one(arg_names, @~"s") .map(|x| *x), - ", ")); + ~", ")); body += #fmt("pipes::send(pipe, message);\n"); - body += "c }"; + body += ~"c }"; let body = cx.parse_expr(body); @@ -127,7 +127,7 @@ impl methods for state { self.messages.push(message(name, data, self, next, next_tys)); } - fn filename() -> str { + fn filename() -> ~str { (*self).proto.filename() } @@ -158,8 +158,8 @@ impl methods for state { let next_name = next.data_name(); let dir = alt this.dir { - send { @"server"/~ } - recv { @"client"/~ } + send { @~"server" } + recv { @~"client" } }; let v = cx.variant(name, @@ -190,7 +190,7 @@ impl methods for state { cx.item_ty_poly( self.data_name(), cx.ty_path( - (@"pipes"/~ + @(dir.to_str() + "_packet"/~)) + (@~"pipes" + @(dir.to_str() + ~"_packet")) .add_ty(cx.ty_path( (self.proto.name + self.data_name()) .add_tys(cx.ty_vars(self.ty_params))))), @@ -236,17 +236,17 @@ impl methods for protocol { state } - fn filename() -> str { - "proto://" + *self.name + fn filename() -> ~str { + ~"proto://" + *self.name } fn gen_init(cx: ext_ctxt) -> @ast::item { let start_state = self.states[0]; let body = alt start_state.dir { - send { cx.parse_expr("pipes::entangle()") } + send { cx.parse_expr(~"pipes::entangle()") } recv { - cx.parse_expr("{ \ + cx.parse_expr(~"{ \ let (s, c) = pipes::entangle(); \ (c, s) \ }") @@ -281,10 +281,10 @@ impl methods for protocol { } vec::push(items, - cx.item_mod(@"client"/~, + cx.item_mod(@~"client", client_states)); vec::push(items, - cx.item_mod(@"server"/~, + cx.item_mod(@~"server", server_states)); cx.item_mod(self.name, items) @@ -293,49 +293,49 @@ impl methods for protocol { iface to_source { // Takes a thing and generates a string containing rust code for it. - fn to_source() -> str; + fn to_source() -> ~str; } impl of to_source for @ast::item { - fn to_source() -> str { + fn to_source() -> ~str { item_to_str(self) } } impl of to_source for ~[@ast::item] { - fn to_source() -> str { - str::connect(self.map(|i| i.to_source()), "\n\n") + fn to_source() -> ~str { + str::connect(self.map(|i| i.to_source()), ~"\n\n") } } impl of to_source for @ast::ty { - fn to_source() -> str { + fn to_source() -> ~str { ty_to_str(self) } } impl of to_source for ~[@ast::ty] { - fn to_source() -> str { - str::connect(self.map(|i| i.to_source()), ", ") + fn to_source() -> ~str { + str::connect(self.map(|i| i.to_source()), ~", ") } } impl of to_source for ~[ast::ty_param] { - fn to_source() -> str { + fn to_source() -> ~str { pprust::typarams_to_str(self) } } impl of to_source for @ast::expr { - fn to_source() -> str { + fn to_source() -> ~str { pprust::expr_to_str(self) } } impl parse_utils for ext_ctxt { - fn parse_item(s: str) -> @ast::item { + fn parse_item(s: ~str) -> @ast::item { let res = parse::parse_item_from_source_str( - "***protocol expansion***", + ~"***protocol expansion***", @(copy s), self.cfg(), ~[], @@ -350,9 +350,9 @@ impl parse_utils for ext_ctxt { } } - fn parse_expr(s: str) -> @ast::expr { + fn parse_expr(s: ~str) -> @ast::expr { parse::parse_expr_from_source_str( - "***protocol expansion***", + ~"***protocol expansion***", @(copy s), self.cfg(), self.parse_sess()) diff --git a/src/libsyntax/ext/qquote.rs b/src/libsyntax/ext/qquote.rs index 77e67f6da20..4fd896e65bb 100644 --- a/src/libsyntax/ext/qquote.rs +++ b/src/libsyntax/ext/qquote.rs @@ -16,7 +16,7 @@ import codemap::span; type aq_ctxt = @{lo: uint, gather: dvec<{lo: uint, hi: uint, e: @ast::expr, - constr: str}>}; + constr: ~str}>}; enum fragment { from_expr(@ast::expr), from_ty(@ast::ty) @@ -27,7 +27,7 @@ iface qq_helper { fn visit(aq_ctxt, vt<aq_ctxt>); fn extract_mac() -> option<ast::mac_>; fn mk_parse_fn(ext_ctxt,span) -> @ast::expr; - fn get_fold_fn() -> str; + fn get_fold_fn() -> ~str; } impl of qq_helper for @ast::crate { @@ -36,9 +36,9 @@ impl of qq_helper for @ast::crate { fn extract_mac() -> option<ast::mac_> {fail} fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { mk_path(cx, sp, - ~[@"syntax"/~, @"ext"/~, @"qquote"/~, @"parse_crate"/~]) + ~[@~"syntax", @~"ext", @~"qquote", @~"parse_crate"]) } - fn get_fold_fn() -> str {"fold_crate"} + fn get_fold_fn() -> ~str {~"fold_crate"} } impl of qq_helper for @ast::expr { fn span() -> span {self.span} @@ -51,9 +51,9 @@ impl of qq_helper for @ast::expr { } fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { mk_path(cx, sp, - ~[@"syntax"/~, @"ext"/~, @"qquote"/~, @"parse_expr"/~]) + ~[@~"syntax", @~"ext", @~"qquote", @~"parse_expr"]) } - fn get_fold_fn() -> str {"fold_expr"} + fn get_fold_fn() -> ~str {~"fold_expr"} } impl of qq_helper for @ast::ty { fn span() -> span {self.span} @@ -66,9 +66,9 @@ impl of qq_helper for @ast::ty { } fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { mk_path(cx, sp, - ~[@"syntax"/~, @"ext"/~, @"qquote"/~, @"parse_ty"/~]) + ~[@~"syntax", @~"ext", @~"qquote", @~"parse_ty"]) } - fn get_fold_fn() -> str {"fold_ty"} + fn get_fold_fn() -> ~str {~"fold_ty"} } impl of qq_helper for @ast::item { fn span() -> span {self.span} @@ -76,9 +76,9 @@ impl of qq_helper for @ast::item { fn extract_mac() -> option<ast::mac_> {fail} fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { mk_path(cx, sp, - ~[@"syntax"/~, @"ext"/~, @"qquote"/~, @"parse_item"/~]) + ~[@~"syntax", @~"ext", @~"qquote", @~"parse_item"]) } - fn get_fold_fn() -> str {"fold_item"} + fn get_fold_fn() -> ~str {~"fold_item"} } impl of qq_helper for @ast::stmt { fn span() -> span {self.span} @@ -86,24 +86,24 @@ impl of qq_helper for @ast::stmt { fn extract_mac() -> option<ast::mac_> {fail} fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { mk_path(cx, sp, - ~[@"syntax"/~, @"ext"/~, @"qquote"/~, @"parse_stmt"/~]) + ~[@~"syntax", @~"ext", @~"qquote", @~"parse_stmt"]) } - fn get_fold_fn() -> str {"fold_stmt"} + fn get_fold_fn() -> ~str {~"fold_stmt"} } impl of qq_helper for @ast::pat { fn span() -> span {self.span} fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_pat(self, cx, v);} fn extract_mac() -> option<ast::mac_> {fail} fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { - mk_path(cx, sp, ~[@"syntax"/~, @"ext"/~, @"qquote"/~, @"parse_pat"/~]) + mk_path(cx, sp, ~[@~"syntax", @~"ext", @~"qquote", @~"parse_pat"]) } - fn get_fold_fn() -> str {"fold_pat"} + fn get_fold_fn() -> ~str {~"fold_pat"} } fn gather_anti_quotes<N: qq_helper>(lo: uint, node: N) -> aq_ctxt { - let v = @{visit_expr: |node, &&cx, v| visit_aq(node, "from_expr", cx, v), - visit_ty: |node, &&cx, v| visit_aq(node, "from_ty", cx, v) + let v = @{visit_expr: |node, &&cx, v| visit_aq(node, ~"from_expr", cx, v), + visit_ty: |node, &&cx, v| visit_aq(node, ~"from_ty", cx, v) with *default_visitor()}; let cx = @{lo:lo, gather: dvec()}; node.visit(cx, mk_vt(v)); @@ -115,7 +115,7 @@ fn gather_anti_quotes<N: qq_helper>(lo: uint, node: N) -> aq_ctxt ret cx; } -fn visit_aq<T:qq_helper>(node: T, constr: str, &&cx: aq_ctxt, v: vt<aq_ctxt>) +fn visit_aq<T:qq_helper>(node: T, constr: ~str, &&cx: aq_ctxt, v: vt<aq_ctxt>) { alt (node.extract_mac()) { some(mac_aq(sp, e)) { @@ -134,35 +134,35 @@ fn expand_ast(ecx: ext_ctxt, _sp: span, arg: ast::mac_arg, body: ast::mac_body) -> @ast::expr { - let mut what = "expr"; + let mut what = ~"expr"; do option::iter(arg) |arg| { let args: ~[@ast::expr] = alt arg.node { ast::expr_vec(elts, _) { elts } _ { ecx.span_fatal - (_sp, "#ast requires arguments of the form `~[...]`.") + (_sp, ~"#ast requires arguments of the form `~[...]`.") } }; if vec::len::<@ast::expr>(args) != 1u { - ecx.span_fatal(_sp, "#ast requires exactly one arg"); + ecx.span_fatal(_sp, ~"#ast requires exactly one arg"); } alt (args[0].node) { ast::expr_path(@{idents: id, _}) if vec::len(id) == 1u {what = *id[0]} - _ {ecx.span_fatal(args[0].span, "expected an identifier");} + _ {ecx.span_fatal(args[0].span, ~"expected an identifier");} } } let body = get_mac_body(ecx,_sp,body); ret alt what { - "crate" {finish(ecx, body, parse_crate)} - "expr" {finish(ecx, body, parse_expr)} - "ty" {finish(ecx, body, parse_ty)} - "item" {finish(ecx, body, parse_item)} - "stmt" {finish(ecx, body, parse_stmt)} - "pat" {finish(ecx, body, parse_pat)} - _ {ecx.span_fatal(_sp, "unsupported ast type")} + ~"crate" {finish(ecx, body, parse_crate)} + ~"expr" {finish(ecx, body, parse_expr)} + ~"ty" {finish(ecx, body, parse_ty)} + ~"item" {finish(ecx, body, parse_item)} + ~"stmt" {finish(ecx, body, parse_stmt)} + ~"pat" {finish(ecx, body, parse_pat)} + _ {ecx.span_fatal(_sp, ~"unsupported ast type")} }; } @@ -175,7 +175,7 @@ fn parse_pat(p: parser) -> @ast::pat { p.parse_pat() } fn parse_item(p: parser) -> @ast::item { alt p.parse_item(~[], ast::public) { some(item) { item } - none { fail "parse_item: parsing an item failed"; } + none { fail ~"parse_item: parsing an item failed"; } } } @@ -203,7 +203,7 @@ fn finish<T: qq_helper> // ^^ check that the spans are non-overlapping } - let mut str2 = ""; + let mut str2 = ~""; enum state {active, skip(uint), blank}; let mut state = active; let mut i = 0u, j = 0u; @@ -233,19 +233,19 @@ fn finish<T: qq_helper> let cx = ecx; let cfg_call = || mk_call_( - cx, sp, mk_access(cx, sp, ~[@"ext_cx"/~], @"cfg"/~), ~[]); + cx, sp, mk_access(cx, sp, ~[@~"ext_cx"], @~"cfg"), ~[]); let parse_sess_call = || mk_call_( - cx, sp, mk_access(cx, sp, ~[@"ext_cx"/~], @"parse_sess"/~), ~[]); + cx, sp, mk_access(cx, sp, ~[@~"ext_cx"], @~"parse_sess"), ~[]); let pcall = mk_call(cx,sp, - ~[@"syntax"/~, @"parse"/~, @"parser"/~, - @"parse_from_source_str"/~], + ~[@~"syntax", @~"parse", @~"parser", + @~"parse_from_source_str"], ~[node.mk_parse_fn(cx,sp), mk_uniq_str(cx,sp, fname), mk_call(cx,sp, - ~[@"syntax"/~,@"ext"/~, - @"qquote"/~, @"mk_file_substr"/~], + ~[@~"syntax",@~"ext", + @~"qquote", @~"mk_file_substr"], ~[mk_uniq_str(cx,sp, loc.file.name), mk_uint(cx,sp, loc.line), mk_uint(cx,sp, loc.col)]), @@ -257,15 +257,15 @@ fn finish<T: qq_helper> let mut rcall = pcall; if (g_len > 0u) { rcall = mk_call(cx,sp, - ~[@"syntax"/~, @"ext"/~, @"qquote"/~, @"replace"/~], + ~[@~"syntax", @~"ext", @~"qquote", @~"replace"], ~[pcall, mk_uniq_vec_e(cx,sp, qcx.gather.map_to_vec(|g| { mk_call(cx,sp, - ~[@"syntax"/~, @"ext"/~, - @"qquote"/~, @g.constr], + ~[@~"syntax", @~"ext", + @~"qquote", @g.constr], ~[g.e])})), mk_path(cx,sp, - ~[@"syntax"/~, @"ext"/~, @"qquote"/~, + ~[@~"syntax", @~"ext", @~"qquote", @node.get_fold_fn()])]); } ret rcall; @@ -326,10 +326,11 @@ fn print_expr(expr: @ast::expr) { let pp = pprust::rust_printer(stdout); pprust::print_expr(pp, expr); pp::eof(pp.s); - stdout.write_str("\n"); + stdout.write_str(~"\n"); } -fn mk_file_substr(fname: str, line: uint, col: uint) -> codemap::file_substr { +fn mk_file_substr(fname: ~str, line: uint, col: uint) -> + codemap::file_substr { codemap::fss_external({filename: fname, line: line, col: col}) } diff --git a/src/libsyntax/ext/simplext.rs b/src/libsyntax/ext/simplext.rs index 6ccbabd748e..333c510b7cd 100644 --- a/src/libsyntax/ext/simplext.rs +++ b/src/libsyntax/ext/simplext.rs @@ -35,29 +35,29 @@ enum matchable { } /* for when given an incompatible bit of AST */ -fn match_error(cx: ext_ctxt, m: matchable, expected: str) -> ! { +fn match_error(cx: ext_ctxt, m: matchable, expected: ~str) -> ! { alt m { match_expr(x) { cx.span_fatal(x.span, - "this argument is an expr, expected " + expected); + ~"this argument is an expr, expected " + expected); } match_path(x) { cx.span_fatal(x.span, - "this argument is a path, expected " + expected); + ~"this argument is a path, expected " + expected); } match_ident(x) { cx.span_fatal(x.span, - "this argument is an ident, expected " + expected); + ~"this argument is an ident, expected " + expected); } match_ty(x) { cx.span_fatal(x.span, - "this argument is a type, expected " + expected); + ~"this argument is a type, expected " + expected); } match_block(x) { cx.span_fatal(x.span, - "this argument is a block, expected " + expected); + ~"this argument is a block, expected " + expected); } - match_exact { cx.bug("what is a match_exact doing in a bindings?"); } + match_exact { cx.bug(~"what is a match_exact doing in a bindings?"); } } } @@ -80,7 +80,7 @@ fn elts_to_ell(cx: ext_ctxt, elts: ~[@expr]) -> alt m.node { ast::mac_ellipsis { if res != none { - cx.span_fatal(m.span, "only one ellipsis allowed"); + cx.span_fatal(m.span, ~"only one ellipsis allowed"); } res = some({pre: vec::slice(elts, 0u, idx - 1u), @@ -234,8 +234,8 @@ fn follow_for_trans(cx: ext_ctxt, mmaybe: option<arb_depth<matchable>>, ret alt follow(m, idx_path) { seq(_, sp) { cx.span_fatal(sp, - "syntax matched under ... but not " + - "used that way.") + ~"syntax matched under ... but not " + + ~"used that way.") } leaf(m) { ret some(m) } } @@ -302,8 +302,8 @@ fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], alt repeat { none { cx.span_fatal(repeat_me.span, - "'...' surrounds an expression without any" + - " repeating syntax variables"); + ~"'...' surrounds an expression without any" + + ~" repeating syntax variables"); } some({rep_count: rc, _}) { /* Whew, we now know how how many times to repeat */ @@ -331,7 +331,7 @@ fn transcribe_ident(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], &&i: ident, _fld: ast_fold) -> ident { ret alt follow_for_trans(cx, b.find(i), idx_path) { some(match_ident(a_id)) { a_id.node } - some(m) { match_error(cx, m, "an identifier") } + some(m) { match_error(cx, m, ~"an identifier") } none { i } } } @@ -347,7 +347,7 @@ fn transcribe_path(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], rp: none, types: ~[]} } some(match_path(a_pth)) { *a_pth } - some(m) { match_error(cx, m, "a path") } + some(m) { match_error(cx, m, ~"a path") } none { p } } } @@ -374,7 +374,7 @@ fn transcribe_expr(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], } some(match_path(a_pth)) { (expr_path(a_pth), s) } some(match_expr(a_exp)) { (a_exp.node, a_exp.span) } - some(m) { match_error(cx, m, "an expression") } + some(m) { match_error(cx, m, ~"an expression") } none { orig(e, s, fld) } } } @@ -393,7 +393,7 @@ fn transcribe_type(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], some(id) { alt follow_for_trans(cx, b.find(id), idx_path) { some(match_ty(ty)) { (ty.node, ty.span) } - some(m) { match_error(cx, m, "a type") } + some(m) { match_error(cx, m, ~"a type") } none { orig(t, s, fld) } } } @@ -424,7 +424,7 @@ fn transcribe_block(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], // possibly allow promotion of ident/path/expr to blocks? some(m) { - match_error(cx, m, "a block") + match_error(cx, m, ~"a block") } none { orig(blk, s, fld) } } @@ -455,12 +455,12 @@ fn p_t_s_rec(cx: ext_ctxt, m: matchable, s: selector, b: binders) { if vec::len(post) > 0u { cx.span_unimpl(e.span, - "matching after `...` not yet supported"); + ~"matching after `...` not yet supported"); } } {pre: pre, rep: none, post: post} { if post != ~[] { - cx.bug("elts_to_ell provided an invalid result"); + cx.bug(~"elts_to_ell provided an invalid result"); } p_t_s_r_length(cx, vec::len(pre), false, s, b); p_t_s_r_actual_vector(cx, pre, false, s, b); @@ -478,7 +478,7 @@ fn p_t_s_rec(cx: ext_ctxt, m: matchable, s: selector, b: binders) { match_expr(e) { if e == pat { some(leaf(match_exact)) } else { none } } - _ { cx.bug("broken traversal in p_t_s_r") } + _ { cx.bug(~"broken traversal in p_t_s_r") } } } b.literal_ast_matchers.push(|x| select(cx, x, e)); @@ -486,7 +486,7 @@ fn p_t_s_rec(cx: ext_ctxt, m: matchable, s: selector, b: binders) { } } _ { - cx.bug("undocumented invariant in p_t_s_rec"); + cx.bug(~"undocumented invariant in p_t_s_rec"); } } } @@ -517,11 +517,11 @@ fn p_t_s_r_path(cx: ext_ctxt, p: @path, s: selector, b: binders) { fn select(cx: ext_ctxt, m: matchable) -> match_result { ret alt m { match_expr(e) { some(leaf(specialize_match(m))) } - _ { cx.bug("broken traversal in p_t_s_r") } + _ { cx.bug(~"broken traversal in p_t_s_r") } } } if b.real_binders.contains_key(p_id) { - cx.span_fatal(p.span, "duplicate binding identifier"); + cx.span_fatal(p.span, ~"duplicate binding identifier"); } b.real_binders.insert(p_id, compose_sels(s, |x| select(cx, x))); } @@ -546,16 +546,16 @@ fn p_t_s_r_mac(cx: ext_ctxt, mac: ast::mac, s: selector, b: binders) { match_expr(e) { alt e.node { expr_mac(mac) { fn_m(mac) } _ { none } } } - _ { cx.bug("broken traversal in p_t_s_r") } + _ { cx.bug(~"broken traversal in p_t_s_r") } } } - fn no_des(cx: ext_ctxt, sp: span, syn: str) -> ! { - cx.span_fatal(sp, "destructuring " + syn + " is not yet supported"); + fn no_des(cx: ext_ctxt, sp: span, syn: ~str) -> ! { + cx.span_fatal(sp, ~"destructuring " + syn + ~" is not yet supported"); } alt mac.node { - ast::mac_ellipsis { cx.span_fatal(mac.span, "misused `...`"); } - ast::mac_invoc(_, _, _) { no_des(cx, mac.span, "macro calls"); } - ast::mac_invoc_tt(_, _) { no_des(cx, mac.span, "macro calls"); } + ast::mac_ellipsis { cx.span_fatal(mac.span, ~"misused `...`"); } + ast::mac_invoc(_, _, _) { no_des(cx, mac.span, ~"macro calls"); } + ast::mac_invoc_tt(_, _) { no_des(cx, mac.span, ~"macro calls"); } ast::mac_embed_type(ty) { alt ty.node { ast::ty_path(pth, _) { @@ -571,10 +571,10 @@ fn p_t_s_r_mac(cx: ext_ctxt, mac: ast::mac, s: selector, b: binders) { let final_step = |x| select_pt_1(cx, x, select_pt_2); b.real_binders.insert(id, compose_sels(s, final_step)); } - none { no_des(cx, pth.span, "under `#<>`"); } + none { no_des(cx, pth.span, ~"under `#<>`"); } } } - _ { no_des(cx, ty.span, "under `#<>`"); } + _ { no_des(cx, ty.span, ~"under `#<>`"); } } } ast::mac_embed_block(blk) { @@ -591,11 +591,11 @@ fn p_t_s_r_mac(cx: ext_ctxt, mac: ast::mac, s: selector, b: binders) { let final_step = |x| select_pt_1(cx, x, select_pt_2); b.real_binders.insert(id, compose_sels(s, final_step)); } - none { no_des(cx, blk.span, "under `#{}`"); } + none { no_des(cx, blk.span, ~"under `#{}`"); } } } - ast::mac_aq(_,_) { no_des(cx, mac.span, "antiquotes"); } - ast::mac_var(_) { no_des(cx, mac.span, "antiquote variables"); } + ast::mac_aq(_,_) { no_des(cx, mac.span, ~"antiquotes"); } + ast::mac_var(_) { no_des(cx, mac.span, ~"antiquote variables"); } } } @@ -621,7 +621,7 @@ fn p_t_s_r_ellipses(cx: ext_ctxt, repeat_me: @expr, offset: uint, s: selector, _ { none } } } - _ { cx.bug("broken traversal in p_t_s_r") } + _ { cx.bug(~"broken traversal in p_t_s_r") } } } p_t_s_rec(cx, match_expr(repeat_me), @@ -666,7 +666,7 @@ fn p_t_s_r_actual_vector(cx: ext_ctxt, elts: ~[@expr], _repeat_after: bool, _ { none } } } - _ { cx.bug("broken traversal in p_t_s_r") } + _ { cx.bug(~"broken traversal in p_t_s_r") } } } p_t_s_rec(cx, match_expr(elts[idx]), @@ -677,17 +677,17 @@ fn p_t_s_r_actual_vector(cx: ext_ctxt, elts: ~[@expr], _repeat_after: bool, fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body) -> base::macro_def { - let args = get_mac_args_no_max(cx, sp, arg, 0u, "macro"); + let args = get_mac_args_no_max(cx, sp, arg, 0u, ~"macro"); - let mut macro_name: option<@str/~> = none; + let mut macro_name: option<@~str> = none; let mut clauses: ~[@clause] = ~[]; for args.each |arg| { alt arg.node { expr_vec(elts, mutbl) { if vec::len(elts) != 2u { cx.span_fatal((*arg).span, - "extension clause must consist of ~[" + - "macro invocation, expansion body]"); + ~"extension clause must consist of ~[" + + ~"macro invocation, expansion body]"); } @@ -702,21 +702,21 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, some(other_id) { if id != other_id { cx.span_fatal(pth.span, - "macro name must be " + - "consistent"); + ~"macro name must be " + + ~"consistent"); } } } } none { cx.span_fatal(pth.span, - "macro name must not be a path"); + ~"macro name must not be a path"); } } let arg = alt invoc_arg { some(arg) { arg } none { cx.span_fatal(mac.span, - "macro must have arguments")} + ~"macro must have arguments")} }; vec::push(clauses, @{params: pattern_to_selectors(cx, arg), @@ -726,21 +726,21 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, // the macro arg situation) } _ { - cx.span_bug(mac.span, "undocumented invariant in \ + cx.span_bug(mac.span, ~"undocumented invariant in \ add_extension"); } } } _ { cx.span_fatal(elts[0u].span, - "extension clause must" + - " start with a macro invocation."); + ~"extension clause must" + + ~" start with a macro invocation."); } } } _ { cx.span_fatal((*arg).span, - "extension must be ~[clause, " + " ...]"); + ~"extension must be ~[clause, " + ~" ...]"); } } } @@ -751,8 +751,8 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, alt macro_name { some(id) { id } none { - cx.span_fatal(sp, "macro definition must have " + - "at least one clause") + cx.span_fatal(sp, ~"macro definition must have " + + ~"at least one clause") } }, ext: normal({expander: ext, span: some(option::get(arg).span)})}; @@ -762,7 +762,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, clauses: ~[@clause]) -> @expr { let arg = alt arg { some(arg) { arg } - none { cx.span_fatal(sp, "macro must have arguments")} + none { cx.span_fatal(sp, ~"macro must have arguments")} }; for clauses.each |c| { alt use_selectors_to_bind(c.params, arg) { @@ -770,7 +770,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, none { again; } } } - cx.span_fatal(sp, "no clauses match macro invocation"); + cx.span_fatal(sp, ~"no clauses match macro invocation"); } } diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index 3ba1a7b159e..ff7fedde34e 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -16,7 +16,7 @@ export expand_include_bin; /* #line(): expands to the current line number */ fn expand_line(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - get_mac_args(cx, sp, arg, 0u, option::some(0u), "line"); + get_mac_args(cx, sp, arg, 0u, option::some(0u), ~"line"); let loc = codemap::lookup_char_pos(cx.codemap(), sp.lo); ret mk_uint(cx, sp, loc.line); } @@ -24,7 +24,7 @@ fn expand_line(cx: ext_ctxt, sp: span, arg: ast::mac_arg, /* #col(): expands to the current column number */ fn expand_col(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - get_mac_args(cx, sp, arg, 0u, option::some(0u), "col"); + get_mac_args(cx, sp, arg, 0u, option::some(0u), ~"col"); let loc = codemap::lookup_char_pos(cx.codemap(), sp.lo); ret mk_uint(cx, sp, loc.col); } @@ -34,7 +34,7 @@ fn expand_col(cx: ext_ctxt, sp: span, arg: ast::mac_arg, * out if we wanted. */ fn expand_file(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - get_mac_args(cx, sp, arg, 0u, option::some(0u), "file"); + get_mac_args(cx, sp, arg, 0u, option::some(0u), ~"file"); let { file: @{ name: filename, _ }, _ } = codemap::lookup_char_pos(cx.codemap(), sp.lo); ret mk_uniq_str(cx, sp, filename); @@ -42,21 +42,21 @@ fn expand_file(cx: ext_ctxt, sp: span, arg: ast::mac_arg, fn expand_stringify(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - let args = get_mac_args(cx, sp, arg, 1u, option::some(1u), "stringify"); + let args = get_mac_args(cx, sp, arg, 1u, option::some(1u), ~"stringify"); ret mk_uniq_str(cx, sp, pprust::expr_to_str(args[0])); } fn expand_mod(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - get_mac_args(cx, sp, arg, 0u, option::some(0u), "file"); + get_mac_args(cx, sp, arg, 0u, option::some(0u), ~"file"); ret mk_uniq_str(cx, sp, - str::connect(cx.mod_path().map(|x|*x), "::")); + str::connect(cx.mod_path().map(|x|*x), ~"::")); } fn expand_include(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - let args = get_mac_args(cx, sp, arg, 1u, option::some(1u), "include"); - let file = expr_to_str(cx, args[0], "#include_str requires a string"); + let args = get_mac_args(cx, sp, arg, 1u, option::some(1u), ~"include"); + let file = expr_to_str(cx, args[0], ~"#include_str requires a string"); let p = parse::new_parser_from_file(cx.parse_sess(), cx.cfg(), res_rel_file(cx, sp, file), parse::parser::SOURCE_FILE); @@ -65,9 +65,9 @@ fn expand_include(cx: ext_ctxt, sp: span, arg: ast::mac_arg, fn expand_include_str(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - let args = get_mac_args(cx,sp,arg,1u,option::some(1u),"include_str"); + let args = get_mac_args(cx,sp,arg,1u,option::some(1u),~"include_str"); - let file = expr_to_str(cx, args[0], "#include_str requires a string"); + let file = expr_to_str(cx, args[0], ~"#include_str requires a string"); let res = io::read_whole_file_str(res_rel_file(cx, sp, file)); alt res { @@ -82,9 +82,9 @@ fn expand_include_str(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, fn expand_include_bin(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - let args = get_mac_args(cx,sp,arg,1u,option::some(1u),"include_bin"); + let args = get_mac_args(cx,sp,arg,1u,option::some(1u),~"include_bin"); - let file = expr_to_str(cx, args[0], "#include_bin requires a string"); + let file = expr_to_str(cx, args[0], ~"#include_bin requires a string"); alt io::read_whole_file(res_rel_file(cx, sp, file)) { result::ok(src) { diff --git a/src/libsyntax/ext/tt/earley_parser.rs b/src/libsyntax/ext/tt/earley_parser.rs index f830330e182..3f604aafb3d 100644 --- a/src/libsyntax/ext/tt/earley_parser.rs +++ b/src/libsyntax/ext/tt/earley_parser.rs @@ -83,7 +83,7 @@ fn nameize(p_s: parse_sess, ms: ~[matcher], res: ~[@arb_depth]) } {node: mtc_bb(bind_name, _, idx), span: sp} { if ret_val.contains_key(bind_name) { - p_s.span_diagnostic.span_fatal(sp, "Duplicated bind name: " + p_s.span_diagnostic.span_fatal(sp, ~"Duplicated bind name: " + *bind_name) } ret_val.insert(bind_name, res[idx]); @@ -97,7 +97,7 @@ fn nameize(p_s: parse_sess, ms: ~[matcher], res: ~[@arb_depth]) enum parse_result { success(hashmap<ident, @arb_depth>), - failure(codemap::span, str) + failure(codemap::span, ~str) } fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) @@ -207,9 +207,9 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) nameize(sess, ms, vec::map(eof_eis[0u].matches, |dv| dv.pop()))); } else if eof_eis.len() > 1u { - ret failure(sp, "Ambiguity: multiple successful parses"); + ret failure(sp, ~"Ambiguity: multiple successful parses"); } else { - ret failure(sp, "Unexpected end of macro invocation"); + ret failure(sp, ~"Unexpected end of macro invocation"); } } else { if (bb_eis.len() > 0u && next_eis.len() > 0u) @@ -217,13 +217,13 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) let nts = str::connect(vec::map(bb_eis, |ei| { alt ei.elts[ei.idx].node { mtc_bb(_,name,_) { *name } _ { fail; } } - }), " or "); + }), ~" or "); ret failure(sp, #fmt[ "Local ambiguity: multiple parsing options: \ built-in NTs %s or %u other options.", nts, next_eis.len()]); } else if (bb_eis.len() == 0u && next_eis.len() == 0u) { - ret failure(sp, "No rules expected the token " + ret failure(sp, ~"No rules expected the token " + to_str(*rdr.interner(), tok)); } else if (next_eis.len() > 0u) { /* Now process the next token */ @@ -259,32 +259,32 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) } } -fn parse_nt(p: parser, name: str) -> whole_nt { +fn parse_nt(p: parser, name: ~str) -> whole_nt { alt name { - "item" { alt p.parse_item(~[], ast::public) { + ~"item" { alt p.parse_item(~[], ast::public) { some(i) { token::w_item(i) } - none { p.fatal("expected an item keyword") } + none { p.fatal(~"expected an item keyword") } }} - "block" { token::w_block(p.parse_block()) } - "stmt" { token::w_stmt(p.parse_stmt(~[])) } - "pat" { token::w_pat(p.parse_pat()) } - "expr" { token::w_expr(p.parse_expr()) } - "ty" { token::w_ty(p.parse_ty(false /* no need to disambiguate*/)) } + ~"block" { token::w_block(p.parse_block()) } + ~"stmt" { token::w_stmt(p.parse_stmt(~[])) } + ~"pat" { token::w_pat(p.parse_pat()) } + ~"expr" { token::w_expr(p.parse_expr()) } + ~"ty" { token::w_ty(p.parse_ty(false /* no need to disambiguate*/)) } // this could be handled like a token, since it is one - "ident" { alt copy p.token { + ~"ident" { alt copy p.token { token::IDENT(sn,b) { p.bump(); token::w_ident(sn,b) } - _ { p.fatal("expected ident, found " + _ { p.fatal(~"expected ident, found " + token::to_str(*p.reader.interner(), copy p.token)) } } } - "path" { token::w_path(p.parse_path_with_tps(false)) } - "tt" { + ~"path" { token::w_path(p.parse_path_with_tps(false)) } + ~"tt" { p.quote_depth += 1u; //but in theory, non-quoted tts might be useful let res = token::w_tt(@p.parse_token_tree()); p.quote_depth -= 1u; res } - "mtcs" { token::w_mtcs(p.parse_matchers()) } - _ { p.fatal("Unsupported builtin nonterminal parser: " + name)} + ~"mtcs" { token::w_mtcs(p.parse_matchers()) } + _ { p.fatal(~"Unsupported builtin nonterminal parser: " + name)} } } diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index b454dcfc0be..7bed3107f53 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -18,9 +18,9 @@ fn add_new_extension(cx: ext_ctxt, sp: span, name: ident, let argument_gram = ~[ ms(mtc_rep(~[ - ms(mtc_bb(@"lhs"/~,@"mtcs"/~, 0u)), + ms(mtc_bb(@~"lhs",@~"mtcs", 0u)), ms(mtc_tok(FAT_ARROW)), - ms(mtc_bb(@"rhs"/~,@"tt"/~, 1u)), + ms(mtc_bb(@~"rhs",@~"tt", 1u)), ], some(SEMI), false))]; let arg_reader = new_tt_reader(cx.parse_sess().span_diagnostic, @@ -31,20 +31,20 @@ fn add_new_extension(cx: ext_ctxt, sp: span, name: ident, failure(sp, msg) { cx.span_fatal(sp, msg); } }; - let lhses = alt arguments.get(@"lhs"/~) { + let lhses = alt arguments.get(@~"lhs") { @seq(s, sp) { s } - _ { cx.span_bug(sp, "wrong-structured lhs") } + _ { cx.span_bug(sp, ~"wrong-structured lhs") } }; - let rhses = alt arguments.get(@"rhs"/~) { + let rhses = alt arguments.get(@~"rhs") { @seq(s, sp) { s } - _ { cx.span_bug(sp, "wrong-structured rhs") } + _ { cx.span_bug(sp, ~"wrong-structured rhs") } }; fn generic_extension(cx: ext_ctxt, sp: span, arg: ~[ast::token_tree], lhses: ~[@arb_depth], rhses: ~[@arb_depth]) -> mac_result { let mut best_fail_spot = {lo: 0u, hi: 0u, expn_info: none}; - let mut best_fail_msg = "internal error: ran no matchers"; + let mut best_fail_msg = ~"internal error: ran no matchers"; let s_d = cx.parse_sess().span_diagnostic; let itr = cx.parse_sess().interner; @@ -57,7 +57,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, name: ident, success(m) { let rhs = alt rhses[i] { @leaf(w_tt(@tt)) { tt } - _ { cx.span_bug(sp, "bad thing in rhs") } + _ { cx.span_bug(sp, ~"bad thing in rhs") } }; let trncbr = new_tt_reader(s_d, itr, some(m), ~[rhs]); let p = parser(cx.parse_sess(), cx.cfg(), @@ -71,7 +71,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, name: ident, } } } - _ { cx.bug("non-matcher found in parsed lhses"); } + _ { cx.bug(~"non-matcher found in parsed lhses"); } } } cx.span_fatal(best_fail_spot, best_fail_msg); diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index df0c39bb266..a9bc124b605 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -25,7 +25,7 @@ type tt_frame = @{ type tt_reader = @{ sp_diag: span_handler, - interner: @interner<@str/~>, + interner: @interner<@~str>, mut cur: tt_frame, /* for MBE-style macro transcription */ interpolations: std::map::hashmap<ident, @arb_depth>, @@ -39,7 +39,7 @@ type tt_reader = @{ /** This can do Macro-By-Example transcription. On the other hand, if * `src` contains no `tt_dotdotdot`s and `tt_interpolate`s, `interp` can (and * should) be none. */ -fn new_tt_reader(sp_diag: span_handler, itr: @interner<@str/~>, +fn new_tt_reader(sp_diag: span_handler, itr: @interner<@~str>, interp: option<std::map::hashmap<ident,@arb_depth>>, src: ~[ast::token_tree]) -> tt_reader { @@ -93,7 +93,7 @@ fn lookup_cur_ad(r: tt_reader, name: ident) -> @arb_depth { lookup_cur_ad_by_ad(r, r.interpolations.get(name)) } enum lis { - lis_unconstrained, lis_constraint(uint, ident), lis_contradiction(str) + lis_unconstrained, lis_constraint(uint, ident), lis_contradiction(~str) } fn lockstep_iter_size(&&t: token_tree, &&r: tt_reader) -> lis { @@ -183,7 +183,7 @@ fn tt_next_token(&&r: tt_reader) -> {tok: token, sp: span} { lis_unconstrained { r.sp_diag.span_fatal( sp, /* blame macro writer */ - "attempted to repeat an expression containing no syntax \ + ~"attempted to repeat an expression containing no syntax \ variables matched as repeating at this depth"); } lis_contradiction(msg) { /* FIXME #2887 blame macro invoker @@ -200,7 +200,7 @@ fn tt_next_token(&&r: tt_reader) -> {tok: token, sp: span} { if !zerok { r.sp_diag.span_fatal(sp, /* FIXME #2887 blame invoker */ - "this must repeat at least \ + ~"this must repeat at least \ once"); } /* we need to pop before we proceed, so recur */ |
