diff --git a/src/libcore/core.rc b/src/libcore/core.rc index a90758694f83a..ef88258daec59 100644 --- a/src/libcore/core.rc +++ b/src/libcore/core.rc @@ -41,6 +41,10 @@ export either, option, result, iter; export libc, os, io, run, rand, sys, unsafe, logging; export arc, comm, task, future, pipes; export extfmt; +// The test harness links against core, so don't include runtime in tests. +// FIXME (#2861): Uncomment this after snapshot gets updated. +//#[cfg(notest)] +export rt; export tuple; export to_str, to_bytes; export dvec, dvec_iter; @@ -206,6 +210,9 @@ mod unsafe; // Exported but not part of the public interface mod extfmt; +// The test harness links against core, so don't include runtime in tests. +#[cfg(notest)] +mod rt; // For internal use, not exported diff --git a/src/libcore/rt.rs b/src/libcore/rt.rs new file mode 100644 index 0000000000000..356e81689f02f --- /dev/null +++ b/src/libcore/rt.rs @@ -0,0 +1,61 @@ +//! Runtime calls emitted by the compiler. + +import libc::c_char; +import libc::c_void; +import libc::size_t; +import libc::uintptr_t; + +type rust_task = c_void; + +extern mod rustrt { + #[rust_stack] + fn rust_upcall_fail(expr: *c_char, file: *c_char, line: size_t); + + #[rust_stack] + fn rust_upcall_exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char; + + #[rust_stack] + fn rust_upcall_exchange_free(ptr: *c_char); + + #[rust_stack] + fn rust_upcall_malloc(td: *c_char, size: uintptr_t) -> *c_char; + + #[rust_stack] + fn rust_upcall_free(ptr: *c_char); +} + +// FIXME (#2861): This needs both the attribute, and the name prefixed with +// 'rt_', otherwise the compiler won't find it. To fix this, see +// gather_rust_rtcalls. +#[rt(fail)] +fn rt_fail(expr: *c_char, file: *c_char, line: size_t) { + rustrt::rust_upcall_fail(expr, file, line); +} + +#[rt(exchange_malloc)] +fn rt_exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char { + ret rustrt::rust_upcall_exchange_malloc(td, size); +} + +#[rt(exchange_free)] +fn rt_exchange_free(ptr: *c_char) { + rustrt::rust_upcall_exchange_free(ptr); +} + +#[rt(malloc)] +fn rt_malloc(td: *c_char, size: uintptr_t) -> *c_char { + ret rustrt::rust_upcall_malloc(td, size); +} + +#[rt(free)] +fn rt_free(ptr: *c_char) { + rustrt::rust_upcall_free(ptr); +} + +// Local Variables: +// mode: rust; +// fill-column: 78; +// indent-tabs-mode: nil +// c-basic-offset: 4 +// buffer-file-coding-system: utf-8-unix +// End: diff --git a/src/rt/rust_upcall.cpp b/src/rt/rust_upcall.cpp index cae5ce45b5497..8bab4b9e2d3d7 100644 --- a/src/rt/rust_upcall.cpp +++ b/src/rt/rust_upcall.cpp @@ -98,6 +98,16 @@ upcall_fail(char const *expr, UPCALL_SWITCH_STACK(task, &args, upcall_s_fail); } +// FIXME (#2861): Alias used by libcore/rt.rs to avoid naming conflicts with +// autogenerated wrappers for upcall_fail. Remove this when we fully move away +// away from the C upcall path. +extern "C" CDECL void +rust_upcall_fail(char const *expr, + char const *file, + size_t line) { + upcall_fail(expr, file, line); +} + struct s_trace_args { rust_task *task; char const *msg; @@ -160,6 +170,14 @@ upcall_exchange_malloc(type_desc *td, uintptr_t size) { return args.retval; } +// FIXME (#2861): Alias used by libcore/rt.rs to avoid naming conflicts with +// autogenerated wrappers for upcall_exchange_malloc. Remove this when we +// fully move away away from the C upcall path. +extern "C" CDECL uintptr_t +rust_upcall_exchange_malloc(type_desc *td, uintptr_t size) { + return upcall_exchange_malloc(td, size); +} + struct s_exchange_free_args { rust_task *task; void *ptr; @@ -179,6 +197,14 @@ upcall_exchange_free(void *ptr) { UPCALL_SWITCH_STACK(task, &args, upcall_s_exchange_free); } +// FIXME (#2861): Alias used by libcore/rt.rs to avoid naming conflicts with +// autogenerated wrappers for upcall_exchange_free. Remove this when we fully +// move away away from the C upcall path. +extern "C" CDECL void +rust_upcall_exchange_free(void *ptr) { + return upcall_exchange_free(ptr); +} + /********************************************************************** * Allocate an object in the task-local heap. */ @@ -220,6 +246,14 @@ upcall_malloc(type_desc *td, uintptr_t size) { return args.retval; } +// FIXME (#2861): Alias used by libcore/rt.rs to avoid naming conflicts with +// autogenerated wrappers for upcall_malloc. Remove this when we fully move +// away away from the C upcall path. +extern "C" CDECL uintptr_t +rust_upcall_malloc(type_desc *td, uintptr_t size) { + return upcall_malloc(td, size); +} + /********************************************************************** * Called whenever an object in the task-local heap is freed. */ @@ -252,6 +286,14 @@ upcall_free(void* ptr) { UPCALL_SWITCH_STACK(task, &args, upcall_s_free); } +// FIXME (#2861): Alias used by libcore/rt.rs to avoid naming conflicts with +// autogenerated wrappers for upcall_free. Remove this when we fully move away +// away from the C upcall path. +extern "C" CDECL void +rust_upcall_free(void* ptr) { + upcall_free(ptr); +} + /********************************************************************** * Sanity checks on boxes, insert when debugging possible * use-after-free bugs. See maybe_validate_box() in trans.rs. diff --git a/src/rustc/driver/driver.rs b/src/rustc/driver/driver.rs index 1222cfc2d6085..52aa88e6cb639 100644 --- a/src/rustc/driver/driver.rs +++ b/src/rustc/driver/driver.rs @@ -69,10 +69,11 @@ fn build_configuration(sess: session, argv0: ~str, input: input) -> // If the user wants a test runner, then add the test cfg let gen_cfg = { - if sess.opts.test && !attr::contains_name(user_cfg, ~"test") - { + if sess.opts.test && !attr::contains_name(user_cfg, ~"test") { ~[attr::mk_word_item(@~"test")] - } else { ~[] } + } else { + ~[attr::mk_word_item(@~"notest")] + } }; ret vec::append(vec::append(user_cfg, gen_cfg), default_cfg); } diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs index 951bcce910f08..05c432401657a 100644 --- a/src/rustc/middle/trans/base.rs +++ b/src/rustc/middle/trans/base.rs @@ -37,7 +37,7 @@ import link::{mangle_internal_name_by_type_only, mangle_internal_name_by_path, mangle_internal_name_by_path_and_seq, mangle_exported_name}; -import metadata::{csearch, cstore, encoder}; +import metadata::{csearch, cstore, decoder, encoder}; import metadata::common::link_meta; import util::ppaux; import util::ppaux::{ty_to_str, ty_to_short_str}; @@ -244,15 +244,13 @@ fn trans_foreign_call(cx: block, externs: hashmap<~str, ValueRef>, fn trans_free(cx: block, v: ValueRef) -> block { let _icx = cx.insn_ctxt(~"trans_free"); - Call(cx, cx.ccx().upcalls.free, ~[PointerCast(cx, v, T_ptr(T_i8()))]); - cx + trans_rtcall(cx, ~"free", ~[PointerCast(cx, v, T_ptr(T_i8()))], ignore) } fn trans_unique_free(cx: block, v: ValueRef) -> block { let _icx = cx.insn_ctxt(~"trans_unique_free"); - Call(cx, cx.ccx().upcalls.exchange_free, - ~[PointerCast(cx, v, T_ptr(T_i8()))]); - ret cx; + trans_rtcall(cx, ~"exchange_free", ~[PointerCast(cx, v, T_ptr(T_i8()))], + ignore) } fn umax(cx: block, a: ValueRef, b: ValueRef) -> ValueRef { @@ -356,15 +354,13 @@ fn opaque_box_body(bcx: block, // malloc_raw_dyn: allocates a box to contain a given type, but with a // potentially dynamic size. fn malloc_raw_dyn(bcx: block, t: ty::t, heap: heap, - size: ValueRef) -> ValueRef { + size: ValueRef) -> result { let _icx = bcx.insn_ctxt(~"malloc_raw"); let ccx = bcx.ccx(); - let (mk_fn, upcall) = alt heap { - heap_shared { (ty::mk_imm_box, ccx.upcalls.malloc) } - heap_exchange { - (ty::mk_imm_uniq, ccx.upcalls.exchange_malloc ) - } + let (mk_fn, rtcall) = alt heap { + heap_shared { (ty::mk_imm_box, ~"malloc") } + heap_exchange { (ty::mk_imm_uniq, ~"exchange_malloc") } }; // Grab the TypeRef type of box_ptr_ty. @@ -376,37 +372,42 @@ fn malloc_raw_dyn(bcx: block, t: ty::t, heap: heap, lazily_emit_all_tydesc_glue(ccx, static_ti); // Allocate space: - let rval = Call(bcx, upcall, ~[static_ti.tydesc, size]); - ret PointerCast(bcx, rval, llty); + let tydesc = PointerCast(bcx, static_ti.tydesc, T_ptr(T_i8())); + let rval = alloca_zeroed(bcx, T_ptr(T_i8())); + let bcx = trans_rtcall(bcx, rtcall, ~[tydesc, size], save_in(rval)); + let retval = {bcx: bcx, val: PointerCast(bcx, Load(bcx, rval), llty)}; + ret retval; } // malloc_raw: expects an unboxed type and returns a pointer to // enough space for a box of that type. This includes a rust_opaque_box // header. -fn malloc_raw(bcx: block, t: ty::t, heap: heap) -> ValueRef { +fn malloc_raw(bcx: block, t: ty::t, heap: heap) -> result { malloc_raw_dyn(bcx, t, heap, llsize_of(bcx.ccx(), type_of(bcx.ccx(), t))) } // malloc_general_dyn: usefully wraps malloc_raw_dyn; allocates a box, // and pulls out the body -fn malloc_general_dyn(bcx: block, t: ty::t, heap: heap, size: ValueRef) -> - {box: ValueRef, body: ValueRef} { +fn malloc_general_dyn(bcx: block, t: ty::t, heap: heap, size: ValueRef) + -> {bcx: block, box: ValueRef, body: ValueRef} { let _icx = bcx.insn_ctxt(~"malloc_general"); - let llbox = malloc_raw_dyn(bcx, t, heap, size); + let {bcx: bcx, val: llbox} = malloc_raw_dyn(bcx, t, heap, size); let non_gc_box = non_gc_box_cast(bcx, llbox); let body = GEPi(bcx, non_gc_box, ~[0u, abi::box_field_body]); - ret {box: llbox, body: body}; + ret {bcx: bcx, box: llbox, body: body}; } -fn malloc_general(bcx: block, t: ty::t, heap: heap) -> - {box: ValueRef, body: ValueRef} { +fn malloc_general(bcx: block, t: ty::t, heap: heap) + -> {bcx: block, box: ValueRef, body: ValueRef} { malloc_general_dyn(bcx, t, heap, llsize_of(bcx.ccx(), type_of(bcx.ccx(), t))) } -fn malloc_boxed(bcx: block, t: ty::t) -> {box: ValueRef, body: ValueRef} { +fn malloc_boxed(bcx: block, t: ty::t) + -> {bcx: block, box: ValueRef, body: ValueRef} { malloc_general(bcx, t, heap_shared) } -fn malloc_unique(bcx: block, t: ty::t) -> {box: ValueRef, body: ValueRef} { +fn malloc_unique(bcx: block, t: ty::t) + -> {bcx: block, box: ValueRef, body: ValueRef} { malloc_general(bcx, t, heap_exchange) } @@ -1464,7 +1465,7 @@ fn trans_boxed_expr(bcx: block, contents: @ast::expr, t: ty::t, heap: heap, dest: dest) -> block { let _icx = bcx.insn_ctxt(~"trans_boxed_expr"); - let {box, body} = malloc_general(bcx, t, heap); + let {bcx, box, body} = malloc_general(bcx, t, heap); add_clean_free(bcx, box, heap); let bcx = trans_expr_save_in(bcx, contents, body); revoke_clean(bcx, box); @@ -3942,11 +3943,26 @@ fn trans_fail_value(bcx: block, sp_opt: option, let V_str = PointerCast(bcx, V_fail_str, T_ptr(T_i8())); let V_filename = PointerCast(bcx, V_filename, T_ptr(T_i8())); let args = ~[V_str, V_filename, C_int(ccx, V_line)]; - let bcx = invoke(bcx, bcx.ccx().upcalls._fail, args); + let bcx = trans_rtcall(bcx, ~"fail", args, ignore); Unreachable(bcx); ret bcx; } +fn trans_rtcall(bcx: block, name: ~str, args: ~[ValueRef], dest: dest) + -> block { + let did = bcx.ccx().rtcalls[name]; + let fty = if did.crate == ast::local_crate { + ty::node_id_to_type(bcx.ccx().tcx, did.node) + } else { + csearch::get_type(bcx.ccx().tcx, did).ty + }; + let rty = ty::ty_fn_ret(fty); + ret trans_call_inner( + bcx, none, fty, rty, + |bcx| lval_static_fn_inner(bcx, did, 0, ~[], none), + arg_vals(args), dest); +} + fn trans_break_cont(bcx: block, to_end: bool) -> block { let _icx = bcx.insn_ctxt(~"trans_break_cont"); @@ -5314,6 +5330,83 @@ fn trap(bcx: block) { } } +fn push_rtcall(ccx: @crate_ctxt, name: ~str, did: ast::def_id) { + if ccx.rtcalls.contains_key(name) { + fail #fmt("multiple definitions for runtime call %s", name); + } + ccx.rtcalls.insert(name, did); +} + +fn gather_local_rtcalls(ccx: @crate_ctxt, crate: @ast::crate) { + visit::visit_crate(*crate, (), visit::mk_simple_visitor(@{ + visit_item: |item| alt item.node { + ast::item_fn(decl, _, _) { + let attr_metas = attr::attr_metas( + attr::find_attrs_by_name(item.attrs, ~"rt")); + do vec::iter(attr_metas) |attr_meta| { + alt attr::get_meta_item_list(attr_meta) { + some(list) { + let name = *attr::get_meta_item_name(vec::head(list)); + push_rtcall(ccx, name, {crate: ast::local_crate, + node: item.id}); + } + none {} + } + } + } + _ {} + } + with *visit::default_simple_visitor() + })); +} + +fn gather_external_rtcalls(ccx: @crate_ctxt) { + do cstore::iter_crate_data(ccx.sess.cstore) |_cnum, cmeta| { + do decoder::each_path(cmeta) |path| { + let pathname = path.path_string; + alt path.def_like { + decoder::dl_def(d) { + alt d { + ast::def_fn(did, _) { + // FIXME (#2861): This should really iterate attributes + // like gather_local_rtcalls, but we'll need to + // export attributes in metadata/encoder before we can do + // that. + let sentinel = "rt::rt_"; + let slen = str::len(sentinel); + if str::starts_with(pathname, sentinel) { + let name = str::substr(pathname, + slen, str::len(pathname)-slen); + push_rtcall(ccx, name, did); + } + } + _ {} + } + } + _ {} + } + true + } + } +} + +fn gather_rtcalls(ccx: @crate_ctxt, crate: @ast::crate) { + gather_local_rtcalls(ccx, crate); + gather_external_rtcalls(ccx); + + // FIXME (#2861): Check for other rtcalls too, once they are + // supported. Also probably want to check type signature so we don't crash + // in some obscure place in LLVM if the user provides the wrong signature + // for an rtcall. + let expected_rtcalls = + ~[~"exchange_free", ~"exchange_malloc", ~"fail", ~"free", ~"malloc"]; + for vec::each(expected_rtcalls) |name| { + if !ccx.rtcalls.contains_key(name) { + fail #fmt("no definition for runtime call %s", name); + } + } +} + fn create_module_map(ccx: @crate_ctxt) -> ValueRef { let elttype = T_struct(~[ccx.int_type, ccx.int_type]); let maptype = T_array(elttype, ccx.module_data.size() + 1u); @@ -5544,6 +5637,7 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt, upcalls: upcall::declare_upcalls(targ_cfg, tn, tydesc_type, llmod), + rtcalls: str_hash::(), tydesc_type: tydesc_type, int_type: int_type, float_type: float_type, @@ -5557,6 +5651,8 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt, mut do_not_commit_warning_issued: false}; + gather_rtcalls(ccx, crate); + { let _icx = ccx.insn_ctxt(~"data"); trans_constants(ccx, crate); diff --git a/src/rustc/middle/trans/closure.rs b/src/rustc/middle/trans/closure.rs index dfeecabeb1084..c8d55ff09459e 100644 --- a/src/rustc/middle/trans/closure.rs +++ b/src/rustc/middle/trans/closure.rs @@ -138,7 +138,7 @@ fn mk_closure_tys(tcx: ty::ctxt, fn allocate_cbox(bcx: block, ck: ty::closure_kind, cdata_ty: ty::t) - -> ValueRef { + -> result { let _icx = bcx.insn_ctxt(~"closure::allocate_cbox"); let ccx = bcx.ccx(), tcx = ccx.tcx; @@ -153,7 +153,7 @@ fn allocate_cbox(bcx: block, } // Allocate and initialize the box: - let llbox = alt ck { + let {bcx, val} = alt ck { ty::ck_box { malloc_raw(bcx, cdata_ty, heap_shared) } @@ -164,11 +164,11 @@ fn allocate_cbox(bcx: block, let cbox_ty = tuplify_box_ty(tcx, cdata_ty); let llbox = base::alloc_ty(bcx, cbox_ty); nuke_ref_count(bcx, llbox); - llbox + {bcx: bcx, val: llbox} } }; - ret llbox; + ret {bcx: bcx, val: val}; } type closure_result = { @@ -191,7 +191,7 @@ fn store_environment(bcx: block, let cdata_ty = mk_closure_tys(tcx, bound_values); // allocate closure in the heap - let llbox = allocate_cbox(bcx, ck, cdata_ty); + let {bcx: bcx, val: llbox} = allocate_cbox(bcx, ck, cdata_ty); let mut temp_cleanups = ~[]; // cbox_ty has the form of a tuple: (a, b, c) we want a ptr to a @@ -362,14 +362,14 @@ fn trans_expr_fn(bcx: block, dest: dest) -> block { let _icx = bcx.insn_ctxt(~"closure::trans_expr_fn"); if dest == ignore { ret bcx; } - let ccx = bcx.ccx(), bcx = bcx; + let ccx = bcx.ccx(); let fty = node_id_type(bcx, id); let llfnty = type_of_fn_from_ty(ccx, fty); let sub_path = vec::append_one(bcx.fcx.path, path_name(@~"anon")); let s = mangle_internal_name_by_path(ccx, sub_path); let llfn = decl_internal_cdecl_fn(ccx.llmod, s, llfnty); - let trans_closure_env = fn@(ck: ty::closure_kind) -> ValueRef { + let trans_closure_env = fn@(ck: ty::closure_kind) -> result { let cap_vars = capture::compute_capture_vars( ccx.tcx, id, proto, cap_clause); let ret_handle = alt is_loop_body { some(x) { x } none { none } }; @@ -384,20 +384,21 @@ fn trans_expr_fn(bcx: block, Store(bcx, C_bool(true), bcx.fcx.llretptr); } }); - llbox + {bcx: bcx, val: llbox} }; - let closure = alt proto { + let {bcx: bcx, val: closure} = alt proto { ast::proto_any | ast::proto_block { trans_closure_env(ty::ck_block) } ast::proto_box { trans_closure_env(ty::ck_box) } ast::proto_uniq { trans_closure_env(ty::ck_uniq) } ast::proto_bare { trans_closure(ccx, sub_path, decl, body, llfn, no_self, none, id, |_fcx| { }, |_bcx| { }); - C_null(T_opaque_box_ptr(ccx)) + {bcx: bcx, val: C_null(T_opaque_box_ptr(ccx))} } }; fill_fn_pair(bcx, get_dest_addr(dest), llfn, closure); + ret bcx; } @@ -459,9 +460,12 @@ fn make_opaque_cbox_take_glue( let sz = Add(bcx, sz, shape::llsize_of(ccx, T_box_header(ccx))); // Allocate memory, update original ptr, and copy existing data - let malloc = ccx.upcalls.exchange_malloc; - let cbox_out = Call(bcx, malloc, ~[tydesc, sz]); - let cbox_out = PointerCast(bcx, cbox_out, llopaquecboxty); + let malloc = ~"exchange_malloc"; + let opaque_tydesc = PointerCast(bcx, tydesc, T_ptr(T_i8())); + let rval = alloca_zeroed(bcx, T_ptr(T_i8())); + let bcx = trans_rtcall(bcx, malloc, ~[opaque_tydesc, sz], + save_in(rval)); + let cbox_out = PointerCast(bcx, Load(bcx, rval), llopaquecboxty); call_memmove(bcx, cbox_out, cbox_in, sz); Store(bcx, cbox_out, cboxptr); diff --git a/src/rustc/middle/trans/common.rs b/src/rustc/middle/trans/common.rs index 77929bdd6a3c5..c002c5a2a43c9 100644 --- a/src/rustc/middle/trans/common.rs +++ b/src/rustc/middle/trans/common.rs @@ -118,6 +118,7 @@ type crate_ctxt = { maps: astencode::maps, stats: stats, upcalls: @upcall::upcalls, + rtcalls: hashmap<~str, ast::def_id>, tydesc_type: TypeRef, int_type: TypeRef, float_type: TypeRef, diff --git a/src/rustc/middle/trans/impl.rs b/src/rustc/middle/trans/impl.rs index e27e6d14ec94f..10c410b6ac22b 100644 --- a/src/rustc/middle/trans/impl.rs +++ b/src/rustc/middle/trans/impl.rs @@ -288,7 +288,7 @@ fn trans_cast(bcx: block, val: @ast::expr, id: ast::node_id, dest: dest) if dest == ignore { ret trans_expr(bcx, val, ignore); } let ccx = bcx.ccx(); let v_ty = expr_ty(bcx, val); - let {box: llbox, body: body} = malloc_boxed(bcx, v_ty); + let {bcx: bcx, box: llbox, body: body} = malloc_boxed(bcx, v_ty); add_clean_free(bcx, llbox, heap_shared); let bcx = trans_expr_save_in(bcx, val, body); revoke_clean(bcx, llbox); diff --git a/src/rustc/middle/trans/tvec.rs b/src/rustc/middle/trans/tvec.rs index 0037db16b6fd8..bc698e6e3d290 100644 --- a/src/rustc/middle/trans/tvec.rs +++ b/src/rustc/middle/trans/tvec.rs @@ -68,7 +68,8 @@ fn alloc_raw(bcx: block, unit_ty: ty::t, let vecbodyty = ty::mk_mut_unboxed_vec(bcx.tcx(), unit_ty); let vecsize = Add(bcx, alloc, llsize_of(ccx, ccx.opaque_vec_type)); - let {box, body} = base::malloc_general_dyn(bcx, vecbodyty, heap, vecsize); + let {bcx, box, body} = + base::malloc_general_dyn(bcx, vecbodyty, heap, vecsize); Store(bcx, fill, GEPi(bcx, body, ~[0u, abi::vec_elt_fill])); Store(bcx, alloc, GEPi(bcx, body, ~[0u, abi::vec_elt_alloc])); ret {bcx: bcx, val: box}; diff --git a/src/rustc/middle/trans/uniq.rs b/src/rustc/middle/trans/uniq.rs index b044d0ac23c68..b1d7762ec7be2 100644 --- a/src/rustc/middle/trans/uniq.rs +++ b/src/rustc/middle/trans/uniq.rs @@ -34,7 +34,8 @@ fn autoderef(bcx: block, v: ValueRef, t: ty::t) -> {v: ValueRef, t: ty::t} { fn duplicate(bcx: block, v: ValueRef, t: ty::t) -> result { let _icx = bcx.insn_ctxt(~"uniq::duplicate"); let content_ty = content_ty(t); - let {box: dst_box, body: dst_body} = malloc_unique(bcx, content_ty); + let {bcx: bcx, box: dst_box, body: dst_body} = + malloc_unique(bcx, content_ty); let src_box = v; let src_body = opaque_box_body(bcx, content_ty, src_box); diff --git a/src/test/run-pass/module-polymorphism.rc b/src/test/run-pass/module-polymorphism.rc index 781e3a279b194..3f93608e53add 100644 --- a/src/test/run-pass/module-polymorphism.rc +++ b/src/test/run-pass/module-polymorphism.rc @@ -1,8 +1,5 @@ -#[no_core]; - - #[path = "module-polymorphism-files"] -mod float { +mod my_float { // The type of the float import inst::T; @@ -18,7 +15,7 @@ mod float { } #[path = "module-polymorphism-files"] -mod f64 { +mod my_f64 { import inst::T; @@ -33,7 +30,7 @@ mod f64 { } #[path = "module-polymorphism-files"] -mod f32 { +mod my_f32 { import inst::T; #[path = "inst_f32.rs"] diff --git a/src/test/run-pass/module-polymorphism.rs b/src/test/run-pass/module-polymorphism.rs index e2f8350ef72af..26c3582d6a635 100644 --- a/src/test/run-pass/module-polymorphism.rs +++ b/src/test/run-pass/module-polymorphism.rs @@ -5,7 +5,7 @@ fn main() { // All of these functions are defined by a single module // source file but instantiated for different types - assert float::template::plus(1.0f, 2.0f) == 3.0f; - assert f64::template::plus(1.0f64, 2.0f64) == 3.0f64; - assert f32::template::plus(1.0f32, 2.0f32) == 3.0f32; + assert my_float::template::plus(1.0f, 2.0f) == 3.0f; + assert my_f64::template::plus(1.0f64, 2.0f64) == 3.0f64; + assert my_f32::template::plus(1.0f32, 2.0f32) == 3.0f32; } \ No newline at end of file diff --git a/src/test/run-pass/module-polymorphism2.rc b/src/test/run-pass/module-polymorphism2.rc index 0d64cb46a2672..bc801bcb4a3f2 100644 --- a/src/test/run-pass/module-polymorphism2.rc +++ b/src/test/run-pass/module-polymorphism2.rc @@ -1,6 +1,3 @@ -#[no_core]; - - #[path = "module-polymorphism2-files"] mod mystd { diff --git a/src/test/run-pass/module-polymorphism3.rc b/src/test/run-pass/module-polymorphism3.rc index 34dc9000e3236..3ed7be15ff5fa 100644 --- a/src/test/run-pass/module-polymorphism3.rc +++ b/src/test/run-pass/module-polymorphism3.rc @@ -1,5 +1,3 @@ -#[no_core]; - // Use one template module to specify in a single file the implementation // of functions for multiple types