Fix damage done by the pretty-printer

This commit is contained in:
Marijn Haverbeke 2011-07-27 14:48:34 +02:00
parent df7f21db09
commit 6e2a7bff7f
77 changed files with 678 additions and 413 deletions

View file

@ -340,10 +340,8 @@ fn build_link_meta(sess: &session::session, c: &ast::crate, output: &str,
ret alt metas.name { ret alt metas.name {
some(v) { v } some(v) { v }
none. { none. {
let // FIXME: Remove this vec->ivec conversion.
// FIXME: Remove this vec->ivec conversion. let name =
name =
{ {
let os_vec = let os_vec =
str::split(fs::basename(output), '.' as u8); str::split(fs::basename(output), '.' as u8);

View file

@ -65,9 +65,8 @@ fn build_configuration(sess: session::session, argv0: str, input: str) ->
// some default and generated configuration items // some default and generated configuration items
let default_cfg = default_configuration(sess, argv0, input); let default_cfg = default_configuration(sess, argv0, input);
let user_cfg = sess.get_opts().cfg; let user_cfg = sess.get_opts().cfg;
let // If the user wants a test runner, then add the test cfg
// If the user wants a test runner, then add the test cfg let gen_cfg =
gen_cfg =
{ {
if sess.get_opts().test && !attr::contains_name(user_cfg, "test") if sess.get_opts().test && !attr::contains_name(user_cfg, "test")
{ {

View file

@ -101,9 +101,7 @@ fn in_cfg(cfg: &ast::crate_cfg, attrs: &ast::attribute[]) -> bool {
// Pull the inner meta_items from the #[cfg(meta_item, ...)] attributes, // Pull the inner meta_items from the #[cfg(meta_item, ...)] attributes,
// so we can match against them. This is the list of configurations for // so we can match against them. This is the list of configurations for
// which the item is valid // which the item is valid
let let item_cfg_metas =
item_cfg_metas =
{ {
fn extract_metas(inner_items: &(@ast::meta_item)[], fn extract_metas(inner_items: &(@ast::meta_item)[],
cfg_item: &@ast::meta_item) -> cfg_item: &@ast::meta_item) ->

View file

@ -1395,11 +1395,10 @@ obj builder(B: BuilderRef, terminated: @mutable bool) {
fn is_terminated() -> bool { fn is_terminated() -> bool {
ret *terminated; ret *terminated;
}drop }
drop {
{
llvm::LLVMDisposeBuilder(B); llvm::LLVMDisposeBuilder(B);
} }
} }
/* Memory-managed object interface to type handles. */ /* Memory-managed object interface to type handles. */

View file

@ -122,22 +122,20 @@ fn find_library_crate(sess: &session::session, ident: &ast::ident,
attr::require_unique_names(sess, metas); attr::require_unique_names(sess, metas);
let // FIXME: Probably want a warning here since the user
// FIXME: Probably want a warning here since the user // is using the wrong type of meta item
// is using the wrong type of meta item let crate_name = {
crate_name = let name_items = attr::find_meta_items_by_name(metas, "name");
{ alt ivec::last(name_items) {
let name_items = attr::find_meta_items_by_name(metas, "name"); some(i) {
alt ivec::last(name_items) { alt attr::get_meta_item_value_str(i) {
some(i) { some(n) { n }
alt attr::get_meta_item_value_str(i) { _ { ident }
some(n) { n }
_ { ident }
}
}
none. { ident }
} }
}; }
none. { ident }
}
};
let nn = default_native_lib_naming(sess, sess.get_opts().static); let nn = default_native_lib_naming(sess, sess.get_opts().static);
let x = let x =

View file

@ -164,9 +164,8 @@ fn lookup_def(cnum: ast::crate_num, data: @u8[], did_: &ast::def_id) ->
let item = lookup_item(did_.node, data); let item = lookup_item(did_.node, data);
let kind_ch = item_kind(item); let kind_ch = item_kind(item);
let did = {crate: cnum, node: did_.node}; let did = {crate: cnum, node: did_.node};
let // We treat references to tags as references to types.
// We treat references to tags as references to types. let def =
def =
alt kind_ch as char { alt kind_ch as char {
'c' { ast::def_const(did) } 'c' { ast::def_const(did) }
'f' { ast::def_fn(did, ast::impure_fn) } 'f' { ast::def_fn(did, ast::impure_fn) }

View file

@ -39,10 +39,9 @@ tag local_info { arg(ast::mode); objfield(ast::mutability); }
type ctx = {tcx: ty::ctxt, local_map: std::map::hashmap[node_id, local_info]}; type ctx = {tcx: ty::ctxt, local_map: std::map::hashmap[node_id, local_info]};
fn check_crate(tcx: ty::ctxt, crate: &@ast::crate) { fn check_crate(tcx: ty::ctxt, crate: &@ast::crate) {
let // Stores information about object fields and function
// Stores information about object fields and function // arguments that's otherwise not easily available.
// arguments that's otherwise not easily available. let cx =
cx =
@{tcx: tcx, local_map: std::map::new_int_hash()}; @{tcx: tcx, local_map: std::map::new_int_hash()};
let v = let v =
@{visit_fn: bind visit_fn(cx, _, _, _, _, _, _, _), @{visit_fn: bind visit_fn(cx, _, _, _, _, _, _, _),

View file

@ -73,12 +73,12 @@ fn collect_freevars(def_map: &resolve::def_map, sess: &session::session,
let e: env = let e: env =
@{mutable refs: ~[], decls: decls, def_map: def_map, sess: sess}; @{mutable refs: ~[], decls: decls, def_map: def_map, sess: sess};
walker(visit::mk_simple_visitor(@{visit_local: bind walk_local(e, _), walker(visit::mk_simple_visitor
visit_pat: bind walk_pat(e, _), (@{visit_local: bind walk_local(e, _),
visit_expr: bind walk_expr(e, _), visit_pat: bind walk_pat(e, _),
visit_fn: bind walk_fn(e, _, _, _, _, _) visit_expr: bind walk_expr(e, _),
with visit_fn: bind walk_fn(e, _, _, _, _, _)
*visit::default_simple_visitor()})); with *visit::default_simple_visitor()}));
// Calculate (refs - decls). This is the set of captured upvars. // Calculate (refs - decls). This is the set of captured upvars.
// We build a vec of the node ids of the uses and a set of the // We build a vec of the node ids of the uses and a set of the

View file

@ -830,10 +830,9 @@ fn trans_malloc_boxed(cx: &@block_ctxt, t: ty::t) -> result {
// size of; box_ptr is the type that's converted to a TypeRef and used as // size of; box_ptr is the type that's converted to a TypeRef and used as
// the pointer cast target in trans_raw_malloc. // the pointer cast target in trans_raw_malloc.
let // The mk_int here is the space being
// The mk_int here is the space being // reserved for the refcount.
// reserved for the refcount. let boxed_body =
boxed_body =
ty::mk_imm_tup(bcx_tcx(cx), ~[ty::mk_int(bcx_tcx(cx)), t]); ty::mk_imm_tup(bcx_tcx(cx), ~[ty::mk_int(bcx_tcx(cx)), t]);
let box_ptr = ty::mk_imm_box(bcx_tcx(cx), t); let box_ptr = ty::mk_imm_box(bcx_tcx(cx), t);
let sz = size_of(cx, boxed_body); let sz = size_of(cx, boxed_body);
@ -1243,21 +1242,20 @@ fn incr_refcnt_of_boxed(cx: &@block_ctxt, box_ptr: ValueRef) -> result {
fn make_free_glue(cx: &@block_ctxt, v0: ValueRef, t: &ty::t) { fn make_free_glue(cx: &@block_ctxt, v0: ValueRef, t: &ty::t) {
// NB: v is an *alias* of type t here, not a direct value. // NB: v is an *alias* of type t here, not a direct value.
let // FIXME: switch gc/non-gc on layer of the type.
// FIXME: switch gc/non-gc on layer of the type. // FIXME: switch gc/non-gc on layer of the type.
// FIXME: switch gc/non-gc on layer of the type. // TODO: call upcall_kill
// TODO: call upcall_kill
// Call through the obj's own fields-drop glue first. // Call through the obj's own fields-drop glue first.
// Then free the body. // Then free the body.
// FIXME: switch gc/non-gc on layer of the type. // FIXME: switch gc/non-gc on layer of the type.
// Call through the closure's own fields-drop glue first. // Call through the closure's own fields-drop glue first.
// Then free the body. // Then free the body.
// FIXME: switch gc/non-gc on layer of the type. // FIXME: switch gc/non-gc on layer of the type.
rs = let rs =
alt ty::struct(bcx_tcx(cx), t) { alt ty::struct(bcx_tcx(cx), t) {
ty::ty_str. { let v = cx.build.Load(v0); trans_non_gc_free(cx, v) } ty::ty_str. { let v = cx.build.Load(v0); trans_non_gc_free(cx, v) }
ty::ty_vec(_) { ty::ty_vec(_) {
@ -1361,9 +1359,7 @@ fn maybe_free_ivec_heap_part(cx: &@block_ctxt, v0: ValueRef, unit_ty: ty::t)
fn make_drop_glue(cx: &@block_ctxt, v0: ValueRef, t: &ty::t) { fn make_drop_glue(cx: &@block_ctxt, v0: ValueRef, t: &ty::t) {
// NB: v0 is an *alias* of type t here, not a direct value. // NB: v0 is an *alias* of type t here, not a direct value.
let ccx = bcx_ccx(cx); let ccx = bcx_ccx(cx);
let let rs =
rs =
alt ty::struct(ccx.tcx, t) { alt ty::struct(ccx.tcx, t) {
ty::ty_str. { decr_refcnt_maybe_free(cx, v0, v0, t) } ty::ty_str. { decr_refcnt_maybe_free(cx, v0, v0, t) }
ty::ty_vec(_) { decr_refcnt_maybe_free(cx, v0, v0, t) } ty::ty_vec(_) { decr_refcnt_maybe_free(cx, v0, v0, t) }
@ -1453,7 +1449,9 @@ fn trans_res_drop(cx: @block_ctxt, rs: ValueRef, did: &ast::def_id,
// value here, but the dtor expects a type that still has opaque pointers // value here, but the dtor expects a type that still has opaque pointers
// for type variables. // for type variables.
let val_llty = let val_llty =
lib::llvm::fn_ty_param_tys(llvm::LLVMGetElementType(llvm::LLVMTypeOf(dtor_addr))).(std::ivec::len(args)); lib::llvm::fn_ty_param_tys(llvm::LLVMGetElementType
(llvm::LLVMTypeOf(dtor_addr)))
.(std::ivec::len(args));
let val_cast = cx.build.BitCast(val.val, val_llty); let val_cast = cx.build.BitCast(val.val, val_llty);
cx.build.FastCall(dtor_addr, args + ~[val_cast]); cx.build.FastCall(dtor_addr, args + ~[val_cast]);
@ -3345,9 +3343,8 @@ mod ivec {
maybe_on_heap_cx.build.PointerCast(vptr, maybe_on_heap_cx.build.PointerCast(vptr,
T_ptr(T_ivec_heap(llunitty))); T_ptr(T_ivec_heap(llunitty)));
let heap_ptr_ptr = let heap_ptr_ptr =
maybe_on_heap_cx.build.InBoundsGEP(stub_ptr, maybe_on_heap_cx.build.InBoundsGEP
~[C_int(0), (stub_ptr, ~[C_int(0), C_uint(abi::ivec_heap_stub_elt_ptr)]);
C_uint(abi::ivec_heap_stub_elt_ptr)]);
let heap_ptr = maybe_on_heap_cx.build.Load(heap_ptr_ptr); let heap_ptr = maybe_on_heap_cx.build.Load(heap_ptr_ptr);
let heap_ptr_is_nonnull = let heap_ptr_is_nonnull =
maybe_on_heap_cx.build.ICmp(lib::llvm::LLVMIntNE, heap_ptr, maybe_on_heap_cx.build.ICmp(lib::llvm::LLVMIntNE, heap_ptr,
@ -3358,9 +3355,8 @@ mod ivec {
// Ok, the vector is on the heap. Copy the heap part. // Ok, the vector is on the heap. Copy the heap part.
let alen_ptr = let alen_ptr =
on_heap_cx.build.InBoundsGEP(stub_ptr, on_heap_cx.build.InBoundsGEP
~[C_int(0), (stub_ptr, ~[C_int(0), C_uint(abi::ivec_heap_stub_elt_alen)]);
C_uint(abi::ivec_heap_stub_elt_alen)]);
let alen = on_heap_cx.build.Load(alen_ptr); let alen = on_heap_cx.build.Load(alen_ptr);
let heap_part_sz = let heap_part_sz =
@ -3598,17 +3594,15 @@ fn trans_if(cx: &@block_ctxt, cond: &@ast::expr, thn: &ast::blk,
let then_cx = new_scope_block_ctxt(cx, "then"); let then_cx = new_scope_block_ctxt(cx, "then");
let then_res = trans_block(then_cx, thn, output); let then_res = trans_block(then_cx, thn, output);
let else_cx = new_scope_block_ctxt(cx, "else"); let else_cx = new_scope_block_ctxt(cx, "else");
let // Synthesize a block here to act as the else block
// Synthesize a block here to act as the else block // containing an if expression. Needed in order for the
// containing an if expression. Needed in order for the // else scope to behave like a normal block scope. A tad
// else scope to behave like a normal block scope. A tad // ugly.
// ugly. // Calling trans_block directly instead of trans_expr
// Calling trans_block directly instead of trans_expr // because trans_expr will create another scope block
// because trans_expr will create another scope block // context for the block, but we've already got the
// context for the block, but we've already got the // 'else' context
// 'else' context let else_res =
else_res =
alt els { alt els {
some(elexpr) { some(elexpr) {
alt elexpr.node { alt elexpr.node {
@ -5334,9 +5328,9 @@ fn trans_expr_out(cx: &@block_ctxt, e: &@ast::expr, output: out_method) ->
} }
_ { _ {
// The expression is an lvalue. Fall through. // The expression is an lvalue. Fall through.
assert (ty::is_lval(e)); // make sure it really is and that we assert (ty::is_lval(e));
// didn't forget to add a case for a new expr! // make sure it really is and that we
// didn't forget to add a case for a new expr!
} }
} }
// lval cases fall through to trans_lval and then // lval cases fall through to trans_lval and then
@ -6352,8 +6346,8 @@ fn copy_args_to_allocas(fcx: @fn_ctxt, args: &ast::arg[],
alt bcx.fcx.llargs.find(aarg.id) { alt bcx.fcx.llargs.find(aarg.id) {
some(x) { argval = x; } some(x) { argval = x; }
_ { _ {
bcx_ccx(bcx).sess.span_fatal(aarg.ty.span, bcx_ccx(bcx).sess.span_fatal
"unbound arg ID in copy_args_to_allocas"); (aarg.ty.span, "unbound arg ID in copy_args_to_allocas");
} }
} }
bcx.build.Store(argval, a); bcx.build.Store(argval, a);
@ -6374,8 +6368,8 @@ fn add_cleanups_for_args(bcx: &@block_ctxt, args: &ast::arg[],
alt bcx.fcx.llargs.find(aarg.id) { alt bcx.fcx.llargs.find(aarg.id) {
some(x) { argval = x; } some(x) { argval = x; }
_ { _ {
bcx_ccx(bcx).sess.span_fatal(aarg.ty.span, bcx_ccx(bcx).sess.span_fatal
"unbound arg ID in copy_args_to_allocas"); (aarg.ty.span, "unbound arg ID in copy_args_to_allocas");
} }
} }
add_clean(bcx, argval, arg_tys.(arg_n).ty); add_clean(bcx, argval, arg_tys.(arg_n).ty);
@ -7227,9 +7221,8 @@ fn trans_tag_variant(cx: @local_ctxt, tag_id: ast::node_id,
let bcx = new_top_block_ctxt(fcx); let bcx = new_top_block_ctxt(fcx);
let lltop = bcx.llbb; let lltop = bcx.llbb;
let // Cast the tag to a type we can GEP into.
// Cast the tag to a type we can GEP into. let llblobptr =
llblobptr =
if is_degen { if is_degen {
fcx.llretptr fcx.llretptr
} else { } else {

View file

@ -294,9 +294,8 @@ fn compile_submatch(bcx: @block_ctxt, m: &match, vals: ValueRef[],
if ivec::len(ty::tag_variants(ccx.tcx, vdef.tg)) == 1u { if ivec::len(ty::tag_variants(ccx.tcx, vdef.tg)) == 1u {
kind = single; kind = single;
} else { } else {
let tagptr = let tagptr = bcx.build.PointerCast
bcx.build.PointerCast(val, (val, trans_common::T_opaque_tag_ptr(ccx.tn));
trans_common::T_opaque_tag_ptr(ccx.tn));
let discrimptr = bcx.build.GEP(tagptr, ~[C_int(0), C_int(0)]); let discrimptr = bcx.build.GEP(tagptr, ~[C_int(0), C_int(0)]);
test_val = bcx.build.Load(discrimptr); test_val = bcx.build.Load(discrimptr);
kind = switch; kind = switch;

View file

@ -159,9 +159,7 @@ fn relax_precond_block(fcx: &fn_ctxt, i: node_id, b: &blk) {
fn quit(keepgoing: @mutable bool, i: &@item) { *keepgoing = false; } fn quit(keepgoing: @mutable bool, i: &@item) { *keepgoing = false; }
fn kg(keepgoing: @mutable bool) -> bool { ret *keepgoing; } fn kg(keepgoing: @mutable bool) -> bool { ret *keepgoing; }
let let v =
v =
{visit_block_pre: bind relax_precond_block_non_recursive(fcx, i, _), {visit_block_pre: bind relax_precond_block_non_recursive(fcx, i, _),
visit_expr_pre: bind relax_precond_expr(fcx, i, _), visit_expr_pre: bind relax_precond_expr(fcx, i, _),
visit_stmt_pre: bind relax_precond_stmt(fcx, i, _), visit_stmt_pre: bind relax_precond_stmt(fcx, i, _),

View file

@ -1987,8 +1987,9 @@ mod unify {
let result_mode; let result_mode;
if expected_input.mode != actual_input.mode { if expected_input.mode != actual_input.mode {
ret fn_common_res_err(ures_err(terr_mode_mismatch(expected_input.mode, ret fn_common_res_err
actual_input.mode))); (ures_err(terr_mode_mismatch(expected_input.mode,
actual_input.mode)));
} else { result_mode = expected_input.mode; } } else { result_mode = expected_input.mode; }
let result = unify_step(cx, expected_input.ty, actual_input.ty); let result = unify_step(cx, expected_input.ty, actual_input.ty);
alt result { alt result {
@ -2817,10 +2818,10 @@ fn ast_constr_to_constr[T](tcx: ty::ctxt, c: &@ast::constr_general[T]) ->
{path: c.node.path, args: c.node.args, id: pred_id}); {path: c.node.path, args: c.node.args, id: pred_id});
} }
_ { _ {
tcx.sess.span_fatal(c.span, tcx.sess.span_fatal
"Predicate " + path_to_str(c.node.path) + (c.span, "Predicate " + path_to_str(c.node.path) +
" is unbound or bound to a non-function or an \ " is unbound or bound to a non-function or an \
impure function"); impure function");
} }
} }
} }

View file

@ -164,14 +164,14 @@ fn instantiate_path(fcx: &@fn_ctxt, pth: &ast::path,
if ty_substs_len > 0u { if ty_substs_len > 0u {
let param_var_len = ivec::len(ty_param_vars); let param_var_len = ivec::len(ty_param_vars);
if param_var_len == 0u { if param_var_len == 0u {
fcx.ccx.tcx.sess.span_fatal(sp, fcx.ccx.tcx.sess.span_fatal
"this item does not take type parameters"); (sp, "this item does not take type parameters");
} else if (ty_substs_len > param_var_len) { } else if (ty_substs_len > param_var_len) {
fcx.ccx.tcx.sess.span_fatal(sp, fcx.ccx.tcx.sess.span_fatal
"too many type parameter provided for this item"); (sp, "too many type parameter provided for this item");
} else if (ty_substs_len < param_var_len) { } else if (ty_substs_len < param_var_len) {
fcx.ccx.tcx.sess.span_fatal(sp, fcx.ccx.tcx.sess.span_fatal
"not enough type parameters provided for this item"); (sp, "not enough type parameters provided for this item");
} }
let ty_substs: ty::t[] = ~[]; let ty_substs: ty::t[] = ~[];
let i = 0u; let i = 0u;
@ -868,11 +868,10 @@ mod collect {
let abi = @mutable none[ast::native_abi]; let abi = @mutable none[ast::native_abi];
let cx = @{tcx: tcx}; let cx = @{tcx: tcx};
let visit = let visit =
visit::mk_simple_visitor(@{visit_item: bind convert(cx, abi, _), visit::mk_simple_visitor
visit_native_item: (@{visit_item: bind convert(cx, abi, _),
bind convert_native(cx, abi, _) visit_native_item: bind convert_native(cx, abi, _)
with with *visit::default_simple_visitor()});
*visit::default_simple_visitor()});
visit::visit_crate(*crate, (), visit); visit::visit_crate(*crate, (), visit);
} }
} }
@ -1426,14 +1425,13 @@ fn check_pat(fcx: &@fn_ctxt, map: &ast::pat_id_map, pat: &@ast::pat,
// 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_fatal
#fmt("this pattern has %u field%s, \ (pat.span, #fmt("this pattern has %u field%s, \
but the corresponding \ but the corresponding \
variant has no fields", variant has no fields",
subpats_len, subpats_len,
if subpats_len == 1u { if subpats_len == 1u { "" }
"" else { "s" }));
} else { "s" }));
} }
write::ty_fixup(fcx, pat.id, path_tpot); write::ty_fixup(fcx, pat.id, path_tpot);
} }
@ -1464,11 +1462,10 @@ fn check_pat(fcx: &@fn_ctxt, map: &ast::pat_id_map, pat: &@ast::pat,
let f_count = ivec::len(fields); let f_count = ivec::len(fields);
let ex_f_count = ivec::len(ex_fields); let ex_f_count = ivec::len(ex_fields);
if ex_f_count < f_count || !etc && ex_f_count > f_count { if ex_f_count < f_count || !etc && ex_f_count > f_count {
fcx.ccx.tcx.sess.span_fatal(pat.span, fcx.ccx.tcx.sess.span_fatal
#fmt("mismatched types: expected a record \ (pat.span, #fmt("mismatched types: expected a record \
with %u fields, found one with %u \ with %u fields, found one with %u \
fields", fields", ex_f_count, f_count));
ex_f_count, f_count));
} }
fn matches(name: &str, f: &ty::field) -> bool { fn matches(name: &str, f: &ty::field) -> bool {
ret str::eq(name, f.ident); ret str::eq(name, f.ident);
@ -1521,8 +1518,8 @@ fn require_pure_call(ccx: @crate_ctxt, caller_purity: &ast::purity,
alt ccx.tcx.def_map.find(callee.id) { alt ccx.tcx.def_map.find(callee.id) {
some(ast::def_fn(_, ast::pure_fn.)) { ret; } some(ast::def_fn(_, ast::pure_fn.)) { ret; }
_ { _ {
ccx.tcx.sess.span_fatal(sp, ccx.tcx.sess.span_fatal
"Pure function calls function not known to be pure"); (sp, "Pure function calls function not known to be pure");
} }
} }
} }
@ -1614,10 +1611,10 @@ fn check_expr(fcx: &@fn_ctxt, expr: &@ast::expr) {
arg_tys.(i).mode == mo_val { arg_tys.(i).mode == mo_val {
// For why the check is necessary, see the // For why the check is necessary, see the
// none case in trans_bind_thunk // none case in trans_bind_thunk
fcx.ccx.tcx.sess.span_fatal(sp, fcx.ccx.tcx.sess.span_fatal
call_kind_str(call_kind) + (sp, call_kind_str(call_kind) +
" arguments with types containing parameters \ " arguments with types containing parameters \
must be passed by alias"); must be passed by alias");
} }
} }
} }
@ -1785,10 +1782,10 @@ fn check_expr(fcx: &@fn_ctxt, expr: &@ast::expr) {
let variants = ty::tag_variants(fcx.ccx.tcx, id); let variants = ty::tag_variants(fcx.ccx.tcx, id);
if ivec::len(variants) != 1u || if ivec::len(variants) != 1u ||
ivec::len(variants.(0).args) != 1u { ivec::len(variants.(0).args) != 1u {
fcx.ccx.tcx.sess.span_fatal(expr.span, fcx.ccx.tcx.sess.span_fatal
"can only dereference tags " + (expr.span, "can only dereference tags " +
"with a single variant which has a " "with a single variant which has a "
+ "single argument"); + "single argument");
} }
oper_t = oper_t =
ty::substitute_type_params(fcx.ccx.tcx, tps, ty::substitute_type_params(fcx.ccx.tcx, tps,
@ -1983,10 +1980,9 @@ fn check_expr(fcx: &@fn_ctxt, expr: &@ast::expr) {
ty::ty_ivec(vec_elt_ty) { elt_ty = vec_elt_ty.ty; } ty::ty_ivec(vec_elt_ty) { elt_ty = vec_elt_ty.ty; }
ty::ty_istr. { elt_ty = ty::mk_mach(fcx.ccx.tcx, ast::ty_u8); } ty::ty_istr. { elt_ty = ty::mk_mach(fcx.ccx.tcx, ast::ty_u8); }
_ { _ {
fcx.ccx.tcx.sess.span_fatal(expr.span, fcx.ccx.tcx.sess.span_fatal
"mismatched types: expected vector or string but " (expr.span, "mismatched types: expected vector or string but "
+ "found " + + "found " + ty_to_str(fcx.ccx.tcx, ety));
ty_to_str(fcx.ccx.tcx, ety));
} }
} }
check_for_or_for_each(fcx, decl, elt_ty, body, id); check_for_or_for_each(fcx, decl, elt_ty, body, id);
@ -2440,10 +2436,9 @@ fn check_expr(fcx: &@fn_ctxt, expr: &@ast::expr) {
_ { _ {
// The user is trying to extend a // The user is trying to extend a
// non-object. // non-object.
fcx.ccx.tcx.sess.span_fatal(e.span, fcx.ccx.tcx.sess.span_fatal
syntax::print::pprust::expr_to_str(e) (e.span, syntax::print::pprust::expr_to_str(e) +
+ " does not have object type");
" does not have object type");
} }
} }
} }

View file

@ -329,9 +329,9 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: vec[piece],
let expected_nargs = n + 1u; // n conversions + the fmt string let expected_nargs = n + 1u; // n conversions + the fmt string
if expected_nargs < nargs { if expected_nargs < nargs {
cx.span_fatal(sp, cx.span_fatal
#fmt("too many arguments to #fmt. found %u, expected %u", (sp, #fmt("too many arguments to #fmt. found %u, expected %u",
nargs, expected_nargs)); nargs, expected_nargs));
} }
ret tmp_expr; ret tmp_expr;
} }

View file

@ -317,10 +317,9 @@ fn noop_fold_expr(e: &expr_, fld: ast_fold) -> expr_ {
ret {fields: ret {fields:
alt ao.fields { alt ao.fields {
option::none[anon_obj_field[]]. { ao.fields } option::none. { ao.fields }
option::some[anon_obj_field[]](v) { option::some(v) {
option::some[anon_obj_field[]](ivec::map(fold_anon_obj_field, option::some(ivec::map(fold_anon_obj_field, v))
v))
} }
}, },
methods: ivec::map(fld.fold_method, ao.methods), methods: ivec::map(fld.fold_method, ao.methods),

View file

@ -1812,15 +1812,14 @@ fn parse_dtor(p: &parser) -> @ast::method {
let b: ast::blk = parse_block(p); let b: ast::blk = parse_block(p);
let inputs: ast::arg[] = ~[]; let inputs: ast::arg[] = ~[];
let output: @ast::ty = @spanned(lo, lo, ast::ty_nil); let output: @ast::ty = @spanned(lo, lo, ast::ty_nil);
let // I guess dtors can't have constraints?
let d: ast::fn_decl = {
// I guess dtors can't have constraints? inputs: inputs,
d: ast::fn_decl = output: output,
{inputs: inputs, purity: ast::impure_fn,
output: output, cf: ast::return,
purity: ast::impure_fn, constraints: ~[]
cf: ast::return, };
constraints: ~[]};
let f: ast::_fn = {decl: d, proto: ast::proto_fn, body: b}; let f: ast::_fn = {decl: d, proto: ast::proto_fn, body: b};
let m: ast::method_ = {ident: "drop", meth: f, id: p.get_id()}; let m: ast::method_ = {ident: "drop", meth: f, id: p.get_id()};
ret @spanned(lo, f.body.span.hi, m); ret @spanned(lo, f.body.span.hi, m);
@ -1877,9 +1876,8 @@ fn parse_item_res(p: &parser, lyr: ast::layer, attrs: &ast::attribute[]) ->
fn parse_mod_items(p: &parser, term: token::token, fn parse_mod_items(p: &parser, term: token::token,
first_item_attrs: &ast::attribute[]) -> ast::_mod { first_item_attrs: &ast::attribute[]) -> ast::_mod {
let // Shouldn't be any view items since we've already parsed an item attr
// Shouldn't be any view items since we've already parsed an item attr let view_items =
view_items =
if ivec::len(first_item_attrs) == 0u { parse_view(p) } else { ~[] }; if ivec::len(first_item_attrs) == 0u { parse_view(p) } else { ~[] };
let items: (@ast::item)[] = ~[]; let items: (@ast::item)[] = ~[];
let initial_attrs = first_item_attrs; let initial_attrs = first_item_attrs;
@ -1960,11 +1958,10 @@ fn parse_native_item(p: &parser, attrs: &ast::attribute[]) ->
} }
fn parse_native_mod_items(p: &parser, native_name: &str, abi: ast::native_abi, fn parse_native_mod_items(p: &parser, native_name: &str, abi: ast::native_abi,
first_item_attrs: &ast::attribute[]) -> first_item_attrs: &ast::attribute[])
ast::native_mod { -> ast::native_mod {
let // Shouldn't be any view items since we've already parsed an item attr
// Shouldn't be any view items since we've already parsed an item attr let view_items =
view_items =
if ivec::len(first_item_attrs) == 0u { if ivec::len(first_item_attrs) == 0u {
parse_native_view(p) parse_native_view(p)
} else { ~[] }; } else { ~[] };

View file

@ -215,11 +215,9 @@ mod ct {
{ty: ty, next: uint} { {ty: ty, next: uint} {
if i >= lim { error("missing type in conversion"); } if i >= lim { error("missing type in conversion"); }
let tstr = str::substr(s, i, 1u); let tstr = str::substr(s, i, 1u);
let // TODO: Do we really want two signed types here?
// How important is it to be printf compatible?
// TODO: Do we really want two signed types here? let t =
// How important is it to be printf compatible?
t =
if str::eq(tstr, "b") { if str::eq(tstr, "b") {
ty_bool ty_bool
} else if (str::eq(tstr, "s")) { } else if (str::eq(tstr, "s")) {
@ -305,13 +303,11 @@ mod rt {
ret pad(cv, str::from_char(c), pad_nozero); ret pad(cv, str::from_char(c), pad_nozero);
} }
fn conv_str(cv: &conv, s: str) -> str { fn conv_str(cv: &conv, s: str) -> str {
let // For strings, precision is the maximum characters
// displayed
// For strings, precision is the maximum characters // FIXME: substr works on bytes, not chars!
// displayed let unpadded =
// FIXME: substr works on bytes, not chars!
unpadded =
alt cv.precision { alt cv.precision {
count_implied. { s } count_implied. { s }
count_is(max) { count_is(max) {

View file

@ -90,10 +90,12 @@ pred is_not_empty[T](v: &T[mutable? ]) -> bool { ret !is_empty(v); }
// Accessors // Accessors
/// Returns the first element of a vector /// Returns the first element of a vector
fn head[T](v: &T[mutable? ]) -> T { ret v.(0); } fn head[T](v: &T[mutable?]) : is_not_empty(v) -> T { ret v.(0); }
/// Returns all but the first element of a vector /// Returns all but the first element of a vector
fn tail[T](v: &T[mutable? ]) -> T[mutable? ] { ret slice(v, 1u, len(v)); } fn tail[T](v: &T[mutable? ]) : is_not_empty(v) -> T[mutable?] {
ret slice(v, 1u, len(v));
}
/// Returns the last element of `v`. /// Returns the last element of `v`.
fn last[T](v: &T[mutable? ]) -> option::t[T] { fn last[T](v: &T[mutable? ]) -> option::t[T] {

View file

@ -396,7 +396,7 @@ fn slice(s: str, begin: uint, end: uint) -> str {
ret rustrt::str_slice(s, begin, end); ret rustrt::str_slice(s, begin, end);
} }
fn safe_slice(s: str, begin: uint, end: uint) -> str { fn safe_slice(s: str, begin: uint, end: uint): le(begin, end) -> str {
assert (end <= assert (end <=
str::byte_len(s)); // would need some magic to str::byte_len(s)); // would need some magic to
// make this a precondition // make this a precondition
@ -505,7 +505,7 @@ fn to_upper(s: str) -> str {
} }
// FIXME: This is super-inefficient // FIXME: This is super-inefficient
fn replace(s: str, from: str, to: str) -> str { fn replace(s: str, from: str, to: str) : is_not_empty(from) -> str {
// FIXME (694): Shouldn't have to check this // FIXME (694): Shouldn't have to check this
check (is_not_empty(from)); check (is_not_empty(from));
if byte_len(s) == 0u { if byte_len(s) == 0u {

View file

@ -58,7 +58,7 @@ type test_opts = {filter: option::t[str], run_ignored: bool};
type opt_res = either::t[test_opts, str]; type opt_res = either::t[test_opts, str];
// Parses command line arguments into test options // Parses command line arguments into test options
fn parse_opts(args: &str[]) -> opt_res { fn parse_opts(args: &str[]) : ivec::is_not_empty(args) -> opt_res {
// FIXME (#649): Shouldn't have to check here // FIXME (#649): Shouldn't have to check here
check (ivec::is_not_empty(args)); check (ivec::is_not_empty(args));

View file

@ -6,16 +6,13 @@ native "llvm" mod llvm {
} }
fn main() { fn main() {
//
let // Leave these commented out to
// // finish in a reasonable time
// Leave these commented out to // during 'make check' under valgrind
// finish in a reasonable time // 5000000
// during 'make check' under valgrind // 50000000
// 5000000 let inputs: vec[int] = [50000, 500000];
// 50000000
inputs: vec[int] =
[50000, 500000];
let bodies: vec[Body::props] = NBodySystem::MakeNBodySystem(); let bodies: vec[Body::props] = NBodySystem::MakeNBodySystem();
@ -35,9 +32,8 @@ fn main() {
mod NBodySystem { mod NBodySystem {
fn MakeNBodySystem() -> vec[Body::props] { fn MakeNBodySystem() -> vec[Body::props] {
let // these each return a Body::props
// these each return a Body::props let bodies: vec[Body::props] =
bodies: vec[Body::props] =
[Body::sun(), Body::jupiter(), Body::saturn(), Body::uranus(), [Body::sun(), Body::jupiter(), Body::saturn(), Body::uranus(),
Body::neptune()]; Body::neptune()];

View file

@ -1,6 +1,6 @@
./src/test/compile-fail/attr-bad-meta.rs:5:6:5:7: error: expecting ], found * // xfail-stage0
./src/test/compile-fail/attr-bad-meta.rs:5 #[attr*] // error-pattern:expecting ]
^
rt: --- // asterisk is bogus
rt: f00e:main:main: upcall fail 'explicit failure', src/comp/syntax/parse/parser.rs:112 #[attr*]
rt: f00e:main: domain main @0xa6bf04c root task failed mod m { }

View file

@ -1,6 +1,10 @@
./src/test/compile-fail/attr-before-stmt.rs:6:2:6:6: error: expected item // xfail-stage0
./src/test/compile-fail/attr-before-stmt.rs:6 auto x = 10; // error-pattern:expected item
^~~~
rt: --- fn f() {
rt: 0bb1:main:main: upcall fail 'explicit failure', src/comp/syntax/parse/parser.rs:112 #[foo = "bar"]
rt: 0bb1:main: domain main @0x8ef904c root task failed let x = 10;
}
fn main() {
}

View file

@ -1,6 +1,8 @@
./src/test/compile-fail/attr-before-view-item.rs:5:0:5:3: error: expected item but found use // xfail-stage0
./src/test/compile-fail/attr-before-view-item.rs:5 use std; // error-pattern:expected item
^~~
rt: --- #[foo = "bar"]
rt: 0bb1:main:main: upcall fail 'explicit failure', src/comp/syntax/parse/parser.rs:112 use std;
rt: 0bb1:main: domain main @0xa78604c root task failed
fn main() {
}

View file

@ -1,6 +1,10 @@
./src/test/compile-fail/attr-before-view-item2.rs:6:2:6:5: error: expected item but found use // xfail-stage0
./src/test/compile-fail/attr-before-view-item2.rs:6 use std; // error-pattern:expected item
^~~
rt: --- mod m {
rt: 0bb1:main:main: upcall fail 'explicit failure', src/comp/syntax/parse/parser.rs:112 #[foo = "bar"]
rt: 0bb1:main: domain main @0xa1fd04c root task failed use std;
}
fn main() {
}

View file

@ -1,6 +1,9 @@
./src/test/compile-fail/attr-dangling-in-fn.rs:6:0:6:1: error: expected item // xfail-stage0
./src/test/compile-fail/attr-dangling-in-fn.rs:6 } // error-pattern:expected item
^
rt: --- fn f() {
rt: f00e:main:main: upcall fail 'explicit failure', src/comp/syntax/parse/parser.rs:112 #[foo = "bar"]
rt: f00e:main: domain main @0x9fb104c root task failed }
fn main() {
}

View file

@ -1,6 +1,7 @@
./src/test/compile-fail/attr-dangling-in-mod.rs:7:14:7:14: error: expected item but found <eof> // xfail-stage0
./src/test/compile-fail/attr-dangling-in-mod.rs:7 #[foo = "bar"] // error-pattern:expected item
^
rt: --- fn main() {
rt: 0bb1:main:main: upcall fail 'explicit failure', src/comp/syntax/parse/parser.rs:112 }
rt: 0bb1:main: domain main @0xa2d504c root task failed
#[foo = "bar"]

View file

@ -1,6 +1,6 @@
./src/test/compile-fail/bad-alt.rs:5:7:5:8: error: expecting {, found ; // error-pattern: expecting
./src/test/compile-fail/bad-alt.rs:5 alt x;
^ fn main() {
rt: --- let int x = 5;
rt: 0bb1:main:main: upcall fail 'explicit failure', src/comp/syntax/parse/parser.rs:112 alt x;
rt: 0bb1:main: domain main @0x9e0f04c root task failed }

View file

@ -1,6 +1,5 @@
./src/test/compile-fail/bad-name.rs:4:7:4:8: error: expecting ident // error-pattern: expecting
./src/test/compile-fail/bad-name.rs:4 let x.y[int].z foo;
^ fn main() {
rt: --- let x.y[int].z foo;
rt: f00e:main:main: upcall fail 'explicit failure', src/comp/syntax/parse/parser.rs:112 }
rt: f00e:main: domain main @0x8d6004c root task failed

View file

@ -11,7 +11,7 @@ type bubu = {x: int, y: int};
pred less_than(x: int, y: int) -> bool { ret x < y; } pred less_than(x: int, y: int) -> bool { ret x < y; }
type ordered_range = {low: int, high: int} : : less_than(low, high); type ordered_range = {low: int, high: int} : less_than(low, high);
fn main() { fn main() {
// Should fail to compile, b/c we're not doing the check // Should fail to compile, b/c we're not doing the check

View file

@ -1,16 +1,25 @@
// xfail-stage0 // xfail-stage0
// error-pattern: Unsatisfied precondition constraint (for example, even(y // error-pattern: Unsatisfied precondition constraint (for example, even(y
fn print_even(y: int) { log y; } fn print_even(y: int) : even(y) {
log y;
}
pred even(y: int) -> bool { true } pred even(y: int) -> bool {
true
}
fn main() { fn main() {
let y: int = 42;
let y: int = 42; check even(y);
check (even(y)); do {
do { print_even(y);
print_even(y); do {
do { do { do { y += 1; } while true } while true } while true do {
} while true do {
y += 1;
} while (true);
} while (true);
} while (true);
} while (true);
} }

View file

@ -1,6 +1,8 @@
./src/test/compile-fail/ext-after-attrib.rs:7:1:7:4: error: expecting [, found fmt // xfail-stage0
./src/test/compile-fail/ext-after-attrib.rs:7 #fmt("baz") // error-pattern:expecting [, found fmt
^~~
rt: --- // Don't know how to deal with a syntax extension appearing after an
rt: f00e:main:main: upcall fail 'explicit failure', src/comp/syntax/parse/parser.rs:112 // item attribute. Probably could use a better error message.
rt: f00e:main: domain main @0xa47a04c root task failed #[foo = "bar"]
#fmt("baz")
fn main() { }

View file

@ -1,6 +1,5 @@
./src/test/compile-fail/ext-noname.rs:4:3:4:4: error: expected a syntax expander name // error-pattern:expected a syntax expander name
./src/test/compile-fail/ext-noname.rs:4 #();
^ fn main() {
rt: --- #();
rt: 0bb1:main:main: upcall fail 'explicit failure', src/comp/syntax/parse/parser.rs:112 }
rt: 0bb1:main: domain main @0x91a204c root task failed

View file

@ -1,3 +1,5 @@
// error-pattern:malformed #env call // error-pattern:malformed #env call
fn main() { #env; } fn main() {
#env();
}

View file

@ -1,3 +1,5 @@
// error-pattern:format string // error-pattern:format string
fn main() { #fmt; } fn main() {
#fmt();
}

View file

@ -1,6 +1,6 @@
./src/test/compile-fail/fail-simple.rs:5:9:5:10: error: unexpected token: ; // -*- rust -*-
./src/test/compile-fail/fail-simple.rs:5 fail @ ;
^ // error-pattern:unexpected token
rt: --- fn main() {
rt: f00e:main:main: upcall fail 'explicit failure', src/comp/syntax/parse/parser.rs:112 fail @ ;
rt: f00e:main: domain main @0x994f04c root task failed }

View file

@ -6,7 +6,7 @@ pred even(x: uint) -> bool {
} else if (x == 2u) { ret true; } else { ret even(x - 2u); } } else if (x == 2u) { ret true; } else { ret even(x - 2u); }
} }
fn print_even(x: uint) { log x; } fn print_even(x: uint) : even(x) { log x; }
fn foo(x: uint) { if check even(x) { fail; } else { print_even(x); } } fn foo(x: uint) { if check even(x) { fail; } else { print_even(x); } }

View file

@ -1,11 +1,7 @@
// xfail-stage0 // xfail-stage0
//error-pattern:is an expr, expected an identifier //error-pattern:is an expr, expected an identifier
fn main() { fn main() {
#macro([#mylambda(x, body), #macro([#mylambda(x, body), {fn f(x: int) -> int {ret body}; f}]);
{
fn f(x: int) -> int { ret body }
f
}]);
assert (#mylambda(y * 1, y * 2)(8) == 16); assert(#mylambda(y*1, y*2)(8) == 16);
} }

View file

@ -2,8 +2,7 @@
//error-pattern:no clauses match //error-pattern:no clauses match
fn main() { fn main() {
#macro([#trivial, 1 * 2 * 4 * 2 * 1]); #macro([#trivial(), 1*2*4*2*1]);
assert (#trivial(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) == assert(#trivial(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) == 16);
16);
} }

View file

@ -1,6 +1,10 @@
./src/test/compile-fail/multiline-comment-line-tracking.rs:9:2:9:3: error: unexpected token: % // -*- rust -*-
./src/test/compile-fail/multiline-comment-line-tracking.rs:9 %; // parse error on line 9, but is reported on line 6 instead. // error-pattern:9:2
^
rt: --- /* 1
rt: f00e:main:main: upcall fail 'explicit failure', src/comp/syntax/parse/parser.rs:112 * 2
rt: f00e:main: domain main @0x969e04c root task failed * 3
*/
fn main() {
%; // parse error on line 9, but is reported on line 6 instead.
}

View file

@ -8,5 +8,6 @@ obj f() {
fn main() { fn main() {
let z = f(); let z = f();
check (z.g(42)); // should fail to typecheck, as z.g isn't an explicit name // should fail to typecheck, as z.g isn't an explicit name
check (z.g(42));
} }

View file

@ -2,7 +2,7 @@
// xfail-stage0 // xfail-stage0
// error-pattern: Non-predicate in constraint: lt // error-pattern: Non-predicate in constraint: lt
fn f(a: int, b: int) { } fn f(a: int, b: int) : lt(a,b) { }
obj lt(a: int, b: int) { } obj lt(a: int, b: int) { }

View file

@ -5,6 +5,7 @@
pred f(q: int) -> bool { ret true; } pred f(q: int) -> bool { ret true; }
fn main() { fn main() {
// should fail to typecheck, as pred args must be slot variables or literals // should fail to typecheck, as pred args must be slot variables
// or literals
check (f(42 * 17)); check (f(42 * 17));
} }

View file

@ -3,7 +3,7 @@
// error-pattern: Unsatisfied precondition constraint (for example, lt(a, b) // error-pattern: Unsatisfied precondition constraint (for example, lt(a, b)
fn f(a: int, b: int) { } fn f(a: int, b: int) : lt(a,b) { }
pred lt(a: int, b: int) -> bool { ret a < b; } pred lt(a: int, b: int) -> bool { ret a < b; }

View file

@ -3,7 +3,7 @@
// error-pattern: lt(a, c) // error-pattern: lt(a, c)
fn f(a: int, b: int) { } fn f(a: int, b: int) : lt(a,b) { }
pred lt(a: int, b: int) -> bool { ret a < b; } pred lt(a: int, b: int) -> bool { ret a < b; }

View file

@ -3,7 +3,7 @@
// error-pattern: Unsatisfied precondition constraint (for example, lt(a, b) // error-pattern: Unsatisfied precondition constraint (for example, lt(a, b)
fn f(a: int, b: int) { } fn f(a: int, b: int) : lt(a,b) { }
pred lt(a: int, b: int) -> bool { ret a < b; } pred lt(a: int, b: int) -> bool { ret a < b; }

View file

@ -1,6 +1,12 @@
./src/test/compile-fail/self-missing-method.rs:6:14:6:15: error: expecting ., found ( // error-pattern:expecting ., found (
./src/test/compile-fail/self-missing-method.rs:6 self(); fn main() {
^
rt: --- obj foo() {
rt: 0bb1:main:main: upcall fail 'explicit failure', src/comp/syntax/parse/parser.rs:112 fn m() {
rt: 0bb1:main: domain main @0x8f5904c root task failed self();
}
}
let a = foo;
a.m();
}

View file

@ -2,7 +2,7 @@
// xfail-stage0 // xfail-stage0
// error-pattern: unresolved name: lt // error-pattern: unresolved name: lt
fn f(a: int, b: int) { } fn f(a: int, b: int) : lt(a,b) { }
fn main() { fn main() {
let lt: int; let lt: int;

View file

@ -1,6 +1,10 @@
./src/test/compile-fail/tail-non-call.rs:5:6:5:7: error: Non-call expression in tail call // error-pattern: Non-call expression in tail call
./src/test/compile-fail/tail-non-call.rs:5 be x;
^ fn f() -> int {
rt: --- let x = 1;
rt: f00e:main:main: upcall fail 'explicit failure', src/comp/syntax/parse/parser.rs:112 be x;
rt: f00e:main: domain main @0x9d9404c root task failed }
fn main() {
let y = f();
}

View file

@ -1,6 +1,11 @@
./src/test/compile-fail/unbalanced-comment.rs:11:1:11:1: error: unterminated block comment // -*- rust -*-
./src/test/compile-fail/unbalanced-comment.rs:11 }
^ // error-pattern: unterminated block comment
rt: ---
rt: f00e:main:main: upcall fail 'explicit failure', src/comp/syntax/parse/lexer.rs:153 /*
rt: f00e:main: domain main @0x96ef04c root task failed * This is an un-balanced /* multi-line comment.
*/
fn main() {
log "hello, world.";
}

View file

@ -1,7 +1,7 @@
// xfail-stage0 // xfail-stage0
// error-pattern: Unsatisfied precondition constraint (for example, even(y // error-pattern: Unsatisfied precondition constraint (for example, even(y
fn print_even(y: int) { log y; } fn print_even(y: int) : even(y) { log y; }
pred even(y: int) -> bool { true } pred even(y: int) -> bool { true }

View file

@ -5,6 +5,11 @@ use std;
import std::str::*; import std::str::*;
import std::uint::*; import std::uint::*;
fn nop(a: uint, b: uint) { fail "quux"; } fn nop(a: uint, b: uint) : le(a, b) { fail "quux"; }
fn main() { let a: uint = 5u; let b: uint = 4u; claim (le(a, b)); nop(a, b); } fn main() {
let a: uint = 5u;
let b: uint = 4u;
claim (le(a, b));
nop(a, b);
}

View file

@ -1,6 +1,33 @@
./src/test/run-fail/task-comm-14.rs:5:0:5:2: error: expected item but found io // xfail-stage0
./src/test/run-fail/task-comm-14.rs:5 io fn main() { // xfail-stage1
^~ // xfail-stage2
rt: --- // xfail-stage3
rt: 0bb1:main:main: upcall fail 'explicit failure', src/comp/syntax/parse/parser.rs:112 io fn main() {
rt: 0bb1:main: domain main @0x919b04c root task failed let port[int] po = port();
// Spawn 10 tasks each sending us back one int.
let int i = 10;
while (i > 0) {
log i;
spawn "child" child(i, chan(po));
i = i - 1;
}
// Spawned tasks are likely killed before they get a chance to send
// anything back, so we deadlock here.
i = 10;
let int value = 0;
while (i > 0) {
log i;
po |> value;
i = i - 1;
}
log "main thread exiting";
}
io fn child(int x, chan[int] ch) {
log x;
ch <| x;
}

View file

@ -1,6 +1,15 @@
./src/test/run-pass/alt-type-simple.rs:6:6:6:10: error: found type in expression position // xfail-stage0
./src/test/run-pass/alt-type-simple.rs:6 alt type (f) { // xfail-stage1
^~~~ // xfail-stage2
rt: --- // xfail-stage3
rt: f00e:main:main: upcall fail 'explicit failure', src/comp/syntax/parse/parser.rs:112 fn altsimple(any x) {
rt: f00e:main: domain main @0x9b0204c root task failed alt type (f) {
case (int i) { print("int"); }
case (str s) { print("str"); }
}
}
fn main() {
altsimple(5);
altsimple("asdfasdfsDF");
}

View file

@ -10,9 +10,7 @@ fn main() {
let my_a = a(); let my_a = a();
// An anonymous object that overloads the 'foo' method. // An anonymous object that overloads the 'foo' method.
let let my_b =
my_b =
obj () { obj () {
fn foo() -> int { ret 3; } fn foo() -> int { ret 3; }
with with

View file

@ -43,7 +43,7 @@
fn main() { fn main() {
auto num = 12; let num = 12;
assert if (true) { 12 } else { 12 } - num == 0; assert if (true) { 12 } else { 12 } - num == 0;
assert 12 - if (true) { 12 } else { 12 } == 0; assert 12 - if (true) { 12 } else { 12 } == 0;

View file

@ -1,6 +1,14 @@
./src/test/run-pass/clone-with-exterior.rs:12:28:12:29: error: expecting (, found f // xfail-stage0
./src/test/run-pass/clone-with-exterior.rs:12 let task p = spawn thread f(z); // xfail-stage1
^ // xfail-stage2
rt: --- // xfail-stage3
rt: f00e:main:main: upcall fail 'explicit failure', src/comp/syntax/parse/parser.rs:112 fn f(@rec(int a, int b) x) {
rt: f00e:main: domain main @0x8f2504c root task failed assert (x.a == 10);
assert (x.b == 12);
}
fn main() {
let @rec(int a, int b) z = rec(a=10, b=12);
let task p = spawn thread f(z);
join p;
}

View file

@ -7,6 +7,6 @@ type bubu = {x: int, y: int};
pred less_than(x: int, y: int) -> bool { ret x < y; } pred less_than(x: int, y: int) -> bool { ret x < y; }
type ordered_range = {low: int, high: int} : : less_than(low, high); type ordered_range = {low: int, high: int} : less_than(*.low, *.high);
fn main() { } fn main() { }

View file

@ -1,6 +1,123 @@
./src/test/run-pass/destructor-ordering.rs:25:0:25:2: error: expected item but found io // xfail-stage0
./src/test/run-pass/destructor-ordering.rs:25 io fn check_order(port[order_info] expected_p) { // xfail-stage1
^~ // xfail-stage2
rt: --- // xfail-stage3
rt: 17b9:main:main: upcall fail 'explicit failure', src/comp/syntax/parse/parser.rs:112 // This test checks that destructors run in the right order. Because
rt: 17b9:main: domain main @0x96d304c root task failed // stateful objects can't have destructors, we have the destructors
// record their expected order into a channel when they execute (so
// the object becomes 'io' rather than 'state'). Then each test case
// asserts that the channel produces values in ascending order.
//
// FIXME: Write an int->str function and concatenate the whole failure
// message into a single log statement (or, even better, a print).
//
// FIXME: check_order should take only 1 line in a test, not 2+a block
// block. Since destructor-having objects can't refer to mutable state
// (like the port), we'd need a with-like construct to do the same for
// stateful objects within a scope.
//
// FIXME #21: Each test should execute in its own task, so it can fail
// independently, writing its error message to a channel that the
// parent task aggregates.
type order_info = rec(int order, str msg);
io fn check_order(port[order_info] expected_p) {
chan(expected_p) <| rec(order=-1, msg="");
let mutable int actual = 0;
// FIXME #121: Workaround for while(true) bug.
auto expected; expected_p |> expected;
auto done = -1; // FIXME: Workaround for typechecking bug.
while(expected.order != done) {
if (expected.order != actual) {
log expected.order;
log " != ";
log actual;
log expected.msg;
fail;
}
actual += 1;
expected_p |> expected;
}
}
obj dorder(chan[order_info] expected, int order, str message) {
drop {
expected <| rec(order=order, msg=message);
}
}
io fn test_simple() {
let port[order_info] tracker_p = port();
auto tracker = chan(tracker_p);
dorder(tracker, 1, "Reverse decl order");
dorder(tracker, 0, "Reverse decl order");
check_order(tracker_p);
}
io fn test_block() {
let port[order_info] tracker_p = port();
auto tracker = chan(tracker_p);
{
dorder(tracker, 2, "Before block");
{
dorder(tracker, 0, "Inside block");
}
dorder(tracker, 1, "After block");
}
check_order(tracker_p);
}
io fn test_decl_v_init() {
let port[order_info] tracker_p = port();
auto tracker = chan(tracker_p);
{
auto var1;
auto var2;
var2 = dorder(tracker, 0, "decl, not init");
var1 = dorder(tracker, 1, "decl, not init");
}
check_order(tracker_p);
}
io fn test_overwritten_obj() {
let port[order_info] tracker_p = port();
auto tracker = chan(tracker_p);
{
auto var1 = dorder(tracker, 0, "overwritten object destroyed first");
auto var2 = dorder(tracker, 2, "destroyed at end of scope");
var1 = dorder(tracker, 3, "overwriter deleted in rev decl order");
{
dorder(tracker, 1, "overwritten object destroyed before end of scope");
}
}
check_order(tracker_p);
}
// Used to embed dorder objects into an expression. Note that the
// parameters don't get destroyed.
fn combine_dorders(dorder d1, dorder d2) -> int {
ret 1;
}
io fn test_expression_destroyed_right_to_left() {
let port[order_info] tracker_p = port();
auto tracker = chan(tracker_p);
{
combine_dorders(dorder(tracker, 4, ""), dorder(tracker, 3, ""))
/ combine_dorders(dorder(tracker, 2, ""), dorder(tracker, 1, ""));
{
dorder(tracker, 0,
"expression objects live to end of block, not statement");
}
}
check_order(tracker_p);
}
io fn main() {
test_simple();
test_block();
test_decl_v_init();
test_overwritten_obj();
test_expression_destroyed_right_to_left();
}

View file

@ -5,7 +5,7 @@ pred even(x: uint) -> bool {
} else if (x == 2u) { ret true; } else { ret even(x - 2u); } } else if (x == 2u) { ret true; } else { ret even(x - 2u); }
} }
fn print_even(x: uint) { log x; } fn print_even(x: uint) : even(x) { log x; }
fn foo(x: uint) { if check even(x) { print_even(x); } else { fail; } } fn foo(x: uint) { if check even(x) { print_even(x); } else { fail; } }

View file

@ -1,4 +1,4 @@
// xfail-stage0 // xfail-stage0
fn foo() { if ret { } } fn foo() { if (ret) { } }
fn main() { foo(); } fn main() { foo(); }

View file

@ -1,11 +1,7 @@
// xfail-stage0 // xfail-stage0
fn main() { fn main() {
#macro([#mylambda(x, body), #macro([#mylambda(x,body), {fn f(x: int) -> int { ret body }; f}]);
{
fn f(x: int) -> int { ret body }
f
}]);
assert (#mylambda(y, y * 2)(8) == 16); assert(#mylambda(y,y*2)(8) == 16);
} }

View file

@ -1,7 +1,7 @@
// xfail-stage0 // xfail-stage0
fn main() { fn main() {
#macro([#trivial, 1 * 2 * 4 * 2 * 1]); #macro([#trivial(), 1*2*4*2*1]);
assert (#trivial == 16); assert(#trivial() == 16);
} }

View file

@ -1,3 +1,6 @@
// xfail-stage0 // xfail-stage0
fn main() { #macro([#m1(a), a * 4]); assert (#m1(2) == 8); } fn main() {
#macro([#m1(a), a*4]);
assert (#m1(2) == 8);
}

View file

@ -1,6 +1,25 @@
./src/test/run-pass/many.rs:21:12:21:14: error: expecting ;, found |> // xfail-stage0
./src/test/run-pass/many.rs:21 let int p |> y; // xfail-stage1
^~ // xfail-stage2
rt: --- // xfail-stage3
rt: f00e:main:main: upcall fail 'explicit failure', src/comp/syntax/parse/parser.rs:112 // -*- rust -*-
rt: f00e:main: domain main @0x8da604c root task failed
fn sub(chan[int] parent, int id) {
if (id == 0) {
parent <| 0;
} else {
let port[int] p = port();
auto child = spawn sub(chan(p), id-1);
let int y; p |> y;
parent <| y + 1;
}
}
fn main() {
let port[int] p = port();
auto child = spawn sub(chan(p), 500);
let int p |> y;
log "transmission complete";
log y;
assert (y == 500);
}

View file

@ -1,2 +1,2 @@
// xfail-stage0 // xfail-stage0
fn main() { let x = (); alt x { () { } } } fn main() { let x = (); alt x { (()) { } } }

View file

@ -1,6 +1,13 @@
./src/test/run-pass/spawn-module-qualified.rs:7:7:7:8: error: expected ';' or '}' after expression but found x // xfail-stage0
./src/test/run-pass/spawn-module-qualified.rs:7 join x; // xfail-stage1
^ // xfail-stage2
rt: --- // xfail-stage3
rt: 0bb1:main:main: upcall fail 'explicit failure', src/comp/syntax/parse/parser.rs:112 fn main() {
rt: 0bb1:main: domain main @0xa98404c root task failed auto x = spawn m::child(10);
join x;
}
mod m {
fn child(int i) {
log i;
}
}

View file

@ -1,6 +1,8 @@
./src/test/run-pass/syntax-extension-shell.rs:6:18:6:19: error: expecting (, found { // xfail-stage0
./src/test/run-pass/syntax-extension-shell.rs:6 auto s = #shell { uname -a }; // xfail-stage1
^ // xfail-stage2
rt: --- // xfail-stage3
rt: f00e:main:main: upcall fail 'explicit failure', src/comp/syntax/parse/parser.rs:112 fn main() {
rt: f00e:main: domain main @0x910c04c root task failed auto s = #shell { uname -a };
log s;
}

View file

@ -1,6 +1,41 @@
./src/test/run-pass/task-killjoin.rs:22:36:22:46: error: expecting (, found supervised // xfail-stage0
./src/test/run-pass/task-killjoin.rs:22 let task t = spawn "supervised" supervised(); // xfail-stage1
^~~~~~~~~~ // xfail-stage2
rt: --- // xfail-stage3
rt: f00e:main:main: upcall fail 'explicit failure', src/comp/syntax/parse/parser.rs:112
rt: f00e:main: domain main @0xa7b604c root task failed // Create a task that is supervised by another task,
// join the supervised task from the supervising task,
// then fail the supervised task. The supervised task
// will kill the supervising task, waking it up. The
// supervising task no longer needs to be wakened when
// the supervised task exits.
fn supervised() {
// Yield to make sure the supervisor joins before we
// fail. This is currently not needed because the supervisor
// runs first, but I can imagine that changing.
yield;
fail;
}
fn supervisor() {
let task t = spawn "supervised" supervised();
join t;
}
fn main() {
// Start the test in another domain so that
// the process doesn't return a failure status as a result
// of the main task being killed.
let task dom2 = spawn thread "supervisor" supervisor();
join dom2;
}
// Local Variables:
// mode: rust;
// fill-column: 78;
// indent-tabs-mode: nil
// c-basic-offset: 4
// buffer-file-coding-system: utf-8-unix
// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
// End:

View file

@ -1,6 +1,20 @@
./src/test/run-pass/threads.rs:11:17:11:24: error: expecting (, found "child" // xfail-stage0
./src/test/run-pass/threads.rs:11 spawn thread "child" child(i); // xfail-stage1
^~~~~~~ // xfail-stage2
rt: --- // xfail-stage3
rt: f00e:main:main: upcall fail 'explicit failure', src/comp/syntax/parse/parser.rs:112
rt: f00e:main: domain main @0x999804c root task failed // -*- rust -*-
fn main() {
let int i = 10;
while (i > 0) {
spawn thread "child" child(i);
i = i - 1;
}
log "main thread exiting";
}
fn child(int x) {
log x;
}

View file

@ -1,7 +1,7 @@
pred p(i: int) -> bool { true } pred p(i: int) -> bool { true }
fn f(i: int) -> int { i } fn f(i: int) : p(i) -> int { i }
fn g(i: int) -> int { f(i) } fn g(i: int) : p(i) -> int { f(i) }
fn main() { } fn main() { }

View file

@ -1,6 +1,18 @@
./src/test/run-pass/user.rs:9:16:9:17: error: unexpected token: _ // xfail-stage0
./src/test/run-pass/user.rs:9 uuid = _, ver = _); // xfail-stage1
^ // xfail-stage2
rt: --- // xfail-stage3
rt: f00e:main:main: upcall fail 'explicit failure', src/comp/syntax/parse/parser.rs:112 // -*- rust -*-
rt: f00e:main: domain main @0x907604c root task failed
use std (name = "std",
url = "http://rust-lang.org/src/std",
uuid = _, ver = _);
fn main() {
auto s = std::str.alloc(10 as uint);
s += "hello ";
log s;
s += "there";
log s;
auto z = std::vec.alloc[int](10 as uint);
}

View file

@ -1,6 +1,10 @@
./src/test/run-pass/vec-slice.rs:7:16:7:17: error: expecting ), found , // xfail-stage0
./src/test/run-pass/vec-slice.rs:7 auto v2 = v.(1,2); // xfail-stage1
^ // xfail-stage2
rt: --- // xfail-stage3
rt: f00e:main:main: upcall fail 'explicit failure', src/comp/syntax/parse/parser.rs:112 fn main() {
rt: f00e:main: domain main @0xa73404c root task failed let vec[int] v = [1,2,3,4,5];
auto v2 = v.(1,2);
assert (v2.(0) == 2);
assert (v2.(1) == 3);
}