Convert rustc::syntax::ext::base to istrs. Issue #855

This commit is contained in:
Brian Anderson 2011-08-27 16:52:00 -07:00
parent 9857048929
commit 7efbfea8d0
7 changed files with 87 additions and 82 deletions

View file

@ -9,7 +9,7 @@ import codemap;
type syntax_expander = type syntax_expander =
fn(&ext_ctxt, span, @ast::expr, &option::t<istr>) -> @ast::expr; fn(&ext_ctxt, span, @ast::expr, &option::t<istr>) -> @ast::expr;
type macro_def = {ident: str, ext: syntax_extension}; type macro_def = {ident: istr, ext: syntax_extension};
type macro_definer = type macro_definer =
fn(&ext_ctxt, span, @ast::expr, &option::t<istr>) -> macro_def; fn(&ext_ctxt, span, @ast::expr, &option::t<istr>) -> macro_def;
@ -36,9 +36,9 @@ fn syntax_expander_table() -> hashmap<istr, syntax_extension> {
} }
obj ext_ctxt(sess: @session, obj ext_ctxt(sess: @session,
crate_file_name_hack: str, crate_file_name_hack: istr,
mutable backtrace: codemap::opt_span) { mutable backtrace: codemap::opt_span) {
fn crate_file_name() -> str { ret crate_file_name_hack; } fn crate_file_name() -> istr { ret crate_file_name_hack; }
fn session() -> @session { ret sess; } fn session() -> @session { ret sess; }
@ -58,29 +58,29 @@ obj ext_ctxt(sess: @session,
let tmp = pre; let tmp = pre;
backtrace = tmp; backtrace = tmp;
} }
_ { 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: istr) -> ! {
self.print_backtrace(); self.print_backtrace();
sess.span_fatal(sp, istr::from_estr(msg)); sess.span_fatal(sp, msg);
} }
fn span_err(sp: span, msg: str) { fn span_err(sp: span, msg: istr) {
self.print_backtrace(); self.print_backtrace();
sess.span_err(sp, istr::from_estr(msg)); sess.span_err(sp, msg);
} }
fn span_unimpl(sp: span, msg: str) -> ! { fn span_unimpl(sp: span, msg: istr) -> ! {
self.print_backtrace(); self.print_backtrace();
sess.span_unimpl(sp, istr::from_estr(msg)); sess.span_unimpl(sp, msg);
} }
fn span_bug(sp: span, msg: str) -> ! { fn span_bug(sp: span, msg: istr) -> ! {
self.print_backtrace(); self.print_backtrace();
sess.span_bug(sp, istr::from_estr(msg)); sess.span_bug(sp, msg);
} }
fn bug(msg: str) -> ! { fn bug(msg: istr) -> ! {
self.print_backtrace(); self.print_backtrace();
sess.bug(istr::from_estr(msg)); sess.bug(msg);
} }
fn next_id() -> ast::node_id { ret sess.next_node_id(); } fn next_id() -> ast::node_id { ret sess.next_node_id(); }
@ -96,15 +96,15 @@ fn mk_ctxt(sess: &session) -> ext_ctxt {
// super-ugly and needs a better solution. // super-ugly and needs a better solution.
let crate_file_name_hack = sess.get_codemap().files[0].name; let crate_file_name_hack = sess.get_codemap().files[0].name;
ret ext_ctxt(@sess, istr::to_estr(crate_file_name_hack), ret ext_ctxt(@sess, crate_file_name_hack,
codemap::os_none); codemap::os_none);
} }
fn expr_to_str(cx: &ext_ctxt, expr: @ast::expr, error: str) -> str { fn expr_to_str(cx: &ext_ctxt, expr: @ast::expr, error: &istr) -> istr {
alt expr.node { alt expr.node {
ast::expr_lit(l) { ast::expr_lit(l) {
alt l.node { alt l.node {
ast::lit_str(s, _) { ret istr::to_estr(s); } ast::lit_str(s, _) { ret s; }
_ { cx.span_fatal(l.span, error); } _ { cx.span_fatal(l.span, error); }
} }
} }
@ -112,7 +112,8 @@ 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: &istr) -> ast::ident {
alt expr.node { alt expr.node {
ast::expr_path(p) { ast::expr_path(p) {
if vec::len(p.node.types) > 0u || vec::len(p.node.idents) != 1u { if vec::len(p.node.types) > 0u || vec::len(p.node.idents) != 1u {

View file

@ -8,12 +8,12 @@ fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr,
alt arg.node { alt arg.node {
ast::expr_vec(elts, _) { elts } ast::expr_vec(elts, _) { elts }
_ { _ {
cx.span_fatal(sp, "#concat_idents requires a vector argument .") cx.span_fatal(sp, ~"#concat_idents requires a vector argument .")
} }
}; };
let res: ast::ident = ~""; let res: ast::ident = ~"";
for e: @ast::expr in args { for e: @ast::expr in args {
res += expr_to_ident(cx, e, "expected an ident"); res += expr_to_ident(cx, e, ~"expected an ident");
} }
ret @{id: cx.next_id(), ret @{id: cx.next_id(),

View file

@ -17,17 +17,17 @@ fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr,
alt arg.node { alt arg.node {
ast::expr_vec(elts, _) { elts } ast::expr_vec(elts, _) { elts }
_ { _ {
cx.span_fatal(sp, "#env requires arguments of the form `[...]`.") cx.span_fatal(sp, ~"#env requires arguments of the form `[...]`.")
} }
}; };
if vec::len::<@ast::expr>(args) != 1u { if vec::len::<@ast::expr>(args) != 1u {
cx.span_fatal(sp, "malformed #env call"); cx.span_fatal(sp, ~"malformed #env call");
} }
// FIXME: if this was more thorough it would manufacture an // FIXME: if this was more thorough it would manufacture an
// option::t<str> rather than just an maybe-empty string. // option::t<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 generic_os::getenv(istr::from_estr(var)) { alt generic_os::getenv(var) {
option::none. { ret make_new_str(cx, sp, ""); } option::none. { ret make_new_str(cx, sp, ""); }
option::some(s) { option::some(s) {
ret make_new_str(cx, sp, istr::to_estr(s)); ret make_new_str(cx, sp, istr::to_estr(s));

View file

@ -26,9 +26,9 @@ fn expand_expr(exts: &hashmap<istr, syntax_extension>, cx: &ext_ctxt,
let extname = pth.node.idents[0]; let extname = pth.node.idents[0];
alt exts.find(extname) { alt exts.find(extname) {
none. { none. {
cx.span_fatal(pth.span, cx.span_fatal(pth.span, istr::from_estr(
#fmt["macro undefined: '%s'", #fmt["macro undefined: '%s'",
istr::to_estr(extname)]) istr::to_estr(extname)]))
} }
some(normal(ext)) { some(normal(ext)) {
let expanded = ext(cx, pth.span, args, body); let expanded = ext(cx, pth.span, args, body);
@ -43,13 +43,13 @@ fn expand_expr(exts: &hashmap<istr, syntax_extension>, cx: &ext_ctxt,
some(macro_defining(ext)) { some(macro_defining(ext)) {
let named_extension = ext(cx, pth.span, args, body); let named_extension = ext(cx, pth.span, args, body);
exts.insert( exts.insert(
istr::from_estr(named_extension.ident), named_extension.ident,
named_extension.ext); named_extension.ext);
ast::expr_rec([], none) ast::expr_rec([], none)
} }
} }
} }
_ { cx.span_bug(mac.span, "naked syntactic bit") } _ { cx.span_bug(mac.span, ~"naked syntactic bit") }
} }
} }
_ { orig(e, fld) } _ { orig(e, fld) }

View file

@ -22,23 +22,24 @@ fn expand_syntax_ext(cx: &ext_ctxt, sp: span, arg: @ast::expr,
alt arg.node { alt arg.node {
ast::expr_vec(elts, _) { elts } ast::expr_vec(elts, _) { elts }
_ { _ {
cx.span_fatal(sp, "#fmt requires arguments of the form `[...]`.") cx.span_fatal(sp, ~"#fmt requires arguments of the form `[...]`.")
} }
}; };
if vec::len::<@ast::expr>(args) == 0u { if vec::len::<@ast::expr>(args) == 0u {
cx.span_fatal(sp, "#fmt requires a format string"); cx.span_fatal(sp, ~"#fmt requires a format string");
} }
let fmt = let fmt =
expr_to_str(cx, args[0], 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; let fmtspan = args[0].span;
log "Format string:"; log "Format string:";
log fmt; log 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); cx.span_fatal(sp, istr::from_estr(msg));
} }
let parse_fmt_err = bind parse_fmt_err_(cx, fmtspan, _); let parse_fmt_err = bind parse_fmt_err_(cx, fmtspan, _);
let pieces = parse_fmt_string(fmt, parse_fmt_err); let pieces = parse_fmt_string(istr::to_estr(fmt), parse_fmt_err);
ret pieces_to_expr(cx, sp, pieces, args); ret pieces_to_expr(cx, sp, pieces, args);
} }
@ -102,7 +103,7 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece],
} }
fn make_path_vec(cx: &ext_ctxt, ident: &ast::ident) -> [ast::ident] { fn make_path_vec(cx: &ext_ctxt, ident: &ast::ident) -> [ast::ident] {
fn compiling_std(cx: &ext_ctxt) -> bool { fn compiling_std(cx: &ext_ctxt) -> bool {
ret str::find(cx.crate_file_name(), "std.rc") >= 0; ret istr::find(cx.crate_file_name(), ~"std.rc") >= 0;
} }
if compiling_std(cx) { if compiling_std(cx) {
ret [~"extfmt", ~"rt", ident]; ret [~"extfmt", ~"rt", ident];
@ -149,7 +150,7 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece],
let count_is_args = [count_lit]; let count_is_args = [count_lit];
ret make_call(cx, sp, count_is_path, count_is_args); ret make_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 { fn make_ty(cx: &ext_ctxt, sp: span, t: &ty) -> @ast::expr {
@ -203,7 +204,7 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece],
_ { ret false; } _ { ret false; }
} }
} }
let unsupported = "conversion not supported in #fmt string"; let unsupported = ~"conversion not supported in #fmt string";
alt cnv.param { alt cnv.param {
option::none. { } option::none. { }
_ { cx.span_unimpl(sp, unsupported); } _ { cx.span_unimpl(sp, unsupported); }
@ -214,15 +215,15 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece],
flag_sign_always. { flag_sign_always. {
if !is_signed_type(cnv) { if !is_signed_type(cnv) {
cx.span_fatal(sp, cx.span_fatal(sp,
"+ flag only valid in " + ~"+ flag only valid in " +
"signed #fmt conversion"); ~"signed #fmt conversion");
} }
} }
flag_space_for_sign. { flag_space_for_sign. {
if !is_signed_type(cnv) { if !is_signed_type(cnv) {
cx.span_fatal(sp, cx.span_fatal(sp,
"space flag only valid in " + ~"space flag only valid in " +
"signed #fmt conversions"); ~"signed #fmt conversions");
} }
} }
flag_left_zero_pad. { } flag_left_zero_pad. { }
@ -330,8 +331,8 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece],
n += 1u; n += 1u;
if n >= nargs { if n >= nargs {
cx.span_fatal(sp, cx.span_fatal(sp,
"not enough arguments to #fmt " + ~"not enough arguments to #fmt " +
"for the given format string"); ~"for the given format string");
} }
log "Building conversion:"; log "Building conversion:";
log_conv(conv); log_conv(conv);
@ -345,9 +346,9 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece],
if expected_nargs < nargs { if expected_nargs < nargs {
cx.span_fatal( cx.span_fatal(
sp, sp, istr::from_estr(
#fmt["too many arguments to #fmt. found %u, expected %u", #fmt["too many arguments to #fmt. found %u, expected %u",
nargs, expected_nargs]); nargs, expected_nargs]));
} }
ret tmp_expr; ret tmp_expr;
} }

View file

@ -10,16 +10,16 @@ fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr,
alt arg.node { alt arg.node {
ast::expr_vec(elts, _) { elts } ast::expr_vec(elts, _) { elts }
_ { _ {
cx.span_fatal(sp, "#ident_to_str requires a vector argument .") cx.span_fatal(sp, ~"#ident_to_str requires a vector argument .")
} }
}; };
if vec::len::<@ast::expr>(args) != 1u { if vec::len::<@ast::expr>(args) != 1u {
cx.span_fatal(sp, "malformed #ident_to_str call"); cx.span_fatal(sp, ~"malformed #ident_to_str call");
} }
ret make_new_lit(cx, sp, ret make_new_lit(cx, sp,
ast::lit_str(expr_to_ident(cx, args[0u], ast::lit_str(expr_to_ident(cx, args[0u],
"expected an ident"), ~"expected an ident"),
ast::sk_rc)); ast::sk_rc));
} }

View file

@ -58,28 +58,29 @@ tag matchable {
/* for when given an incompatible bit of AST */ /* 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) -> ! {
let expected = istr::from_estr(expected);
alt m { alt m {
match_expr(x) { match_expr(x) {
cx.span_fatal(x.span, cx.span_fatal(x.span,
"this argument is an expr, expected " + expected); ~"this argument is an expr, expected " + expected);
} }
match_path(x) { match_path(x) {
cx.span_fatal(x.span, cx.span_fatal(x.span,
"this argument is a path, expected " + expected); ~"this argument is a path, expected " + expected);
} }
match_ident(x) { match_ident(x) {
cx.span_fatal(x.span, cx.span_fatal(x.span,
"this argument is an ident, expected " + expected); ~"this argument is an ident, expected " + expected);
} }
match_ty(x) { match_ty(x) {
cx.span_fatal(x.span, cx.span_fatal(x.span,
"this argument is a type, expected " + expected); ~"this argument is a type, expected " + expected);
} }
match_block(x) { match_block(x) {
cx.span_fatal(x.span, 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?"); }
} }
} }
@ -102,7 +103,7 @@ fn elts_to_ell(cx: &ext_ctxt, elts: &[@expr]) ->
alt m.node { alt m.node {
ast::mac_ellipsis. { ast::mac_ellipsis. {
if res != none { if res != none {
cx.span_fatal(m.span, "only one ellipsis allowed"); cx.span_fatal(m.span, ~"only one ellipsis allowed");
} }
res = res =
some({pre: vec::slice(elts, 0u, idx - 1u), some({pre: vec::slice(elts, 0u, idx - 1u),
@ -252,8 +253,8 @@ fn follow_for_trans(cx: &ext_ctxt, mmaybe: &option::t<arb_depth<matchable>>,
ret alt follow(m, idx_path) { ret alt follow(m, idx_path) {
seq(_, sp) { seq(_, sp) {
cx.span_fatal(sp, cx.span_fatal(sp,
"syntax matched under ... but not " + ~"syntax matched under ... but not " +
"used that way.") ~"used that way.")
} }
leaf(m) { ret some(m) } leaf(m) { ret some(m) }
} }
@ -314,7 +315,8 @@ fn transcribe_exprs(cx: &ext_ctxt, b: &bindings, idx_path: @mutable [uint],
#fmt["'%s' occurs %u times", #fmt["'%s' occurs %u times",
istr::to_estr(old_name), istr::to_estr(old_name),
old_len]; old_len];
cx.span_fatal(repeat_me.span, msg); cx.span_fatal(
repeat_me.span, istr::from_estr(msg));
} }
} }
} }
@ -324,8 +326,8 @@ fn transcribe_exprs(cx: &ext_ctxt, b: &bindings, idx_path: @mutable [uint],
alt repeat { alt repeat {
none. { none. {
cx.span_fatal(repeat_me.span, cx.span_fatal(repeat_me.span,
"'...' surrounds an expression without any" + ~"'...' surrounds an expression without any" +
" repeating syntax variables"); ~" repeating syntax variables");
} }
some({rep_count: rc, _}) { some({rep_count: rc, _}) {
/* Whew, we now know how how many times to repeat */ /* Whew, we now know how how many times to repeat */
@ -468,12 +470,12 @@ fn p_t_s_rec(cx: &ext_ctxt, m: &matchable, s: &selector, b: &binders) {
if vec::len(post) > 0u { if vec::len(post) > 0u {
cx.span_unimpl(e.span, cx.span_unimpl(e.span,
"matching after `...` not yet supported"); ~"matching after `...` not yet supported");
} }
} }
{pre: pre, rep: none., post: post} { {pre: pre, rep: none., post: post} {
if 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_length(cx, vec::len(pre), false, s, b);
p_t_s_r_actual_vector(cx, pre, false, s, b); p_t_s_r_actual_vector(cx, pre, false, s, b);
@ -493,7 +495,7 @@ fn p_t_s_rec(cx: &ext_ctxt, m: &matchable, s: &selector, b: &binders) {
match_expr(e) { match_expr(e) {
if e == pat { some(leaf(match_exact)) } else { none } 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 += [bind select(cx, _, e)]; b.literal_ast_matchers += [bind select(cx, _, e)];
@ -529,11 +531,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 { fn select(cx: &ext_ctxt, m: &matchable) -> match_result {
ret alt m { ret alt m {
match_expr(e) { some(leaf(specialize_match(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) { 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, b.real_binders.insert(p_id,
compose_sels(s, bind select(cx, _))); compose_sels(s, bind select(cx, _)));
@ -559,14 +561,15 @@ fn p_t_s_r_mac(cx: &ext_ctxt, mac: &ast::mac, s: &selector, b: &binders) {
match_expr(e) { match_expr(e) {
alt e.node { expr_mac(mac) { fn_m(mac) } _ { none } } 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) -> ! { fn no_des(cx: &ext_ctxt, sp: &span, syn: &str) -> ! {
cx.span_fatal(sp, "destructuring " + syn + " is not yet supported"); cx.span_fatal(sp, ~"destructuring "
+ istr::from_estr(syn) + ~" is not yet supported");
} }
alt mac.node { alt mac.node {
ast::mac_ellipsis. { cx.span_fatal(mac.span, "misused `...`"); } ast::mac_ellipsis. { cx.span_fatal(mac.span, ~"misused `...`"); }
ast::mac_invoc(_, _, _) { no_des(cx, mac.span, "macro calls"); } ast::mac_invoc(_, _, _) { no_des(cx, mac.span, "macro calls"); }
ast::mac_embed_type(ty) { ast::mac_embed_type(ty) {
alt ty.node { alt ty.node {
@ -633,7 +636,7 @@ fn p_t_s_r_ellipses(cx: &ext_ctxt, repeat_me: @expr, offset: uint,
_ { none } _ { 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), p_t_s_rec(cx, match_expr(repeat_me),
@ -678,7 +681,7 @@ fn p_t_s_r_actual_vector(cx: &ext_ctxt, elts: [@expr], _repeat_after: bool,
_ { none } _ { 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]), p_t_s_rec(cx, match_expr(elts[idx]),
@ -694,7 +697,7 @@ fn add_new_extension(cx: &ext_ctxt, sp: span, arg: @expr,
ast::expr_vec(elts, _) { elts } ast::expr_vec(elts, _) { elts }
_ { _ {
cx.span_fatal(sp, cx.span_fatal(sp,
"#macro requires arguments of the form `[...]`.") ~"#macro requires arguments of the form `[...]`.")
} }
}; };
@ -705,8 +708,8 @@ fn add_new_extension(cx: &ext_ctxt, sp: span, arg: @expr,
expr_vec(elts, mut) { expr_vec(elts, mut) {
if vec::len(elts) != 2u { if vec::len(elts) != 2u {
cx.span_fatal((*arg).span, cx.span_fatal((*arg).span,
"extension clause must consist of [" + ~"extension clause must consist of [" +
"macro invocation, expansion body]"); ~"macro invocation, expansion body]");
} }
@ -721,15 +724,15 @@ fn add_new_extension(cx: &ext_ctxt, sp: span, arg: @expr,
some(other_id) { some(other_id) {
if id != other_id { if id != other_id {
cx.span_fatal(pth.span, cx.span_fatal(pth.span,
"macro name must be " + ~"macro name must be " +
"consistent"); ~"consistent");
} }
} }
} }
} }
none. { none. {
cx.span_fatal(pth.span, cx.span_fatal(pth.span,
"macro name must not be a path"); ~"macro name must not be a path");
} }
} }
clauses += clauses +=
@ -742,14 +745,14 @@ fn add_new_extension(cx: &ext_ctxt, sp: span, arg: @expr,
} }
_ { _ {
cx.span_fatal(elts[0u].span, cx.span_fatal(elts[0u].span,
"extension clause must" + ~"extension clause must" +
" start with a macro invocation."); ~" start with a macro invocation.");
} }
} }
} }
_ { _ {
cx.span_fatal((*arg).span, cx.span_fatal((*arg).span,
"extension must be [clause, " + " ...]"); ~"extension must be [clause, " + ~" ...]");
} }
} }
} }
@ -758,11 +761,11 @@ fn add_new_extension(cx: &ext_ctxt, sp: span, arg: @expr,
ret {ident: ret {ident:
alt macro_name { alt macro_name {
some(id) { istr::to_estr(id) } some(id) { id }
none. { none. {
cx.span_fatal(sp, cx.span_fatal(sp,
"macro definition must have " + ~"macro definition must have " +
"at least one clause") ~"at least one clause")
} }
}, },
ext: normal(ext)}; ext: normal(ext)};
@ -776,7 +779,7 @@ fn add_new_extension(cx: &ext_ctxt, sp: span, arg: @expr,
none. { cont; } none. { cont; }
} }
} }
cx.span_fatal(sp, "no clauses match macro invocation"); cx.span_fatal(sp, ~"no clauses match macro invocation");
} }
} }