1
Fork 0

Revert previous 6 commits. Hopefully put out Windows fire.

Revert "rustc: Export only what's needed from middle::ty"

This reverts commit 4255d58aa5.

Revert "rustc: Make name resolution errors less fatal"

This reverts commit b8ab9ea89c.

Revert "rustc: Make import resolution errors less fatal"

This reverts commit 92a8ae94b9.

Revert "rustc: Export only what's used from middle::resolve"

This reverts commit 4539a2cf7a.

Revert "rustc: Re-introduce session.span_err, session.err"

This reverts commit 7fe9a88e31.

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

This reverts commit c394a7f49a.
This commit is contained in:
Brian Anderson 2011-06-19 03:24:42 -07:00
parent 4255d58aa5
commit cf9ed08a50
16 changed files with 191 additions and 449 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.fatal(msg); sess.err(msg);
} else { sess.fatal(msg + ": " + str::str_from_cstr(buf)); } } else { sess.err(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_fatal(v.(1).span, #fmt("duplicate meta '%s'", k)); sess.span_err(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.fatal("unknown input file type: " + input); fail }; } else { sess.err("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 {
@ -272,7 +272,7 @@ fn build_session(@session::options sopts) -> session::session {
auto target_crate_num = 0; auto target_crate_num = 0;
auto sess = auto sess =
session::session(target_crate_num, target_cfg, sopts, crate_cache, session::session(target_crate_num, target_cfg, sopts, crate_cache,
front::codemap::new_codemap(), 0u); front::codemap::new_codemap());
ret sess; ret sess;
} }
@ -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.fatal("argument to `pretty` must be one of `normal`, `typed`, or " + sess.err("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.fatal("No input files allowed with --glue."); sess.err("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.fatal("No input filename given."); sess.err("No input filename given.");
} else if (n_inputs > 1u) { } else if (n_inputs > 1u) {
sess.fatal("Multiple input filenames provided."); sess.err("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

@ -66,34 +66,20 @@ obj session(ast::crate_num cnum,
@config targ_cfg, @config targ_cfg,
@options opts, @options opts,
map::hashmap[int, crate_metadata] crates, map::hashmap[int, crate_metadata] crates,
codemap::codemap cm, codemap::codemap cm) {
mutable uint err_count) {
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_fatal(span sp, str msg) -> ! { fn span_err(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 fatal(str msg) -> ! { fn err(str msg) -> ! {
emit_diagnostic(none[span], msg, "error", 9u8, cm); emit_diagnostic(none[span], msg, "error", 9u8, cm);
fail; fail;
} }
fn span_err(span sp, str msg) {
emit_diagnostic(some(sp), msg, "error", 9u8, cm);
err_count += 1u;
}
fn err(span sp, str msg) {
emit_diagnostic(some(sp), msg, "error", 9u8, cm);
err_count += 1u;
}
fn abort_if_errors() {
if (err_count > 0u) {
self.fatal("aborting due to previous errors");
}
}
fn span_warn(span sp, str msg) { fn span_warn(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.
@ -108,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_fatal(sp, #fmt("internal compiler error %s", msg)); self.span_err(sp, #fmt("internal compiler error %s", msg));
} }
fn bug(str msg) -> ! { fn bug(str msg) -> ! {
self.fatal(#fmt("internal compiler error %s", msg)); self.err(#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_fatal(sp, "unknown variable: " + i) sess.span_err(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_fatal(sp, "evaluating unsupported literal") } case (_) { cx.sess.span_err(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_fatal(x.span, "evaluating structured path-name"); cx.sess.span_err(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_fatal(x.span, "bad types in '!' expression"); cx.sess.span_err(x.span, "bad types in '!' expression");
} }
case (_) { case (_) {
cx.sess.span_fatal(x.span, "evaluating unsupported unop"); cx.sess.span_err(x.span, "evaluating unsupported unop");
} }
} }
} }
@ -108,45 +108,43 @@ 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_fatal(x.span, "bad types in '+' expression"); cx.sess.span_err(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_fatal(x.span, "bad types in '-' expression"); cx.sess.span_err(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_fatal(x.span, "bad types in '*' expression"); cx.sess.span_err(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_fatal(x.span, "bad types in '/' expression"); cx.sess.span_err(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_fatal(x.span, "bad types in '%' expression"); cx.sess.span_err(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_fatal(x.span, cx.sess.span_err(x.span, "bad types in '&&' expression");
"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_fatal(x.span, cx.sess.span_err(x.span, "bad types in '||' expression");
"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));
@ -155,13 +153,12 @@ 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_fatal(x.span, cx.sess.span_err(x.span, "evaluating unsupported binop");
"evaluating unsupported binop");
} }
} }
} }
case (_) { case (_) {
cx.sess.span_fatal(x.span, "evaluating unsupported expression"); cx.sess.span_err(x.span, "evaluating unsupported expression");
} }
} }
fail; fail;
@ -174,7 +171,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_fatal(sp, "bad types in comparison") } } else { sess.span_err(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,
@ -203,7 +200,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_fatal(s.span, cx.sess.span_err(s.span,
"unsupported stmt in crate-directive block"); "unsupported stmt in crate-directive block");
} }
} }
@ -217,7 +214,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_fatal(x.span, "bad cond type in 'if'"); cx.sess.span_err(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,
@ -252,18 +249,18 @@ fn eval_crate_directive_expr(ctx cx, env e, @ast::expr x, str prefix,
items); items);
} }
case (_) { case (_) {
cx.sess.span_fatal(arm.pat.span, cx.sess.span_err(arm.pat.span,
"bad pattern type in 'alt'"); "bad pattern type in 'alt'");
} }
} }
} }
cx.sess.span_fatal(x.span, "no cases matched in 'alt'"); cx.sess.span_err(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_fatal(x.span, "unsupported expr type"); } case (_) { cx.sess.span_err(x.span, "unsupported expr type"); }
} }
} }

View file

@ -31,23 +31,21 @@ 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_fatal, rec(span_msg_fn span_err, span_msg_fn span_unimpl, next_ann_fn next_ann);
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_fatal_(session sess, span sp, str msg) -> ! { fn ext_span_err_(session sess, span sp, str msg) -> ! {
sess.span_fatal(sp, msg); sess.span_err(sp, msg);
} }
auto ext_span_fatal = bind ext_span_fatal_(sess, _, _); auto ext_span_err = bind ext_span_err_(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_fatal=ext_span_fatal, ret rec(span_err=ext_span_err,
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_fatal(sp, "malformed #env call"); cx.span_err(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_fatal(l.span, "malformed #env call"); } case (_) { cx.span_err(l.span, "malformed #env call"); }
} }
} }
case (_) { cx.span_fatal(expr.span, "malformed #env call"); } case (_) { cx.span_err(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_fatal(sp, "#fmt requires a format string"); cx.span_err(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_fatal(sp, msg); cx.span_err(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_fatal(l.span, err_msg); } case (_) { cx.span_err(l.span, err_msg); }
} }
} }
case (_) { cx.span_fatal(expr.span, err_msg); } case (_) { cx.span_err(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_fatal(sp, cx.span_err(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_fatal(sp, cx.span_err(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_fatal(sp, cx.span_err(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_fatal(sp, cx.span_err(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_fatal(rec(lo=chpos, hi=chpos), m); } fn err(str m) { sess.span_err(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_fatal(rec(lo=lo, hi=hi), m); } fn err(str m) -> ! { sess.span_err(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_fatal(p.get_span(), p.get_session().span_err(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_fatal(ex.span, cx.tcx.sess.span_err(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_fatal(arg.span, m); cx.tcx.sess.span_err(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_fatal(f.span, cx.tcx.sess.span_err(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_fatal(args.(i).span, cx.tcx.sess.span_err(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_fatal(args.(root._0).span, cx.tcx.sess.span_err(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_fatal(dest.span, cx.tcx.sess.span_err(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_fatal(dest.span, cx.tcx.sess.span_err(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_fatal(dest.span, "assignment to non-lvalue"); cx.tcx.sess.span_err(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_fatal(dest.span, cx.tcx.sess.span_err(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_fatal(msg._0, cx.tcx.sess.span_err(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

@ -25,9 +25,6 @@ import std::option::none;
import std::str; import std::str;
import std::vec; import std::vec;
export resolve_crate;
export def_map;
export crate_map;
// Resolving happens in two passes. The first pass collects defids of all // Resolving happens in two passes. The first pass collects defids of all
// (internal) imports and modules, so that they can be looked up when needed, // (internal) imports and modules, so that they can be looked up when needed,
@ -236,11 +233,8 @@ fn map_crate(&@env e, &@ast::crate c) {
case ( case (
//if it really is a glob import, that is //if it really is a glob import, that is
ast::view_item_import_glob(?path, _)) { ast::view_item_import_glob(?path, _)) {
auto imp = follow_import(*e, sc, path, vi.span);
if (option::is_some(imp)) {
find_mod(e, sc).glob_imports += find_mod(e, sc).glob_imports +=
[option::get(imp)]; [follow_import(*e, sc, path, vi.span)];
}
} }
case (_) { } case (_) { }
} }
@ -254,7 +248,6 @@ fn resolve_imports(&env e) {
case (resolved(_, _, _)) { } case (resolved(_, _, _)) { }
} }
} }
e.sess.abort_if_errors();
} }
fn resolve_names(&@env e, &@ast::crate c) { fn resolve_names(&@env e, &@ast::crate c) {
@ -269,15 +262,14 @@ fn resolve_names(&@env e, &@ast::crate c) {
visit_fn=bind visit_fn_with_scope(e, _, _, _, _, _, _, _, _) visit_fn=bind visit_fn_with_scope(e, _, _, _, _, _, _, _, _)
with *visit::default_visitor()); with *visit::default_visitor());
visit::visit_crate(*c, cons(scope_crate(c), @nil), visit::vtor(v)); visit::visit_crate(*c, cons(scope_crate(c), @nil), visit::vtor(v));
e.sess.abort_if_errors();
fn walk_expr(@env e, &@ast::expr exp, &scopes sc, &vt[scopes] v) { fn walk_expr(@env e, &@ast::expr exp, &scopes sc, &vt[scopes] v) {
visit_expr_with_scope(exp, sc, v); visit_expr_with_scope(exp, sc, v);
alt (exp.node) { alt (exp.node) {
case (ast::expr_path(?p, ?a)) { case (ast::expr_path(?p, ?a)) {
maybe_insert(e, a.id, auto df =
lookup_path_strict(*e, sc, exp.span, lookup_path_strict(*e, sc, exp.span, p.node.idents,
p.node.idents, ns_value)); ns_value);
e.def_map.insert(a.id, df);
} }
case (_) { } case (_) { }
} }
@ -286,17 +278,19 @@ fn resolve_names(&@env e, &@ast::crate c) {
visit::visit_ty(t, sc, v); visit::visit_ty(t, sc, v);
alt (t.node) { alt (t.node) {
case (ast::ty_path(?p, ?a)) { case (ast::ty_path(?p, ?a)) {
maybe_insert(e, a.id, auto new_def =
lookup_path_strict(*e, sc, t.span, lookup_path_strict(*e, sc, t.span, p.node.idents,
p.node.idents, ns_type)); ns_type);
e.def_map.insert(a.id, new_def);
} }
case (_) { } case (_) { }
} }
} }
fn walk_constr(@env e, &@ast::constr c, &scopes sc, &vt[scopes] v) { fn walk_constr(@env e, &@ast::constr c, &scopes sc, &vt[scopes] v) {
maybe_insert(e, c.node.ann.id, auto new_def =
lookup_path_strict(*e, sc, c.span, lookup_path_strict(*e, sc, c.span, c.node.path.node.idents,
c.node.path.node.idents, ns_value)); ns_value);
e.def_map.insert(c.node.ann.id, new_def);
} }
fn walk_arm(@env e, &ast::arm a, &scopes sc, &vt[scopes] v) { fn walk_arm(@env e, &ast::arm a, &scopes sc, &vt[scopes] v) {
walk_pat(*e, sc, a.pat); walk_pat(*e, sc, a.pat);
@ -308,13 +302,9 @@ fn resolve_names(&@env e, &@ast::crate c) {
auto fnd = auto fnd =
lookup_path_strict(e, sc, p.span, p.node.idents, lookup_path_strict(e, sc, p.span, p.node.idents,
ns_value); ns_value);
if (option::is_some(fnd)) { alt (fnd) {
alt (option::get(fnd)) {
case (ast::def_variant(?did, ?vid)) { case (ast::def_variant(?did, ?vid)) {
e.def_map.insert(a.id, option::get(fnd)); e.def_map.insert(a.id, fnd);
for (@ast::pat child in children) {
walk_pat(e, sc, child);
}
} }
case (_) { case (_) {
e.sess.span_err(p.span, e.sess.span_err(p.span,
@ -322,18 +312,11 @@ fn resolve_names(&@env e, &@ast::crate c) {
ast::path_name(p)); ast::path_name(p));
} }
} }
} for (@ast::pat child in children) { walk_pat(e, sc, child); }
} }
case (_) { } case (_) { }
} }
} }
fn maybe_insert(@env e, uint id,
option::t[def] def) {
if (option::is_some(def)) {
e.def_map.insert(id, option::get(def));
}
}
} }
@ -383,40 +366,32 @@ fn visit_expr_with_scope(&@ast::expr x, &scopes sc, &vt[scopes] v) {
visit::visit_expr(x, new_sc, v); visit::visit_expr(x, new_sc, v);
} }
fn follow_import(&env e, &scopes sc, fn follow_import(&env e, &scopes sc, vec[ident] path, &span sp) -> def {
vec[ident] path, &span sp) -> option::t[def] {
auto path_len = vec::len(path); auto path_len = vec::len(path);
auto dcur = lookup_in_scope_strict(e, sc, sp, path.(0), ns_module); auto dcur = lookup_in_scope_strict(e, sc, sp, path.(0), ns_module);
auto i = 1u; auto i = 1u;
while (true && option::is_some(dcur)) { while (true) {
if (i == path_len) { break; } if (i == path_len) { break; }
dcur = dcur =
lookup_in_mod_strict(e, option::get(dcur), lookup_in_mod_strict(e, dcur, sp, path.(i), ns_module, outside);
sp, path.(i), ns_module, outside);
i += 1u; i += 1u;
} }
if (i == path_len) { alt (dcur) {
alt (option::get(dcur)) {
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_err(sp,
str::connect(path, "::") + str::connect(path, "::") +
" does not name a module."); " does not name a module.");
ret none;
} }
} }
} else {
ret none;
}
} }
fn resolve_constr(@env e, &def_id d_id, &@ast::constr c, &scopes sc, fn resolve_constr(@env e, &def_id d_id, &@ast::constr c, &scopes sc,
&vt[scopes] v) { &vt[scopes] v) {
auto new_def = let def new_def =
lookup_path_strict(*e, sc, c.span, c.node.path.node.idents, ns_value); lookup_path_strict(*e, sc, c.span, c.node.path.node.idents, ns_value);
if (option::is_some(new_def)) { alt (new_def) {
alt (option::get(new_def)) {
case (ast::def_fn(?pred_id)) { case (ast::def_fn(?pred_id)) {
let ty::constr_general[uint] c_ = let ty::constr_general[uint] c_ =
rec(path=c.node.path, args=c.node.args, id=pred_id); rec(path=c.node.path, args=c.node.args, id=pred_id);
@ -430,7 +405,6 @@ fn resolve_constr(@env e, &def_id d_id, &@ast::constr c, &scopes sc,
} }
} }
} }
}
fn add_constr(&@env e, &def_id d_id, &ty::constr_def c) { fn add_constr(&@env e, &def_id d_id, &ty::constr_def c) {
e.fn_constrs.insert(d_id, e.fn_constrs.insert(d_id,
@ -460,18 +434,9 @@ fn resolve_import(&env e, &@ast::view_item it, &scopes sc) {
lookup_in_scope(e, next_sc, it.span, end_id, ns_value), lookup_in_scope(e, next_sc, it.span, end_id, ns_value),
lookup_in_scope(e, next_sc, it.span, end_id, ns_type), lookup_in_scope(e, next_sc, it.span, end_id, ns_type),
lookup_in_scope(e, next_sc, it.span, end_id, ns_module)); lookup_in_scope(e, next_sc, it.span, end_id, ns_module));
remove_if_unresolved(e.imports, defid._1);
} else { } else {
auto dcur = alt(lookup_in_scope(e, sc, it.span, ids.(0), ns_module)) { auto dcur =
case (some(?dcur)) { lookup_in_scope_strict(e, sc, it.span, ids.(0), ns_module);
dcur
}
case (none) {
unresolved_err(e, it.span, ids.(0), ns_name(ns_module));
remove_if_unresolved(e.imports, defid._1);
ret () // FIXME (issue #521)
}
};
auto i = 1u; auto i = 1u;
while (true) { while (true) {
if (i == n_idents - 1u) { if (i == n_idents - 1u) {
@ -482,21 +447,11 @@ fn resolve_import(&env e, &@ast::view_item it, &scopes sc) {
outside), outside),
lookup_in_mod(e, dcur, it.span, end_id, ns_module, lookup_in_mod(e, dcur, it.span, end_id, ns_module,
outside)); outside));
remove_if_unresolved(e.imports, defid._1);
break; break;
} else { } else {
dcur = alt (lookup_in_mod(e, dcur, it.span, ids.(i), dcur =
ns_module, outside)) { lookup_in_mod_strict(e, dcur, it.span, ids.(i), ns_module,
case (some(?dcur)) { outside);
dcur
}
case (none) {
unresolved_err(e, it.span, ids.(i),
ns_name(ns_module));
remove_if_unresolved(e.imports, defid._1);
ret () // FIXME (issue #521)
}
};
i += 1u; i += 1u;
} }
} }
@ -506,26 +461,11 @@ fn resolve_import(&env e, &@ast::view_item it, &scopes sc) {
&option::t[def] md) { &option::t[def] md) {
if (option::is_none(val) && option::is_none(typ) && if (option::is_none(val) && option::is_none(typ) &&
option::is_none(md)) { option::is_none(md)) {
unresolved_err(e, sp, id, "import"); unresolved(e, sp, id, "import");
} else { }
e.imports.insert(defid._1, resolved(val, typ, md)); e.imports.insert(defid._1, resolved(val, typ, md));
} }
} }
fn remove_if_unresolved(hashmap[ast::def_num, import_state] imports,
ast::def_num def_num) {
// If we couldn't resolve the import, don't leave it in a partially
// resolved state, to avoid having it reported later as a cyclic
// import
if (imports.contains_key(def_num)) {
alt (imports.get(def_num)) {
case (resolving(_)) {
imports.remove(def_num);
}
case (_) { }
}
}
}
}
// Utilities // Utilities
@ -537,42 +477,31 @@ fn ns_name(namespace ns) -> str {
} }
} }
fn unresolved_err(&env e, &span sp, &ident id, &str kind) { fn unresolved(&env e, &span sp, &ident id, &str kind) -> ! {
e.sess.span_err(sp, mk_unresolved_msg(id, kind)); e.sess.span_err(sp, "unresolved " + kind + ": " + id);
} }
fn unresolved_fatal(&env e, &span sp, &ident id, &str kind) -> ! {
e.sess.span_fatal(sp, mk_unresolved_msg(id, kind));
}
fn mk_unresolved_msg(&ident id, &str kind) -> str {
ret #fmt("unresolved %s: %s", kind, id);
}
// Lookup helpers // Lookup helpers
fn lookup_path_strict(&env e, &scopes sc, &span sp, vec[ident] idents, fn lookup_path_strict(&env e, &scopes sc, &span sp, vec[ident] idents,
namespace ns) -> option::t[def] { namespace ns) -> def {
auto n_idents = vec::len(idents); auto n_idents = vec::len(idents);
auto headns = if (n_idents == 1u) { ns } else { ns_module }; auto headns = if (n_idents == 1u) { ns } else { ns_module };
auto dcur = lookup_in_scope_strict(e, sc, sp, idents.(0), headns); auto dcur = lookup_in_scope_strict(e, sc, sp, idents.(0), headns);
auto i = 1u; auto i = 1u;
while (i < n_idents && option::is_some(dcur)) { while (i < n_idents) {
auto curns = if (n_idents == i + 1u) { ns } else { ns_module }; auto curns = if (n_idents == i + 1u) { ns } else { ns_module };
dcur = lookup_in_mod_strict(e, option::get(dcur), dcur = lookup_in_mod_strict(e, dcur, sp, idents.(i), curns, outside);
sp, idents.(i), curns, outside);
i += 1u; i += 1u;
} }
ret dcur; ret dcur;
} }
fn lookup_in_scope_strict(&env e, scopes sc, &span sp, &ident id, fn lookup_in_scope_strict(&env e, scopes sc, &span sp, &ident id,
namespace ns) -> option::t[def] { namespace ns) -> def {
alt (lookup_in_scope(e, sc, sp, id, ns)) { alt (lookup_in_scope(e, sc, sp, id, ns)) {
case (none) { case (none) { unresolved(e, sp, id, ns_name(ns)); }
unresolved_err(e, sp, id, ns_name(ns)); case (some(?d)) { ret d; }
ret none;
}
case (some(?d)) { ret some(d); }
} }
} }
@ -670,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_fatal(sp, e.sess.span_err(sp,
"attempted dynamic \ "attempted dynamic \
environment-capture"); environment-capture");
} }
@ -822,13 +751,10 @@ fn found_def_item(&@ast::item i, namespace ns) -> option::t[def] {
} }
fn lookup_in_mod_strict(&env e, def m, &span sp, &ident id, namespace ns, fn lookup_in_mod_strict(&env e, def m, &span sp, &ident id, namespace ns,
dir dr) -> option::t[def] { dir dr) -> def {
alt (lookup_in_mod(e, m, sp, id, ns, dr)) { alt (lookup_in_mod(e, m, sp, id, ns, dr)) {
case (none) { case (none) { unresolved(e, sp, id, ns_name(ns)); }
unresolved_err(e, sp, id, ns_name(ns)); case (some(?d)) { ret d; }
ret none;
}
case (some(?d)) { ret some(d); }
} }
} }
@ -880,10 +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)) { case (resolving(?sp)) { e.sess.span_err(sp, "cyclic import"); }
e.sess.span_err(sp, "cyclic import");
ret none;
}
case (resolved(?val, ?typ, ?md)) { case (resolved(?val, ?typ, ?md)) {
ret alt (ns) { ret alt (ns) {
case (ns_value) { val } case (ns_value) { val }
@ -958,7 +881,7 @@ fn lookup_glob_in_mod(&env e, @indexed_mod info, &span sp, &ident id,
} }
} }
} }
e.sess.span_fatal(sp, e.sess.span_err(sp,
"'" + id + "' is glob-imported from" + "'" + id + "' is glob-imported from" +
" multiple different modules."); " multiple different modules.");
} }
@ -1163,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_fatal(sp, "duplicate definition of " + word + name); e.sess.span_err(sp, "duplicate definition of " + word + name);
} }
while (true) { while (true) {
alt (entries) { alt (entries) {
@ -1299,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_fatal(sp, "duplicate " + ch.kind + " name: " + id); ch.sess.span_err(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_fatal(sp, cx.sess.span_err(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_fatal(sp, "trans::type_of called on ty_var"); cx.tcx.sess.span_err(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_fatal(sp, cx.tcx.sess.span_err(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_fatal(sp, cx.tcx.sess.span_err(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_fatal(e.span, cx.fcx.lcx.ccx.sess.span_err(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_fatal(sp, cx.fcx.lcx.ccx.sess.span_err(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_fatal(sp, "multiple 'main' functions"); ccx.sess.span_err(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_fatal(e.span, tcx.sess.span_err(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_fatal(operator.span, tcx.sess.span_err(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_fatal(e.span, tcx.sess.span_err(e.span,
"Internal error: " + " ill-formed predicate"); "Internal error: " + " ill-formed predicate");
} }
} }
@ -626,8 +626,7 @@ 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_fatal(a.span, cx.sess.span_err(a.span, "Constraint argument out of bounds");
"Constraint argument out of bounds");
} }
} }
case (carg_base) { ret @respan(a.span, carg_base); } case (carg_base) { ret @respan(a.span, carg_base); }
@ -637,7 +636,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_fatal(p.span, "Malformed path"); } case (none) { cx.sess.span_err(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_fatal(e.span, s); fcx.ccx.tcx.sess.span_err(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_fatal(s.span, ss); fcx.ccx.tcx.sess.span_err(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_fatal(f.decl.output.span, fcx.ccx.tcx.sess.span_err(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_fatal(f.body.span, fcx.ccx.tcx.sess.span_err(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

@ -22,155 +22,6 @@ import middle::metadata;
import util::common::*; import util::common::*;
import util::data::interner; import util::data::interner;
export ann_to_monotype;
export ann_to_type;
export ann_to_type_params;
export ann_to_ty_param_substs_opt_and_ty;
export any_item_native;
export any_item_rust;
export arg;
export args_eq;
export bind_params_in_type;
export block_ty;
export constr_def;
export constr_general;
export constr_table;
export count_ty_params;
export ctxt;
export decl_local_ty;
export def_has_ty_params;
export eq_ty;
export expr_ann;
export expr_has_ty_params;
export expr_ty;
export fold_ty;
export field;
export field_idx;
export field_num;
export fm_general;
export get_element_type;
export hash_ty;
export idx_nil;
export is_lval;
export item_table;
export lookup_item_type;
export method;
export method_idx;
export method_ty_to_fn_ty;
export mk_bool;
export mk_bot;
export mk_box;
export mk_chan;
export mk_char;
export mk_ctxt;
export mk_float;
export mk_fn;
export mk_imm_box;
export mk_imm_tup;
export mk_imm_vec;
export mk_int;
export mk_istr;
export mk_ivec;
export mk_mach;
export mk_native;
export mk_native_fn;
export mk_nil;
export mk_obj;
export mk_param;
export mk_port;
export mk_ptr;
export mk_rec;
export mk_str;
export mk_tag;
export mk_task;
export mk_tup;
export mk_type;
export mk_uint;
export mk_var;
export mk_vec;
export mode;
export mo_val;
export mo_alias;
export mt;
export node_type_table;
export pat_ann;
export pat_ty;
export path_to_str;
export rename;
export ret_ty_of_fn;
export ret_ty_of_fn_ty;
export ret_ty_to_fn_ty;
export sequence_element_type;
export sequence_is_interior;
export struct;
export sort_methods;
export stmt_ann;
export strip_boxes;
export sty;
export substitute_type_params;
export t;
export tag_variants;
export tag_variant_with_id;
export ty_param_substs_opt_and_ty;
export ty_param_count_and_ty;
export ty_native_fn;
export ty_bool;
export ty_bot;
export ty_box;
export ty_chan;
export ty_char;
export ty_float;
export ty_fn;
export ty_fn_abi;
export ty_fn_proto;
export ty_fn_ret;
export ty_int;
export ty_istr;
export ty_ivec;
export ty_machine;
export ty_native;
export ty_nil;
export ty_obj;
export ty_param;
export ty_port;
export ty_ptr;
export ty_rec;
export ty_str;
export ty_tag;
export ty_task;
export ty_tup;
export ty_type;
export ty_uint;
export ty_var;
export ty_var_id;
export ty_vec;
export ty_param_substs_opt_and_ty_to_monotype;
export ty_fn_args;
export type_contains_params;
export type_contains_vars;
export type_err;
export type_err_to_str;
export type_has_dynamic_size;
export type_has_pointers;
export type_is_bool;
export type_is_bot;
export type_is_box;
export type_is_boxed;
export type_is_chan;
export type_is_fp;
export type_is_integral;
export type_is_native;
export type_is_nil;
export type_is_scalar;
export type_is_sequence;
export type_is_signed;
export type_is_structural;
export type_is_tup_like;
export type_owns_heap_mem;
export type_param;
export unify;
export variant_info;
export walk_ty;
// Data types // Data types
tag mode { mo_val; mo_alias(bool); } tag mode { mo_val; mo_alias(bool); }
@ -229,6 +80,9 @@ fn method_ty_to_fn_ty(&ctxt cx, method m) -> t {
// Never construct these manually. These are interned. // Never construct these manually. These are interned.
//
// TODO: It'd be really nice to be able to hide this definition from the
// outside world, to enforce the above invariants.
type raw_t = type raw_t =
rec(sty struct, rec(sty struct,
option::t[str] cname, option::t[str] cname,
@ -1825,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_fatal(sp, sess.span_err(sp,
"bad numeric field on tuple: " + "bad numeric field on tuple: " +
"missing leading underscore"); "missing leading underscore");
} }
@ -1836,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_fatal(sp, sess.span_err(sp,
"bad numeric field on tuple: " + "bad numeric field on tuple: " +
" non-digit character: " + s); " non-digit character: " + s);
} }
@ -1850,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_fatal(sp, "unknown field '" + id + "' of record"); sess.span_err(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_fatal(sp, "unknown method '" + id + "' of obj"); sess.span_err(sp, "unknown method '" + id + "' of obj");
} }
fn sort_methods(&vec[method] meths) -> vec[method] { fn sort_methods(&vec[method] meths) -> vec[method] {
@ -1883,21 +1737,6 @@ fn is_lval(&@ast::expr expr) -> bool {
// //
// http://www.cs.man.ac.uk/~hoderk/ubench/unification_full.pdf // http://www.cs.man.ac.uk/~hoderk/ubench/unification_full.pdf
mod unify { mod unify {
export fixup_result;
export fixup_vars;
export fix_ok;
export fix_err;
export mk_var_bindings;
export resolve_type_bindings;
export resolve_type_structure;
export resolve_type_var;
export result;
export unify;
export ures_ok;
export ures_err;
export var_bindings;
tag result { ures_ok(t); ures_err(type_err); } tag result { ures_ok(t); ures_err(type_err); }
tag union_result { unres_ok; unres_err(type_err); } tag union_result { unres_ok; unres_err(type_err); }
tag fixup_result { tag fixup_result {

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_fatal(sp, "expected value but found type"); fcx.ccx.tcx.sess.span_err(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_fatal(sp, fcx.ccx.tcx.sess.span_err(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_fatal(sp, fcx.ccx.tcx.sess.span_err(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_fatal(ast_ty.span, tcx.sess.span_err(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_fatal(sp, tcx.sess.span_err(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_fatal(ast_ty.span, tcx.sess.span_err(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_fatal(a.ty.span, cx.tcx.sess.span_err(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_fatal(sp, fcx.ccx.tcx.sess.span_err(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_fatal(sp, fcx.ccx.tcx.sess.span_err(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_fatal(l.span, fcx.ccx.tcx.sess.span_err(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_fatal(pat.span, fcx.ccx.tcx.sess.span_err(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_fatal(pat.span, s); fcx.ccx.tcx.sess.span_err(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_fatal(pat.span, fcx.ccx.tcx.sess.span_err(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_fatal(sp, sess.span_err(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_fatal(sp, ccx.tcx.sess.span_err(sp,
"Pure function calls \ "Pure function calls \
impure function"); impure function");
} }
} }
} }
case (_) { case (_) {
ccx.tcx.sess.span_fatal(sp, ccx.tcx.sess.span_err(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_fatal(sp, ccx.tcx.sess.span_err(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_fatal(f.span, fcx.ccx.tcx.sess.span_err(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_fatal(sp, fcx.ccx.tcx.sess.span_err(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_fatal(e.span, s); fcx.ccx.tcx.sess.span_err(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_fatal(e.span,s); fcx.ccx.tcx.sess.span_err(e.span,s);
} }
} }
} }
case (_) { case (_) {
fcx.ccx.tcx.sess.span_fatal(e.span, fcx.ccx.tcx.sess.span_err(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_fatal(expr.span, s); fcx.ccx.tcx.sess.span_err(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_fatal(expr.span, fcx.ccx.tcx.sess.span_err(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_fatal(expr.span, fcx.ccx.tcx.sess.span_err(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_fatal(expr.span, fcx.ccx.tcx.sess.span_err(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_fatal(expr.span, fcx.ccx.tcx.sess.span_err(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_fatal(expr.span,s); fcx.ccx.tcx.sess.span_err(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_fatal(expr.span, fcx.ccx.tcx.sess.span_err(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_fatal(expr.span, fcx.ccx.tcx.sess.span_err(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_fatal(expr.span, fcx.ccx.tcx.sess.span_err(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_fatal(expr.span, fcx.ccx.tcx.sess.span_err(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_fatal(expr.span, fcx.ccx.tcx.sess.span_err(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_fatal(expr.span, fcx.ccx.tcx.sess.span_err(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_fatal(expr.span, fcx.ccx.tcx.sess.span_err(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_fatal(idx.span, fcx.ccx.tcx.sess.span_err(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_fatal(expr.span, fcx.ccx.tcx.sess.span_err(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_fatal(expr.span, fcx.ccx.tcx.sess.span_err(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_fatal(c.span, "Predicate " tcx.sess.span_err(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_fatal(body.span, ccx.tcx.sess.span_err(body.span,
"Non-boolean return type in pred"); "Non-boolean return type in pred");
} }
} }