rustc: Rename session.span_err -> span_fatal, err -> fatal

Issue #440
This commit is contained in:
Brian Anderson 2011-06-18 22:41:20 -07:00
parent 514813148b
commit c394a7f49a
16 changed files with 136 additions and 130 deletions

View file

@ -33,8 +33,8 @@ tag output_type {
fn llvm_err(session::session sess, str msg) { fn llvm_err(session::session sess, str msg) {
auto buf = llvm::LLVMRustGetLastError(); auto buf = llvm::LLVMRustGetLastError();
if (buf as uint == 0u) { if (buf as uint == 0u) {
sess.err(msg); sess.fatal(msg);
} else { sess.err(msg + ": " + str::str_from_cstr(buf)); } } else { sess.fatal(msg + ": " + str::str_from_cstr(buf)); }
fail; fail;
} }
@ -276,7 +276,7 @@ fn get_crate_meta_export(&session::session sess, &ast::crate c, str k,
} }
case (1u) { ret v.(0).node.value; } case (1u) { ret v.(0).node.value; }
case (_) { case (_) {
sess.span_err(v.(1).span, #fmt("duplicate meta '%s'", k)); sess.span_fatal(v.(1).span, #fmt("duplicate meta '%s'", k));
} }
} }
} }

View file

@ -59,7 +59,7 @@ fn parse_input(session::session sess, parser::parser p, str input) ->
parser::parse_crate_from_crate_file(p) parser::parse_crate_from_crate_file(p)
} else if (str::ends_with(input, ".rs")) { } else if (str::ends_with(input, ".rs")) {
parser::parse_crate_from_source_file(p) parser::parse_crate_from_source_file(p)
} else { sess.err("unknown input file type: " + input); fail }; } else { sess.fatal("unknown input file type: " + input); fail };
} }
fn time[T](bool do_it, str what, fn() -> T thunk) -> T { fn time[T](bool do_it, str what, fn() -> T thunk) -> T {
@ -282,7 +282,7 @@ fn parse_pretty(session::session sess, &str name) -> pp_mode {
} else if (str::eq(name, "typed")) { } else if (str::eq(name, "typed")) {
ret ppm_typed; ret ppm_typed;
} else if (str::eq(name, "identified")) { ret ppm_identified; } } else if (str::eq(name, "identified")) { ret ppm_identified; }
sess.err("argument to `pretty` must be one of `normal`, `typed`, or " + sess.fatal("argument to `pretty` must be one of `normal`, `typed`, or " +
"`identified`"); "`identified`");
} }
@ -321,16 +321,16 @@ fn main(vec[str] args) {
auto glue = opt_present(match, "glue"); auto glue = opt_present(match, "glue");
if (glue) { if (glue) {
if (n_inputs > 0u) { if (n_inputs > 0u) {
sess.err("No input files allowed with --glue."); sess.fatal("No input files allowed with --glue.");
} }
auto out = option::from_maybe[str]("glue.bc", output_file); auto out = option::from_maybe[str]("glue.bc", output_file);
middle::trans::make_common_glue(sess, out); middle::trans::make_common_glue(sess, out);
ret; ret;
} }
if (n_inputs == 0u) { if (n_inputs == 0u) {
sess.err("No input filename given."); sess.fatal("No input filename given.");
} else if (n_inputs > 1u) { } else if (n_inputs > 1u) {
sess.err("Multiple input filenames provided."); sess.fatal("Multiple input filenames provided.");
} }
auto ifile = match.free.(0); auto ifile = match.free.(0);
let str saved_out_filename = ""; let str saved_out_filename = "";

View file

@ -70,13 +70,13 @@ obj session(ast::crate_num cnum,
fn get_targ_cfg() -> @config { ret targ_cfg; } fn get_targ_cfg() -> @config { ret targ_cfg; }
fn get_opts() -> @options { ret opts; } fn get_opts() -> @options { ret opts; }
fn get_targ_crate_num() -> ast::crate_num { ret cnum; } fn get_targ_crate_num() -> ast::crate_num { ret cnum; }
fn span_err(span sp, str msg) -> ! { fn span_fatal(span sp, str msg) -> ! {
// FIXME: Use constants, but rustboot doesn't know how to export them. // FIXME: Use constants, but rustboot doesn't know how to export them.
emit_diagnostic(some(sp), msg, "error", 9u8, cm); emit_diagnostic(some(sp), msg, "error", 9u8, cm);
fail; fail;
} }
fn err(str msg) -> ! { fn fatal(str msg) -> ! {
emit_diagnostic(none[span], msg, "error", 9u8, cm); emit_diagnostic(none[span], msg, "error", 9u8, cm);
fail; fail;
} }
@ -94,10 +94,10 @@ obj session(ast::crate_num cnum,
emit_diagnostic(some(sp), msg, "note", 10u8, cm); emit_diagnostic(some(sp), msg, "note", 10u8, cm);
} }
fn span_bug(span sp, str msg) -> ! { fn span_bug(span sp, str msg) -> ! {
self.span_err(sp, #fmt("internal compiler error %s", msg)); self.span_fatal(sp, #fmt("internal compiler error %s", msg));
} }
fn bug(str msg) -> ! { fn bug(str msg) -> ! {
self.err(#fmt("internal compiler error %s", msg)); self.fatal(#fmt("internal compiler error %s", msg));
} }
fn span_unimpl(span sp, str msg) -> ! { fn span_unimpl(span sp, str msg) -> ! {
self.span_bug(sp, "unimplemented " + msg); self.span_bug(sp, "unimplemented " + msg);

View file

@ -63,7 +63,7 @@ fn lookup(session::session sess, env e, span sp, ident i) -> val {
for (tup(ident, val) pair in e) { for (tup(ident, val) pair in e) {
if (str::eq(i, pair._0)) { ret pair._1; } if (str::eq(i, pair._0)) { ret pair._1; }
} }
sess.span_err(sp, "unknown variable: " + i) sess.span_fatal(sp, "unknown variable: " + i)
} }
fn eval_lit(ctx cx, span sp, @ast::lit lit) -> val { fn eval_lit(ctx cx, span sp, @ast::lit lit) -> val {
@ -71,7 +71,7 @@ fn eval_lit(ctx cx, span sp, @ast::lit lit) -> val {
case (ast::lit_bool(?b)) { val_bool(b) } case (ast::lit_bool(?b)) { val_bool(b) }
case (ast::lit_int(?i)) { val_int(i) } case (ast::lit_int(?i)) { val_int(i) }
case (ast::lit_str(?s, _)) { val_str(s) } case (ast::lit_str(?s, _)) { val_str(s) }
case (_) { cx.sess.span_err(sp, "evaluating unsupported literal") } case (_) { cx.sess.span_fatal(sp, "evaluating unsupported literal") }
} }
} }
@ -82,7 +82,7 @@ fn eval_expr(ctx cx, env e, @ast::expr x) -> val {
vec::len[@ast::ty](pth.node.types) == 0u) { vec::len[@ast::ty](pth.node.types) == 0u) {
ret lookup(cx.sess, e, x.span, pth.node.idents.(0)); ret lookup(cx.sess, e, x.span, pth.node.idents.(0));
} }
cx.sess.span_err(x.span, "evaluating structured path-name"); cx.sess.span_fatal(x.span, "evaluating structured path-name");
} }
case (ast::expr_lit(?lit, _)) { ret eval_lit(cx, x.span, lit); } case (ast::expr_lit(?lit, _)) { ret eval_lit(cx, x.span, lit); }
case (ast::expr_unary(?op, ?a, _)) { case (ast::expr_unary(?op, ?a, _)) {
@ -90,10 +90,10 @@ fn eval_expr(ctx cx, env e, @ast::expr x) -> val {
alt (op) { alt (op) {
case (ast::not) { case (ast::not) {
if (val_is_bool(av)) { ret val_bool(!val_as_bool(av)); } if (val_is_bool(av)) { ret val_bool(!val_as_bool(av)); }
cx.sess.span_err(x.span, "bad types in '!' expression"); cx.sess.span_fatal(x.span, "bad types in '!' expression");
} }
case (_) { case (_) {
cx.sess.span_err(x.span, "evaluating unsupported unop"); cx.sess.span_fatal(x.span, "evaluating unsupported unop");
} }
} }
} }
@ -108,43 +108,45 @@ fn eval_expr(ctx cx, env e, @ast::expr x) -> val {
if (val_is_str(av) && val_is_str(bv)) { if (val_is_str(av) && val_is_str(bv)) {
ret val_str(val_as_str(av) + val_as_str(bv)); ret val_str(val_as_str(av) + val_as_str(bv));
} }
cx.sess.span_err(x.span, "bad types in '+' expression"); cx.sess.span_fatal(x.span, "bad types in '+' expression");
} }
case (ast::sub) { case (ast::sub) {
if (val_is_int(av) && val_is_int(bv)) { if (val_is_int(av) && val_is_int(bv)) {
ret val_int(val_as_int(av) - val_as_int(bv)); ret val_int(val_as_int(av) - val_as_int(bv));
} }
cx.sess.span_err(x.span, "bad types in '-' expression"); cx.sess.span_fatal(x.span, "bad types in '-' expression");
} }
case (ast::mul) { case (ast::mul) {
if (val_is_int(av) && val_is_int(bv)) { if (val_is_int(av) && val_is_int(bv)) {
ret val_int(val_as_int(av) * val_as_int(bv)); ret val_int(val_as_int(av) * val_as_int(bv));
} }
cx.sess.span_err(x.span, "bad types in '*' expression"); cx.sess.span_fatal(x.span, "bad types in '*' expression");
} }
case (ast::div) { case (ast::div) {
if (val_is_int(av) && val_is_int(bv)) { if (val_is_int(av) && val_is_int(bv)) {
ret val_int(val_as_int(av) / val_as_int(bv)); ret val_int(val_as_int(av) / val_as_int(bv));
} }
cx.sess.span_err(x.span, "bad types in '/' expression"); cx.sess.span_fatal(x.span, "bad types in '/' expression");
} }
case (ast::rem) { case (ast::rem) {
if (val_is_int(av) && val_is_int(bv)) { if (val_is_int(av) && val_is_int(bv)) {
ret val_int(val_as_int(av) % val_as_int(bv)); ret val_int(val_as_int(av) % val_as_int(bv));
} }
cx.sess.span_err(x.span, "bad types in '%' expression"); cx.sess.span_fatal(x.span, "bad types in '%' expression");
} }
case (ast::and) { case (ast::and) {
if (val_is_bool(av) && val_is_bool(bv)) { if (val_is_bool(av) && val_is_bool(bv)) {
ret val_bool(val_as_bool(av) && val_as_bool(bv)); ret val_bool(val_as_bool(av) && val_as_bool(bv));
} }
cx.sess.span_err(x.span, "bad types in '&&' expression"); cx.sess.span_fatal(x.span,
"bad types in '&&' expression");
} }
case (ast::or) { case (ast::or) {
if (val_is_bool(av) && val_is_bool(bv)) { if (val_is_bool(av) && val_is_bool(bv)) {
ret val_bool(val_as_bool(av) || val_as_bool(bv)); ret val_bool(val_as_bool(av) || val_as_bool(bv));
} }
cx.sess.span_err(x.span, "bad types in '||' expression"); cx.sess.span_fatal(x.span,
"bad types in '||' expression");
} }
case (ast::eq) { case (ast::eq) {
ret val_bool(val_eq(cx.sess, x.span, av, bv)); ret val_bool(val_eq(cx.sess, x.span, av, bv));
@ -153,12 +155,13 @@ fn eval_expr(ctx cx, env e, @ast::expr x) -> val {
ret val_bool(!val_eq(cx.sess, x.span, av, bv)); ret val_bool(!val_eq(cx.sess, x.span, av, bv));
} }
case (_) { case (_) {
cx.sess.span_err(x.span, "evaluating unsupported binop"); cx.sess.span_fatal(x.span,
"evaluating unsupported binop");
} }
} }
} }
case (_) { case (_) {
cx.sess.span_err(x.span, "evaluating unsupported expression"); cx.sess.span_fatal(x.span, "evaluating unsupported expression");
} }
} }
fail; fail;
@ -171,7 +174,7 @@ fn val_eq(session::session sess, span sp, val av, val bv) -> bool {
val_as_int(av) == val_as_int(bv) val_as_int(av) == val_as_int(bv)
} else if (val_is_str(av) && val_is_str(bv)) { } else if (val_is_str(av) && val_is_str(bv)) {
str::eq(val_as_str(av), val_as_str(bv)) str::eq(val_as_str(av), val_as_str(bv))
} else { sess.span_err(sp, "bad types in comparison") } } else { sess.span_fatal(sp, "bad types in comparison") }
} }
fn eval_crate_directives(ctx cx, env e, vec[@ast::crate_directive] cdirs, fn eval_crate_directives(ctx cx, env e, vec[@ast::crate_directive] cdirs,
@ -200,7 +203,7 @@ fn eval_crate_directive_block(ctx cx, env e, &ast::block blk, str prefix,
eval_crate_directive(cx, e, cdir, prefix, view_items, items); eval_crate_directive(cx, e, cdir, prefix, view_items, items);
} }
case (_) { case (_) {
cx.sess.span_err(s.span, cx.sess.span_fatal(s.span,
"unsupported stmt in crate-directive block"); "unsupported stmt in crate-directive block");
} }
} }
@ -214,7 +217,7 @@ fn eval_crate_directive_expr(ctx cx, env e, @ast::expr x, str prefix,
case (ast::expr_if(?cond, ?thn, ?elopt, _)) { case (ast::expr_if(?cond, ?thn, ?elopt, _)) {
auto cv = eval_expr(cx, e, cond); auto cv = eval_expr(cx, e, cond);
if (!val_is_bool(cv)) { if (!val_is_bool(cv)) {
cx.sess.span_err(x.span, "bad cond type in 'if'"); cx.sess.span_fatal(x.span, "bad cond type in 'if'");
} }
if (val_as_bool(cv)) { if (val_as_bool(cv)) {
ret eval_crate_directive_block(cx, e, thn, prefix, view_items, ret eval_crate_directive_block(cx, e, thn, prefix, view_items,
@ -249,18 +252,18 @@ fn eval_crate_directive_expr(ctx cx, env e, @ast::expr x, str prefix,
items); items);
} }
case (_) { case (_) {
cx.sess.span_err(arm.pat.span, cx.sess.span_fatal(arm.pat.span,
"bad pattern type in 'alt'"); "bad pattern type in 'alt'");
} }
} }
} }
cx.sess.span_err(x.span, "no cases matched in 'alt'"); cx.sess.span_fatal(x.span, "no cases matched in 'alt'");
} }
case (ast::expr_block(?block, _)) { case (ast::expr_block(?block, _)) {
ret eval_crate_directive_block(cx, e, block, prefix, view_items, ret eval_crate_directive_block(cx, e, block, prefix, view_items,
items); items);
} }
case (_) { cx.sess.span_err(x.span, "unsupported expr type"); } case (_) { cx.sess.span_fatal(x.span, "unsupported expr type"); }
} }
} }

View file

@ -31,21 +31,23 @@ type next_ann_fn = fn() -> ast::ann ;
// Provides a limited set of services necessary for syntax extensions // Provides a limited set of services necessary for syntax extensions
// to do their thing // to do their thing
type ext_ctxt = type ext_ctxt =
rec(span_msg_fn span_err, span_msg_fn span_unimpl, next_ann_fn next_ann); rec(span_msg_fn span_fatal,
span_msg_fn span_unimpl,
next_ann_fn next_ann);
fn mk_ctxt(parser parser) -> ext_ctxt { fn mk_ctxt(parser parser) -> ext_ctxt {
auto sess = parser.get_session(); auto sess = parser.get_session();
fn ext_span_err_(session sess, span sp, str msg) -> ! { fn ext_span_fatal_(session sess, span sp, str msg) -> ! {
sess.span_err(sp, msg); sess.span_fatal(sp, msg);
} }
auto ext_span_err = bind ext_span_err_(sess, _, _); auto ext_span_fatal = bind ext_span_fatal_(sess, _, _);
fn ext_span_unimpl_(session sess, span sp, str msg) -> ! { fn ext_span_unimpl_(session sess, span sp, str msg) -> ! {
sess.span_unimpl(sp, msg); sess.span_unimpl(sp, msg);
} }
auto ext_span_unimpl = bind ext_span_unimpl_(sess, _, _); auto ext_span_unimpl = bind ext_span_unimpl_(sess, _, _);
fn ext_next_ann_(parser parser) -> ast::ann { parser.get_ann() } fn ext_next_ann_(parser parser) -> ast::ann { parser.get_ann() }
auto ext_next_ann = bind ext_next_ann_(parser); auto ext_next_ann = bind ext_next_ann_(parser);
ret rec(span_err=ext_span_err, ret rec(span_fatal=ext_span_fatal,
span_unimpl=ext_span_unimpl, span_unimpl=ext_span_unimpl,
next_ann=ext_next_ann); next_ann=ext_next_ann);
} }

View file

@ -16,7 +16,7 @@ export expand_syntax_ext;
fn expand_syntax_ext(&ext_ctxt cx, common::span sp, &vec[@ast::expr] args, fn expand_syntax_ext(&ext_ctxt cx, common::span sp, &vec[@ast::expr] args,
option::t[str] body) -> @ast::expr { option::t[str] body) -> @ast::expr {
if (vec::len[@ast::expr](args) != 1u) { if (vec::len[@ast::expr](args) != 1u) {
cx.span_err(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.
@ -35,10 +35,10 @@ fn expr_to_str(&ext_ctxt cx, @ast::expr expr) -> str {
case (ast::expr_lit(?l, _)) { case (ast::expr_lit(?l, _)) {
alt (l.node) { alt (l.node) {
case (ast::lit_str(?s, _)) { ret s; } case (ast::lit_str(?s, _)) { ret s; }
case (_) { cx.span_err(l.span, "malformed #env call"); } case (_) { cx.span_fatal(l.span, "malformed #env call"); }
} }
} }
case (_) { cx.span_err(expr.span, "malformed #env call"); } case (_) { cx.span_fatal(expr.span, "malformed #env call"); }
} }
} }

View file

@ -18,14 +18,14 @@ export expand_syntax_ext;
fn expand_syntax_ext(&ext_ctxt cx, common::span sp, &vec[@ast::expr] args, fn expand_syntax_ext(&ext_ctxt cx, common::span sp, &vec[@ast::expr] args,
option::t[str] body) -> @ast::expr { option::t[str] body) -> @ast::expr {
if (vec::len[@ast::expr](args) == 0u) { if (vec::len[@ast::expr](args) == 0u) {
cx.span_err(sp, "#fmt requires a format string"); cx.span_fatal(sp, "#fmt requires a format string");
} }
auto fmt = expr_to_str(cx, args.(0)); auto fmt = expr_to_str(cx, args.(0));
auto fmtspan = args.(0).span; auto fmtspan = args.(0).span;
log "Format string:"; log "Format string:";
log fmt; log fmt;
fn parse_fmt_err_(&ext_ctxt cx, common::span sp, str msg) -> ! { fn parse_fmt_err_(&ext_ctxt cx, common::span sp, str msg) -> ! {
cx.span_err(sp, msg); cx.span_fatal(sp, msg);
} }
auto parse_fmt_err = bind parse_fmt_err_(cx, fmtspan, _); auto parse_fmt_err = bind parse_fmt_err_(cx, fmtspan, _);
auto pieces = parse_fmt_string(fmt, parse_fmt_err); auto pieces = parse_fmt_string(fmt, parse_fmt_err);
@ -40,10 +40,10 @@ fn expr_to_str(&ext_ctxt cx, @ast::expr expr) -> str {
case (ast::expr_lit(?l, _)) { case (ast::expr_lit(?l, _)) {
alt (l.node) { alt (l.node) {
case (ast::lit_str(?s, _)) { ret s; } case (ast::lit_str(?s, _)) { ret s; }
case (_) { cx.span_err(l.span, err_msg); } case (_) { cx.span_fatal(l.span, err_msg); }
} }
} }
case (_) { cx.span_err(expr.span, err_msg); } case (_) { cx.span_fatal(expr.span, err_msg); }
} }
} }
@ -236,14 +236,14 @@ fn pieces_to_expr(&ext_ctxt cx, common::span sp, vec[piece] pieces,
case (flag_left_justify) { } case (flag_left_justify) { }
case (flag_sign_always) { case (flag_sign_always) {
if (!is_signed_type(cnv)) { if (!is_signed_type(cnv)) {
cx.span_err(sp, cx.span_fatal(sp,
"+ flag only valid in " + "+ flag only valid in " +
"signed #fmt conversion"); "signed #fmt conversion");
} }
} }
case (flag_space_for_sign) { case (flag_space_for_sign) {
if (!is_signed_type(cnv)) { if (!is_signed_type(cnv)) {
cx.span_err(sp, cx.span_fatal(sp,
"space flag only valid in " + "space flag only valid in " +
"signed #fmt conversions"); "signed #fmt conversions");
} }
@ -361,7 +361,7 @@ fn pieces_to_expr(&ext_ctxt cx, common::span sp, vec[piece] pieces,
case (piece_conv(?conv)) { case (piece_conv(?conv)) {
n += 1u; n += 1u;
if (n >= nargs) { if (n >= nargs) {
cx.span_err(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");
} }
@ -376,7 +376,7 @@ fn pieces_to_expr(&ext_ctxt cx, common::span sp, vec[piece] pieces,
auto expected_nargs = n + 1u; // n conversions + the fmt string auto expected_nargs = n + 1u; // n conversions + the fmt string
if (expected_nargs < nargs) { if (expected_nargs < nargs) {
cx.span_err(sp, cx.span_fatal(sp,
#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));
} }

View file

@ -75,7 +75,7 @@ fn new_reader(session sess, io::reader rdr, codemap::filemap filemap,
fn get_interner() -> @interner::interner[str] { ret itr; } fn get_interner() -> @interner::interner[str] { ret itr; }
fn get_col() -> uint { ret col; } fn get_col() -> uint { ret col; }
fn get_filemap() -> codemap::filemap { ret fm; } fn get_filemap() -> codemap::filemap { ret fm; }
fn err(str m) { sess.span_err(rec(lo=chpos, hi=chpos), m); } fn err(str m) { sess.span_fatal(rec(lo=chpos, hi=chpos), m); }
} }
auto file = str::unsafe_from_bytes(rdr.read_whole_stream()); auto file = str::unsafe_from_bytes(rdr.read_whole_stream());
let vec[str] strs = []; let vec[str] strs = [];

View file

@ -78,7 +78,7 @@ fn new_parser(session::session sess, eval::env env, ast::def_id initial_def,
lo = rdr.get_mark_chpos(); lo = rdr.get_mark_chpos();
hi = rdr.get_chpos(); hi = rdr.get_chpos();
} }
fn err(str m) -> ! { sess.span_err(rec(lo=lo, hi=hi), m); } fn err(str m) -> ! { sess.span_fatal(rec(lo=lo, hi=hi), m); }
fn restrict(restriction r) { res = r; } fn restrict(restriction r) { res = r; }
fn get_restriction() -> restriction { ret res; } fn get_restriction() -> restriction { ret res; }
fn get_session() -> session::session { ret sess; } fn get_session() -> session::session { ret sess; }
@ -353,7 +353,7 @@ fn parse_ty_field(&parser p) -> ast::ty_field {
fn ident_index(&parser p, &vec[ast::arg] args, &ast::ident i) -> uint { fn ident_index(&parser p, &vec[ast::arg] args, &ast::ident i) -> uint {
auto j = 0u; auto j = 0u;
for (ast::arg a in args) { if (a.ident == i) { ret j; } j += 1u; } for (ast::arg a in args) { if (a.ident == i) { ret j; } j += 1u; }
p.get_session().span_err(p.get_span(), p.get_session().span_fatal(p.get_span(),
"Unbound variable " + i + " in constraint arg"); "Unbound variable " + i + " in constraint arg");
} }

View file

@ -92,7 +92,7 @@ fn visit_expr(@ctx cx, &@ast::expr ex, &scope sc, &vt[scope] v) {
case (some(?ex)) { case (some(?ex)) {
auto root = expr_root(*cx, ex, false); auto root = expr_root(*cx, ex, false);
if (mut_field(root.ds)) { if (mut_field(root.ds)) {
cx.tcx.sess.span_err(ex.span, cx.tcx.sess.span_fatal(ex.span,
"result of put must be" + "result of put must be" +
" immutably rooted"); " immutably rooted");
} }
@ -148,7 +148,7 @@ fn check_call(&ctx cx, &@ast::expr f, &vec[@ast::expr] args, &scope sc) ->
auto m = auto m =
"passing a temporary value or \ "passing a temporary value or \
immutable field by mutable alias"; immutable field by mutable alias";
cx.tcx.sess.span_err(arg.span, m); cx.tcx.sess.span_fatal(arg.span, m);
} }
} }
} }
@ -171,7 +171,7 @@ fn check_call(&ctx cx, &@ast::expr f, &vec[@ast::expr] args, &scope sc) ->
alt (f.node) { alt (f.node) {
case (ast::expr_path(_, ?ann)) { case (ast::expr_path(_, ?ann)) {
if (def_is_local(cx.tcx.def_map.get(ann.id), true)) { if (def_is_local(cx.tcx.def_map.get(ann.id), true)) {
cx.tcx.sess.span_err(f.span, cx.tcx.sess.span_fatal(f.span,
#fmt("function may alias with \ #fmt("function may alias with \
argument %u, which is not immutably rooted", argument %u, which is not immutably rooted",
unsafe_t_offsets.(0))); unsafe_t_offsets.(0)));
@ -190,7 +190,7 @@ fn check_call(&ctx cx, &@ast::expr f, &vec[@ast::expr] args, &scope sc) ->
if (i != offset && if (i != offset &&
ty_can_unsafely_include(cx, unsafe, arg_t.ty, mut_alias)) ty_can_unsafely_include(cx, unsafe, arg_t.ty, mut_alias))
{ {
cx.tcx.sess.span_err(args.(i).span, cx.tcx.sess.span_fatal(args.(i).span,
#fmt("argument %u may alias with \ #fmt("argument %u may alias with \
argument %u, which is not immutably rooted", argument %u, which is not immutably rooted",
i, offset)); i, offset));
@ -208,7 +208,7 @@ fn check_call(&ctx cx, &@ast::expr f, &vec[@ast::expr] args, &scope sc) ->
} }
} }
if (mut_alias_to_root) { if (mut_alias_to_root) {
cx.tcx.sess.span_err(args.(root._0).span, cx.tcx.sess.span_fatal(args.(root._0).span,
"passing a mutable alias to a \ "passing a mutable alias to a \
variable that roots another alias"); variable that roots another alias");
} }
@ -377,10 +377,10 @@ fn check_assign(&@ctx cx, &@ast::expr dest, &@ast::expr src, &scope sc,
case (ast::expr_path(?p, ?ann)) { case (ast::expr_path(?p, ?ann)) {
auto dnum = ast::def_id_of_def(cx.tcx.def_map.get(ann.id))._1; auto dnum = ast::def_id_of_def(cx.tcx.def_map.get(ann.id))._1;
if (is_immutable_alias(cx, sc, dnum)) { if (is_immutable_alias(cx, sc, dnum)) {
cx.tcx.sess.span_err(dest.span, cx.tcx.sess.span_fatal(dest.span,
"assigning to immutable alias"); "assigning to immutable alias");
} else if (is_immutable_objfield(cx, dnum)) { } else if (is_immutable_objfield(cx, dnum)) {
cx.tcx.sess.span_err(dest.span, cx.tcx.sess.span_fatal(dest.span,
"assigning to immutable obj field"); "assigning to immutable obj field");
} }
auto var_t = ty::expr_ty(*cx.tcx, dest); auto var_t = ty::expr_ty(*cx.tcx, dest);
@ -394,7 +394,7 @@ fn check_assign(&@ctx cx, &@ast::expr dest, &@ast::expr src, &scope sc,
case (_) { case (_) {
auto root = expr_root(*cx, dest, false); auto root = expr_root(*cx, dest, false);
if (vec::len(root.ds) == 0u) { if (vec::len(root.ds) == 0u) {
cx.tcx.sess.span_err(dest.span, "assignment to non-lvalue"); cx.tcx.sess.span_fatal(dest.span, "assignment to non-lvalue");
} else if (!root.ds.(0).mut) { } else if (!root.ds.(0).mut) {
auto name = auto name =
alt (root.ds.(0).kind) { alt (root.ds.(0).kind) {
@ -402,7 +402,7 @@ fn check_assign(&@ctx cx, &@ast::expr dest, &@ast::expr src, &scope sc,
case (field) { "field" } case (field) { "field" }
case (index) { "vec content" } case (index) { "vec content" }
}; };
cx.tcx.sess.span_err(dest.span, cx.tcx.sess.span_fatal(dest.span,
"assignment to immutable " + name); "assignment to immutable " + name);
} }
visit_expr(cx, dest, sc, v); visit_expr(cx, dest, sc, v);
@ -441,7 +441,7 @@ fn test_scope(&ctx cx, &scope sc, &restrict r, &ast::path p) {
tup(sp, "taking the value of " + ast::path_name(vpt)) tup(sp, "taking the value of " + ast::path_name(vpt))
} }
}; };
cx.tcx.sess.span_err(msg._0, cx.tcx.sess.span_fatal(msg._0,
msg._1 + " will invalidate alias " + msg._1 + " will invalidate alias " +
ast::path_name(p) + ", which is still used"); ast::path_name(p) + ", which is still used");
} }

View file

@ -307,7 +307,7 @@ fn resolve_names(&@env e, &@ast::crate c) {
e.def_map.insert(a.id, fnd); e.def_map.insert(a.id, fnd);
} }
case (_) { case (_) {
e.sess.span_err(p.span, e.sess.span_fatal(p.span,
"not a tag variant: " + "not a tag variant: " +
ast::path_name(p)); ast::path_name(p));
} }
@ -380,7 +380,7 @@ fn follow_import(&env e, &scopes sc, vec[ident] path, &span sp) -> def {
case (ast::def_mod(?def_id)) { ret dcur; } case (ast::def_mod(?def_id)) { ret dcur; }
case (ast::def_native_mod(?def_id)) { ret dcur; } case (ast::def_native_mod(?def_id)) { ret dcur; }
case (_) { case (_) {
e.sess.span_err(sp, e.sess.span_fatal(sp,
str::connect(path, "::") + str::connect(path, "::") +
" does not name a module."); " does not name a module.");
} }
@ -399,7 +399,7 @@ fn resolve_constr(@env e, &def_id d_id, &@ast::constr c, &scopes sc,
add_constr(e, d_id, new_constr); add_constr(e, d_id, new_constr);
} }
case (_) { case (_) {
e.sess.span_err(c.span, e.sess.span_fatal(c.span,
"Non-predicate in constraint: " + "Non-predicate in constraint: " +
ty::path_to_str(c.node.path)); ty::path_to_str(c.node.path));
} }
@ -478,7 +478,7 @@ fn ns_name(namespace ns) -> str {
} }
fn unresolved(&env e, &span sp, &ident id, &str kind) -> ! { fn unresolved(&env e, &span sp, &ident id, &str kind) -> ! {
e.sess.span_err(sp, "unresolved " + kind + ": " + id); e.sess.span_fatal(sp, "unresolved " + kind + ": " + id);
} }
@ -599,7 +599,7 @@ fn lookup_in_scope(&env e, scopes sc, &span sp, &ident id, namespace ns) ->
auto df = option::get(fnd); auto df = option::get(fnd);
if (left_fn && def_is_local(df) || if (left_fn && def_is_local(df) ||
left_fn_level2 && def_is_obj_field(df)) { left_fn_level2 && def_is_obj_field(df)) {
e.sess.span_err(sp, e.sess.span_fatal(sp,
"attempted dynamic \ "attempted dynamic \
environment-capture"); environment-capture");
} }
@ -806,7 +806,7 @@ fn lookup_import(&env e, def_id defid, namespace ns) -> option::t[def] {
resolve_import(e, item, sc); resolve_import(e, item, sc);
ret lookup_import(e, defid, ns); ret lookup_import(e, defid, ns);
} }
case (resolving(?sp)) { e.sess.span_err(sp, "cyclic import"); } case (resolving(?sp)) { e.sess.span_fatal(sp, "cyclic import"); }
case (resolved(?val, ?typ, ?md)) { case (resolved(?val, ?typ, ?md)) {
ret alt (ns) { ret alt (ns) {
case (ns_value) { val } case (ns_value) { val }
@ -881,7 +881,7 @@ fn lookup_glob_in_mod(&env e, @indexed_mod info, &span sp, &ident id,
} }
} }
} }
e.sess.span_err(sp, e.sess.span_fatal(sp,
"'" + id + "' is glob-imported from" + "'" + id + "' is glob-imported from" +
" multiple different modules."); " multiple different modules.");
} }
@ -1086,7 +1086,7 @@ fn check_mod_name(&env e, &ident name, list[mod_index_entry] entries) {
auto saw_type = false; auto saw_type = false;
auto saw_value = false; auto saw_value = false;
fn dup(&env e, &span sp, &str word, &ident name) { fn dup(&env e, &span sp, &str word, &ident name) {
e.sess.span_err(sp, "duplicate definition of " + word + name); e.sess.span_fatal(sp, "duplicate definition of " + word + name);
} }
while (true) { while (true) {
alt (entries) { alt (entries) {
@ -1222,7 +1222,7 @@ fn checker(&env e, str kind) -> checker {
fn add_name(&checker ch, &span sp, &ident id) { fn add_name(&checker ch, &span sp, &ident id) {
for (ident s in ch.seen) { for (ident s in ch.seen) {
if (str::eq(s, id)) { if (str::eq(s, id)) {
ch.sess.span_err(sp, "duplicate " + ch.kind + " name: " + id); ch.sess.span_fatal(sp, "duplicate " + ch.kind + " name: " + id);
} }
} }
vec::push(ch.seen, id); vec::push(ch.seen, id);

View file

@ -677,7 +677,7 @@ fn T_opaque_chan_ptr() -> TypeRef { ret T_ptr(T_i8()); }
// TODO: Enforce via a predicate. // TODO: Enforce via a predicate.
fn type_of(&@crate_ctxt cx, &span sp, &ty::t t) -> TypeRef { fn type_of(&@crate_ctxt cx, &span sp, &ty::t t) -> TypeRef {
if (ty::type_has_dynamic_size(cx.tcx, t)) { if (ty::type_has_dynamic_size(cx.tcx, t)) {
cx.sess.span_err(sp, cx.sess.span_fatal(sp,
"type_of() called on a type with dynamic size: " + "type_of() called on a type with dynamic size: " +
ty_to_str(cx.tcx, t)); ty_to_str(cx.tcx, t));
} }
@ -881,7 +881,7 @@ fn type_of_inner(&@crate_ctxt cx, &span sp, &ty::t t) -> TypeRef {
llty = abs_pair; llty = abs_pair;
} }
case (ty::ty_var(_)) { case (ty::ty_var(_)) {
cx.tcx.sess.span_err(sp, "trans::type_of called on ty_var"); cx.tcx.sess.span_fatal(sp, "trans::type_of called on ty_var");
} }
case (ty::ty_param(_)) { llty = T_i8(); } case (ty::ty_param(_)) { llty = T_i8(); }
case (ty::ty_type) { llty = T_ptr(T_tydesc(cx.tn)); } case (ty::ty_type) { llty = T_ptr(T_tydesc(cx.tn)); }
@ -1226,7 +1226,7 @@ fn simplify_type(&@crate_ctxt ccx, &ty::t typ) -> ty::t {
// Computes the size of the data part of a non-dynamically-sized tag. // Computes the size of the data part of a non-dynamically-sized tag.
fn static_size_of_tag(&@crate_ctxt cx, &span sp, &ty::t t) -> uint { fn static_size_of_tag(&@crate_ctxt cx, &span sp, &ty::t t) -> uint {
if (ty::type_has_dynamic_size(cx.tcx, t)) { if (ty::type_has_dynamic_size(cx.tcx, t)) {
cx.tcx.sess.span_err(sp, cx.tcx.sess.span_fatal(sp,
"dynamically sized type passed to " + "dynamically sized type passed to " +
"static_size_of_tag()"); "static_size_of_tag()");
} }
@ -1236,7 +1236,7 @@ fn static_size_of_tag(&@crate_ctxt cx, &span sp, &ty::t t) -> uint {
alt (ty::struct(cx.tcx, t)) { alt (ty::struct(cx.tcx, t)) {
case (ty::ty_tag(?tid_, ?subtys_)) { tid = tid_; subtys = subtys_; } case (ty::ty_tag(?tid_, ?subtys_)) { tid = tid_; subtys = subtys_; }
case (_) { case (_) {
cx.tcx.sess.span_err(sp, cx.tcx.sess.span_fatal(sp,
"non-tag passed to " + "non-tag passed to " +
"static_size_of_tag()"); "static_size_of_tag()");
} }
@ -5983,7 +5983,7 @@ fn trans_log(int lvl, &@block_ctxt cx, &@ast::expr e) -> result {
case (_) { case (_) {
// FIXME: Support these types. // FIXME: Support these types.
cx.fcx.lcx.ccx.sess.span_err(e.span, cx.fcx.lcx.ccx.sess.span_fatal(e.span,
"log called on unsupported type " "log called on unsupported type "
+ +
ty_to_str(cx.fcx.lcx.ccx.tcx, ty_to_str(cx.fcx.lcx.ccx.tcx,
@ -6088,7 +6088,7 @@ fn trans_break_cont(&span sp, &@block_ctxt cx, bool to_end) -> result {
alt ({ cleanup_cx.parent }) { alt ({ cleanup_cx.parent }) {
case (parent_some(?cx)) { cleanup_cx = cx; } case (parent_some(?cx)) { cleanup_cx = cx; }
case (parent_none) { case (parent_none) {
cx.fcx.lcx.ccx.sess.span_err(sp, cx.fcx.lcx.ccx.sess.span_fatal(sp,
if (to_end) { if (to_end) {
"Break" "Break"
} else { "Cont" } + } else { "Cont" } +
@ -7621,7 +7621,7 @@ fn decl_fn_and_pair(&@crate_ctxt ccx, &span sp, vec[str] path, str flav,
register_fn_pair(ccx, ps, llfty, llfn, id); register_fn_pair(ccx, ps, llfty, llfn, id);
if (is_main) { if (is_main) {
if (ccx.main_fn != none[ValueRef]) { if (ccx.main_fn != none[ValueRef]) {
ccx.sess.span_err(sp, "multiple 'main' functions"); ccx.sess.span_fatal(sp, "multiple 'main' functions");
} }
llvm::LLVMSetLinkage(llfn, llvm::LLVMSetLinkage(llfn,
lib::llvm::LLVMExternalLinkage as llvm::Linkage); lib::llvm::LLVMExternalLinkage as llvm::Linkage);

View file

@ -560,7 +560,7 @@ fn expr_to_constr_arg(ty::ctxt tcx, &@expr e) -> @constr_arg_use {
} }
case (expr_lit(?l, _)) { ret @respan(e.span, carg_lit(l)); } case (expr_lit(?l, _)) { ret @respan(e.span, carg_lit(l)); }
case (_) { case (_) {
tcx.sess.span_err(e.span, tcx.sess.span_fatal(e.span,
"Arguments to constrained functions must be " "Arguments to constrained functions must be "
+ "literals or local variables"); + "literals or local variables");
} }
@ -587,7 +587,7 @@ fn expr_to_constr(ty::ctxt tcx, &@expr e) -> constr {
exprs_to_constr_args(tcx, args)))); exprs_to_constr_args(tcx, args))));
} }
case (_) { case (_) {
tcx.sess.span_err(operator.span, tcx.sess.span_fatal(operator.span,
"Internal error: " + "Internal error: " +
" ill-formed operator \ " ill-formed operator \
in predicate"); in predicate");
@ -595,7 +595,7 @@ fn expr_to_constr(ty::ctxt tcx, &@expr e) -> constr {
} }
} }
case (_) { case (_) {
tcx.sess.span_err(e.span, tcx.sess.span_fatal(e.span,
"Internal error: " + " ill-formed predicate"); "Internal error: " + " ill-formed predicate");
} }
} }
@ -626,7 +626,8 @@ fn substitute_arg(&ty::ctxt cx, &vec[@expr] actuals, @ast::constr_arg a) ->
if (i < num_actuals) { if (i < num_actuals) {
ret expr_to_constr_arg(cx, actuals.(i)); ret expr_to_constr_arg(cx, actuals.(i));
} else { } else {
cx.sess.span_err(a.span, "Constraint argument out of bounds"); cx.sess.span_fatal(a.span,
"Constraint argument out of bounds");
} }
} }
case (carg_base) { ret @respan(a.span, carg_base); } case (carg_base) { ret @respan(a.span, carg_base); }
@ -636,7 +637,7 @@ fn substitute_arg(&ty::ctxt cx, &vec[@expr] actuals, @ast::constr_arg a) ->
fn path_to_ident(&ty::ctxt cx, &path p) -> ident { fn path_to_ident(&ty::ctxt cx, &path p) -> ident {
alt (vec::last(p.node.idents)) { alt (vec::last(p.node.idents)) {
case (none) { cx.sess.span_err(p.span, "Malformed path"); } case (none) { cx.sess.span_fatal(p.span, "Malformed path"); }
case (some(?i)) { ret i; } case (some(?i)) { ret i; }
} }
} }

View file

@ -85,7 +85,7 @@ fn check_states_expr(&fn_ctxt fcx, &@expr e) {
s += bitv_to_str(fcx, prec); s += bitv_to_str(fcx, prec);
s += "\nPrestate:\n"; s += "\nPrestate:\n";
s += bitv_to_str(fcx, pres); s += bitv_to_str(fcx, pres);
fcx.ccx.tcx.sess.span_err(e.span, s); fcx.ccx.tcx.sess.span_fatal(e.span, s);
} }
} }
@ -114,7 +114,7 @@ fn check_states_stmt(&fn_ctxt fcx, &@stmt s) {
ss += bitv_to_str(fcx, prec); ss += bitv_to_str(fcx, prec);
ss += "\nPrestate: \n"; ss += "\nPrestate: \n";
ss += bitv_to_str(fcx, pres); ss += bitv_to_str(fcx, pres);
fcx.ccx.tcx.sess.span_err(s.span, ss); fcx.ccx.tcx.sess.span_fatal(s.span, ss);
} }
} }
@ -153,7 +153,7 @@ fn check_states_against_conditions(&fn_ctxt fcx, &_fn f, &ann a,
"In function " + fcx.name + "In function " + fcx.name +
", not all control paths \ ", not all control paths \
return a value"); return a value");
fcx.ccx.tcx.sess.span_err(f.decl.output.span, fcx.ccx.tcx.sess.span_fatal(f.decl.output.span,
"see declared return type of '" + "see declared return type of '" +
ty_to_str(*f.decl.output) + "'"); ty_to_str(*f.decl.output) + "'");
} else if (f.decl.cf == noreturn) { } else if (f.decl.cf == noreturn) {
@ -162,7 +162,7 @@ fn check_states_against_conditions(&fn_ctxt fcx, &_fn f, &ann a,
// the fcx.id bit means "returns" for a returning fn, // the fcx.id bit means "returns" for a returning fn,
// "diverges" for a non-returning fn // "diverges" for a non-returning fn
if (!promises(fcx, post, ret_c)) { if (!promises(fcx, post, ret_c)) {
fcx.ccx.tcx.sess.span_err(f.body.span, fcx.ccx.tcx.sess.span_fatal(f.body.span,
"In non-returning function " + fcx.name "In non-returning function " + fcx.name
+ +
", some control paths may \ ", some control paths may \

View file

@ -1679,7 +1679,7 @@ fn field_num(&session::session sess, &span sp, &ast::ident id) -> uint {
for (u8 c in id) { for (u8 c in id) {
if (i == 0u) { if (i == 0u) {
if (c != '_' as u8) { if (c != '_' as u8) {
sess.span_err(sp, sess.span_fatal(sp,
"bad numeric field on tuple: " + "bad numeric field on tuple: " +
"missing leading underscore"); "missing leading underscore");
} }
@ -1690,7 +1690,7 @@ fn field_num(&session::session sess, &span sp, &ast::ident id) -> uint {
} else { } else {
auto s = ""; auto s = "";
s += str::unsafe_from_byte(c); s += str::unsafe_from_byte(c);
sess.span_err(sp, sess.span_fatal(sp,
"bad numeric field on tuple: " + "bad numeric field on tuple: " +
" non-digit character: " + s); " non-digit character: " + s);
} }
@ -1704,14 +1704,14 @@ fn field_idx(&session::session sess, &span sp, &ast::ident id,
&vec[field] fields) -> uint { &vec[field] fields) -> uint {
let uint i = 0u; let uint i = 0u;
for (field f in fields) { if (str::eq(f.ident, id)) { ret i; } i += 1u; } for (field f in fields) { if (str::eq(f.ident, id)) { ret i; } i += 1u; }
sess.span_err(sp, "unknown field '" + id + "' of record"); sess.span_fatal(sp, "unknown field '" + id + "' of record");
} }
fn method_idx(&session::session sess, &span sp, &ast::ident id, fn method_idx(&session::session sess, &span sp, &ast::ident id,
&vec[method] meths) -> uint { &vec[method] meths) -> uint {
let uint i = 0u; let uint i = 0u;
for (method m in meths) { if (str::eq(m.ident, id)) { ret i; } i += 1u; } for (method m in meths) { if (str::eq(m.ident, id)) { ret i; } i += 1u; }
sess.span_err(sp, "unknown method '" + id + "' of obj"); sess.span_fatal(sp, "unknown method '" + id + "' of obj");
} }
fn sort_methods(&vec[method] meths) -> vec[method] { fn sort_methods(&vec[method] meths) -> vec[method] {

View file

@ -114,7 +114,7 @@ fn ty_param_count_and_ty_for_def(&@fn_ctxt fcx, &span sp, &ast::def defn) ->
ret tup(0u, ty::mk_nil(fcx.ccx.tcx)); ret tup(0u, ty::mk_nil(fcx.ccx.tcx));
} }
case (ast::def_ty(_)) { case (ast::def_ty(_)) {
fcx.ccx.tcx.sess.span_err(sp, "expected value but found type"); fcx.ccx.tcx.sess.span_fatal(sp, "expected value but found type");
} }
case (_) { case (_) {
// FIXME: handle other names. // FIXME: handle other names.
@ -152,7 +152,7 @@ fn instantiate_path(&@fn_ctxt fcx, &ast::path pth, &ty_param_count_and_ty tpt,
} }
ty_substs_opt = some[vec[ty::t]](ty_substs); ty_substs_opt = some[vec[ty::t]](ty_substs);
if (ty_param_count == 0u) { if (ty_param_count == 0u) {
fcx.ccx.tcx.sess.span_err(sp, fcx.ccx.tcx.sess.span_fatal(sp,
"this item does not take type " + "this item does not take type " +
"parameters"); "parameters");
fail; fail;
@ -188,7 +188,7 @@ fn structurally_resolved_type(&@fn_ctxt fcx, &span sp, ty::t typ) -> ty::t {
alt (r) { alt (r) {
case (fix_ok(?typ_s)) { ret typ_s; } case (fix_ok(?typ_s)) { ret typ_s; }
case (fix_err(_)) { case (fix_err(_)) {
fcx.ccx.tcx.sess.span_err(sp, fcx.ccx.tcx.sess.span_fatal(sp,
"the type of this value must be " + "the type of this value must be " +
"known in this context"); "known in this context");
} }
@ -219,7 +219,7 @@ fn ast_ty_to_ty(&ty::ctxt tcx, &ty_getter getter, &@ast::ty ast_ty) -> ty::t {
alt (tcx.ast_ty_to_ty_cache.find(ast_ty)) { alt (tcx.ast_ty_to_ty_cache.find(ast_ty)) {
case (some[option::t[ty::t]](some[ty::t](?ty))) { ret ty; } case (some[option::t[ty::t]](some[ty::t](?ty))) { ret ty; }
case (some[option::t[ty::t]](none)) { case (some[option::t[ty::t]](none)) {
tcx.sess.span_err(ast_ty.span, tcx.sess.span_fatal(ast_ty.span,
"illegal recursive type " + "illegal recursive type " +
"(insert a tag in the cycle, " + "(insert a tag in the cycle, " +
"if this is desired)"); "if this is desired)");
@ -252,7 +252,7 @@ fn ast_ty_to_ty(&ty::ctxt tcx, &ty_getter getter, &@ast::ty ast_ty) -> ty::t {
} }
if (vec::len(param_bindings) != if (vec::len(param_bindings) !=
ty::count_ty_params(tcx, params_opt_and_ty._1)) { ty::count_ty_params(tcx, params_opt_and_ty._1)) {
tcx.sess.span_err(sp, tcx.sess.span_fatal(sp,
"Wrong number of type arguments for a" + "Wrong number of type arguments for a" +
" polymorphic tag"); " polymorphic tag");
} }
@ -333,7 +333,7 @@ fn ast_ty_to_ty(&ty::ctxt tcx, &ty_getter getter, &@ast::ty ast_ty) -> ty::t {
} }
case (ast::def_ty_arg(?id)) { typ = ty::mk_param(tcx, id); } case (ast::def_ty_arg(?id)) { typ = ty::mk_param(tcx, id); }
case (_) { case (_) {
tcx.sess.span_err(ast_ty.span, tcx.sess.span_fatal(ast_ty.span,
"found type name used as a variable"); "found type name used as a variable");
} }
} }
@ -508,7 +508,7 @@ mod collect {
if (ty::type_has_dynamic_size(cx.tcx, tt)) { if (ty::type_has_dynamic_size(cx.tcx, tt)) {
alt (ty_mode) { alt (ty_mode) {
case (mo_val) { case (mo_val) {
cx.tcx.sess.span_err(a.ty.span, cx.tcx.sess.span_fatal(a.ty.span,
"Dynamically sized arguments \ "Dynamically sized arguments \
must be passed by alias"); must be passed by alias");
} }
@ -916,7 +916,7 @@ mod demand {
case (ures_err(?err)) { case (ures_err(?err)) {
auto e_err = resolve_type_vars_if_possible(fcx, expected_1); auto e_err = resolve_type_vars_if_possible(fcx, expected_1);
auto a_err = resolve_type_vars_if_possible(fcx, actual_1); auto a_err = resolve_type_vars_if_possible(fcx, actual_1);
fcx.ccx.tcx.sess.span_err(sp, fcx.ccx.tcx.sess.span_fatal(sp,
"mismatched types: expected " + "mismatched types: expected " +
ty_to_str(fcx.ccx.tcx, e_err) + ty_to_str(fcx.ccx.tcx, e_err) +
" but found " + " but found " +
@ -982,7 +982,7 @@ mod writeback {
alt (ty::unify::fixup_vars(fcx.ccx.tcx, fcx.var_bindings, typ)) { alt (ty::unify::fixup_vars(fcx.ccx.tcx, fcx.var_bindings, typ)) {
case (fix_ok(?new_type)) { ret new_type; } case (fix_ok(?new_type)) { ret new_type; }
case (fix_err(?vid)) { case (fix_err(?vid)) {
fcx.ccx.tcx.sess.span_err(sp, fcx.ccx.tcx.sess.span_fatal(sp,
"cannot determine a type \ "cannot determine a type \
for this expression"); for this expression");
} }
@ -1026,7 +1026,7 @@ mod writeback {
write::ty_only(fcx.ccx.tcx, l.node.ann.id, lty); write::ty_only(fcx.ccx.tcx, l.node.ann.id, lty);
} }
case (fix_err(_)) { case (fix_err(_)) {
fcx.ccx.tcx.sess.span_err(l.span, fcx.ccx.tcx.sess.span_fatal(l.span,
"cannot determine a type \ "cannot determine a type \
for this local variable"); for this local variable");
} }
@ -1232,7 +1232,7 @@ fn check_pat(&@fn_ctxt fcx, &@ast::pat pat, ty::t expected) {
// FIXME: Switch expected and actual in this message? I // FIXME: Switch expected and actual in this message? I
// can never tell. // can never tell.
fcx.ccx.tcx.sess.span_err(pat.span, fcx.ccx.tcx.sess.span_fatal(pat.span,
#fmt("mismatched types: \ #fmt("mismatched types: \
expected tag, found %s", expected tag, found %s",
ty_to_str(fcx.ccx.tcx, ty_to_str(fcx.ccx.tcx,
@ -1271,7 +1271,7 @@ fn check_pat(&@fn_ctxt fcx, &@ast::pat pat, ty::t expected) {
if (arg_len == 1u) { if (arg_len == 1u) {
"" ""
} else { "s" }); } else { "s" });
fcx.ccx.tcx.sess.span_err(pat.span, s); fcx.ccx.tcx.sess.span_fatal(pat.span, s);
} }
// TODO: vec::iter2 // TODO: vec::iter2
@ -1285,7 +1285,7 @@ fn check_pat(&@fn_ctxt fcx, &@ast::pat pat, ty::t expected) {
// TODO (issue #448): Wrap a #fmt string over multiple // TODO (issue #448): Wrap a #fmt string over multiple
// lines... // lines...
fcx.ccx.tcx.sess.span_err(pat.span, fcx.ccx.tcx.sess.span_fatal(pat.span,
#fmt("this pattern has %u field%s, \ #fmt("this pattern has %u field%s, \
but the corresponding \ but the corresponding \
variant has no fields", variant has no fields",
@ -1303,7 +1303,7 @@ fn require_impure(&session::session sess, &ast::purity f_purity, &span sp) {
alt (f_purity) { alt (f_purity) {
case (ast::impure_fn) { ret; } case (ast::impure_fn) { ret; }
case (ast::pure_fn) { case (ast::pure_fn) {
sess.span_err(sp, sess.span_fatal(sp,
"Found impure expression in pure function decl"); "Found impure expression in pure function decl");
} }
} }
@ -1328,14 +1328,14 @@ fn require_pure_call(@crate_ctxt ccx, &ast::purity caller_purity,
alt (get_function_purity(ccx, d_id)) { alt (get_function_purity(ccx, d_id)) {
case (ast::pure_fn) { ret; } case (ast::pure_fn) { ret; }
case (_) { case (_) {
ccx.tcx.sess.span_err(sp, ccx.tcx.sess.span_fatal(sp,
"Pure function calls \ "Pure function calls \
impure function"); impure function");
} }
} }
} }
case (_) { case (_) {
ccx.tcx.sess.span_err(sp, ccx.tcx.sess.span_fatal(sp,
"Pure function calls \ "Pure function calls \
unknown function"); unknown function");
} }
@ -1347,7 +1347,7 @@ fn require_pure_call(@crate_ctxt ccx, &ast::purity caller_purity,
fn require_pure_function(@crate_ctxt ccx, &ast::def_id d_id, &span sp) { fn require_pure_function(@crate_ctxt ccx, &ast::def_id d_id, &span sp) {
alt (get_function_purity(ccx, d_id)) { alt (get_function_purity(ccx, d_id)) {
case (ast::impure_fn) { case (ast::impure_fn) {
ccx.tcx.sess.span_err(sp, ccx.tcx.sess.span_fatal(sp,
"Found non-predicate in check expression"); "Found non-predicate in check expression");
} }
case (_) { ret; } case (_) { ret; }
@ -1376,7 +1376,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
case (ty::ty_fn(_, ?arg_tys_0, _, _, _)) { arg_tys = arg_tys_0; } case (ty::ty_fn(_, ?arg_tys_0, _, _, _)) { arg_tys = arg_tys_0; }
case (ty::ty_native_fn(_, ?arg_tys_0, _)) { arg_tys = arg_tys_0; } case (ty::ty_native_fn(_, ?arg_tys_0, _)) { arg_tys = arg_tys_0; }
case (_) { case (_) {
fcx.ccx.tcx.sess.span_err(f.span, fcx.ccx.tcx.sess.span_fatal(f.span,
"mismatched types: \ "mismatched types: \
expected function or native \ expected function or native \
function but found " function but found "
@ -1388,7 +1388,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
auto expected_arg_count = vec::len[ty::arg](arg_tys); auto expected_arg_count = vec::len[ty::arg](arg_tys);
auto supplied_arg_count = vec::len[option::t[@ast::expr]](args); auto supplied_arg_count = vec::len[option::t[@ast::expr]](args);
if (expected_arg_count != supplied_arg_count) { if (expected_arg_count != supplied_arg_count) {
fcx.ccx.tcx.sess.span_err(sp, fcx.ccx.tcx.sess.span_fatal(sp,
#fmt("this function takes %u \ #fmt("this function takes %u \
parameter%s but %u parameter%s \ parameter%s but %u parameter%s \
supplied", supplied",
@ -1474,7 +1474,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
if (!ast::is_constraint_arg(operand)) { if (!ast::is_constraint_arg(operand)) {
auto s = "Constraint args must be \ auto s = "Constraint args must be \
slot variables or literals"; slot variables or literals";
fcx.ccx.tcx.sess.span_err(e.span, s); fcx.ccx.tcx.sess.span_fatal(e.span, s);
} }
} }
require_pure_function(fcx.ccx, d_id, e.span); require_pure_function(fcx.ccx, d_id, e.span);
@ -1482,12 +1482,12 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
case (_) { case (_) {
auto s = "In a constraint, expected the \ auto s = "In a constraint, expected the \
constraint name to be an explicit name"; constraint name to be an explicit name";
fcx.ccx.tcx.sess.span_err(e.span,s); fcx.ccx.tcx.sess.span_fatal(e.span,s);
} }
} }
} }
case (_) { case (_) {
fcx.ccx.tcx.sess.span_err(e.span, fcx.ccx.tcx.sess.span_fatal(e.span,
"check on non-predicate"); "check on non-predicate");
} }
} }
@ -1555,7 +1555,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
case (_) { case (_) {
auto s = "dereferencing non-box type: " + auto s = "dereferencing non-box type: " +
ty_to_str(fcx.ccx.tcx, oper_t); ty_to_str(fcx.ccx.tcx, oper_t);
fcx.ccx.tcx.sess.span_err(expr.span, s); fcx.ccx.tcx.sess.span_fatal(expr.span, s);
} }
} }
} }
@ -1563,7 +1563,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
if (!type_is_integral(fcx, oper.span, oper_t) && if (!type_is_integral(fcx, oper.span, oper_t) &&
structure_of(fcx, oper.span, oper_t) != structure_of(fcx, oper.span, oper_t) !=
ty::ty_bool) { ty::ty_bool) {
fcx.ccx.tcx.sess.span_err(expr.span, fcx.ccx.tcx.sess.span_fatal(expr.span,
#fmt("mismatched types: \ #fmt("mismatched types: \
expected bool or \ expected bool or \
integer but found %s", integer but found %s",
@ -1588,7 +1588,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
// supplied some, that's an error. // supplied some, that's an error.
if (vec::len[@ast::ty](pth.node.types) > 0u) { if (vec::len[@ast::ty](pth.node.types) > 0u) {
fcx.ccx.tcx.sess.span_err(expr.span, fcx.ccx.tcx.sess.span_fatal(expr.span,
"this kind of value does not \ "this kind of value does not \
take type parameters"); take type parameters");
} }
@ -1607,7 +1607,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
case (none) { case (none) {
auto nil = ty::mk_nil(fcx.ccx.tcx); auto nil = ty::mk_nil(fcx.ccx.tcx);
if (!are_compatible(fcx, fcx.ret_ty, nil)) { if (!are_compatible(fcx, fcx.ret_ty, nil)) {
fcx.ccx.tcx.sess.span_err(expr.span, fcx.ccx.tcx.sess.span_fatal(expr.span,
"ret; in function \ "ret; in function \
returning non-nil"); returning non-nil");
} }
@ -1627,7 +1627,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
case (none) { case (none) {
auto nil = ty::mk_nil(fcx.ccx.tcx); auto nil = ty::mk_nil(fcx.ccx.tcx);
if (!are_compatible(fcx, fcx.ret_ty, nil)) { if (!are_compatible(fcx, fcx.ret_ty, nil)) {
fcx.ccx.tcx.sess.span_err(expr.span, fcx.ccx.tcx.sess.span_fatal(expr.span,
"put; in iterator \ "put; in iterator \
yielding non-nil"); yielding non-nil");
} }
@ -1696,7 +1696,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
but found %s", but found %s",
ty_to_str(fcx.ccx.tcx, ty_to_str(fcx.ccx.tcx,
lhs_t)); lhs_t));
fcx.ccx.tcx.sess.span_err(expr.span,s); fcx.ccx.tcx.sess.span_fatal(expr.span,s);
} }
} }
write::ty_only_fixup(fcx, a.id, chan_t); write::ty_only_fixup(fcx, a.id, chan_t);
@ -1726,7 +1726,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
elt_ty = ty::mk_mach(fcx.ccx.tcx, util::common::ty_u8); elt_ty = ty::mk_mach(fcx.ccx.tcx, util::common::ty_u8);
} }
case (_) { case (_) {
fcx.ccx.tcx.sess.span_err(expr.span, fcx.ccx.tcx.sess.span_fatal(expr.span,
"type of for loop iterator \ "type of for loop iterator \
is not a vector or string"); is not a vector or string");
} }
@ -1916,7 +1916,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
if (!(type_is_scalar(fcx, expr.span, expr_ty(fcx.ccx.tcx, e)) && if (!(type_is_scalar(fcx, expr.span, expr_ty(fcx.ccx.tcx, e)) &&
type_is_scalar(fcx, expr.span, t_1))) { type_is_scalar(fcx, expr.span, t_1))) {
fcx.ccx.tcx.sess.span_err(expr.span, fcx.ccx.tcx.sess.span_fatal(expr.span,
"non-scalar cast: " + "non-scalar cast: " +
ty_to_str(fcx.ccx.tcx, ty_to_str(fcx.ccx.tcx,
expr_ty(fcx.ccx.tcx, expr_ty(fcx.ccx.tcx,
@ -1984,7 +1984,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
alt (structure_of(fcx, expr.span, bexpr_t)) { alt (structure_of(fcx, expr.span, bexpr_t)) {
case (ty::ty_rec(?flds)) { base_fields = flds; } case (ty::ty_rec(?flds)) { base_fields = flds; }
case (_) { case (_) {
fcx.ccx.tcx.sess.span_err(expr.span, fcx.ccx.tcx.sess.span_fatal(expr.span,
"record update \ "record update \
non-record base"); non-record base");
} }
@ -2000,7 +2000,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
} }
} }
if (!found) { if (!found) {
fcx.ccx.tcx.sess.span_err(expr.span, fcx.ccx.tcx.sess.span_fatal(expr.span,
"unknown field in \ "unknown field in \
record update: " record update: "
+ f.ident); + f.ident);
@ -2018,7 +2018,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
let uint ix = let uint ix =
ty::field_num(fcx.ccx.tcx.sess, expr.span, field); ty::field_num(fcx.ccx.tcx.sess, expr.span, field);
if (ix >= vec::len[ty::mt](args)) { if (ix >= vec::len[ty::mt](args)) {
fcx.ccx.tcx.sess.span_err(expr.span, fcx.ccx.tcx.sess.span_fatal(expr.span,
"bad index on tuple"); "bad index on tuple");
} }
write::ty_only_fixup(fcx, a.id, args.(ix).ty); write::ty_only_fixup(fcx, a.id, args.(ix).ty);
@ -2028,7 +2028,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
ty::field_idx(fcx.ccx.tcx.sess, expr.span, field, ty::field_idx(fcx.ccx.tcx.sess, expr.span, field,
fields); fields);
if (ix >= vec::len[ty::field](fields)) { if (ix >= vec::len[ty::field](fields)) {
fcx.ccx.tcx.sess.span_err(expr.span, fcx.ccx.tcx.sess.span_fatal(expr.span,
"bad index on record"); "bad index on record");
} }
write::ty_only_fixup(fcx, a.id, fields.(ix).mt.ty); write::ty_only_fixup(fcx, a.id, fields.(ix).mt.ty);
@ -2038,7 +2038,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
ty::method_idx(fcx.ccx.tcx.sess, expr.span, field, ty::method_idx(fcx.ccx.tcx.sess, expr.span, field,
methods); methods);
if (ix >= vec::len[ty::method](methods)) { if (ix >= vec::len[ty::method](methods)) {
fcx.ccx.tcx.sess.span_err(expr.span, fcx.ccx.tcx.sess.span_fatal(expr.span,
"bad index on obj"); "bad index on obj");
} }
auto meth = methods.(ix); auto meth = methods.(ix);
@ -2063,7 +2063,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
check_expr(fcx, idx); check_expr(fcx, idx);
auto idx_t = expr_ty(fcx.ccx.tcx, idx); auto idx_t = expr_ty(fcx.ccx.tcx, idx);
if (!type_is_integral(fcx, idx.span, idx_t)) { if (!type_is_integral(fcx, idx.span, idx_t)) {
fcx.ccx.tcx.sess.span_err(idx.span, fcx.ccx.tcx.sess.span_fatal(idx.span,
"mismatched types: expected \ "mismatched types: expected \
integer but found " integer but found "
+ ty_to_str(fcx.ccx.tcx, idx_t)); + ty_to_str(fcx.ccx.tcx, idx_t));
@ -2084,7 +2084,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
write::ty_only_fixup(fcx, a.id, typ); write::ty_only_fixup(fcx, a.id, typ);
} }
case (_) { case (_) {
fcx.ccx.tcx.sess.span_err(expr.span, fcx.ccx.tcx.sess.span_fatal(expr.span,
"vector-indexing bad type: " + "vector-indexing bad type: " +
ty_to_str(fcx.ccx.tcx, ty_to_str(fcx.ccx.tcx,
base_t)); base_t));
@ -2105,7 +2105,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
write::ty_only_fixup(fcx, a.id, ct); write::ty_only_fixup(fcx, a.id, ct);
} }
case (_) { case (_) {
fcx.ccx.tcx.sess.span_err(expr.span, fcx.ccx.tcx.sess.span_fatal(expr.span,
"bad port type: " + "bad port type: " +
ty_to_str(fcx.ccx.tcx, ty_to_str(fcx.ccx.tcx,
port_t)); port_t));
@ -2218,7 +2218,7 @@ fn ast_constr_to_constr(ty::ctxt tcx, &@ast::constr c)
id=pred_id)); id=pred_id));
} }
case (_) { case (_) {
tcx.sess.span_err(c.span, "Predicate " tcx.sess.span_fatal(c.span, "Predicate "
+ path_to_str(c.node.path) + path_to_str(c.node.path)
+ " is unbound or bound to a non-function"); + " is unbound or bound to a non-function");
} }
@ -2339,7 +2339,7 @@ fn check_fn(&@crate_ctxt ccx, &ast::fn_decl decl, ast::proto proto,
// per the previous comment, this just checks that the declared // per the previous comment, this just checks that the declared
// type is bool, and trusts that that's the actual return type. // type is bool, and trusts that that's the actual return type.
if (!ty::type_is_bool(ccx.tcx, fcx.ret_ty)) { if (!ty::type_is_bool(ccx.tcx, fcx.ret_ty)) {
ccx.tcx.sess.span_err(body.span, ccx.tcx.sess.span_fatal(body.span,
"Non-boolean return type in pred"); "Non-boolean return type in pred");
} }
} }