From 9f5dddf08cea3b8fcdcffaae89416a9dc180cdd6 Mon Sep 17 00:00:00 2001 From: Paul Stansifer Date: Tue, 31 May 2011 18:24:06 -0700 Subject: [PATCH] Now imports are not re-exported unless 'export' is explicitly used. --- src/comp/back/upcall.rs | 9 +- src/comp/driver/rustc.rs | 6 +- src/comp/front/ast.rs | 28 +++++- src/comp/front/parser.rs | 4 +- src/comp/middle/trans.rs | 51 +++++----- src/comp/middle/tstate/collect_locals.rs | 2 +- src/comp/middle/tstate/pre_post_conditions.rs | 96 +------------------ src/comp/middle/tstate/states.rs | 92 +----------------- src/comp/middle/typeck.rs | 2 +- src/comp/middle/walk.rs | 2 +- src/comp/util/common.rs | 2 +- src/lib/str.rs | 45 +++++++++ src/test/compile-fail/import-glob-circular.rs | 6 ++ src/test/compile-fail/import-loop-2.rs | 2 + src/test/compile-fail/import-loop.rs | 1 + src/test/compile-fail/import5.rs | 15 +++ src/test/run-pass/import-glob-1.rs | 3 + src/test/run-pass/import-glob-circular.rs | 6 ++ src/test/run-pass/import5.rs | 1 + src/test/run-pass/import6.rs | 1 + src/test/run-pass/import7.rs | 1 + 21 files changed, 148 insertions(+), 227 deletions(-) create mode 100644 src/test/compile-fail/import5.rs diff --git a/src/comp/back/upcall.rs b/src/comp/back/upcall.rs index e80100cc55d..f6f6c26f6ae 100644 --- a/src/comp/back/upcall.rs +++ b/src/comp/back/upcall.rs @@ -1,10 +1,6 @@ import middle::trans; import trans::decl_cdecl_fn; -import trans::type_names; -import trans::ModuleRef; -import trans::TypeRef; -import trans::ValueRef; import trans::T_f32; import trans::T_f64; @@ -23,6 +19,11 @@ import trans::T_taskptr; import trans::T_tydesc; import trans::T_void; +import lib::llvm::type_names; +import lib::llvm::llvm::ModuleRef; +import lib::llvm::llvm::ValueRef; +import lib::llvm::llvm::TypeRef; + type upcalls = rec( ValueRef grow_task, ValueRef log_int, diff --git a/src/comp/driver/rustc.rs b/src/comp/driver/rustc.rs index fe5c992d531..49bbf2b1e33 100644 --- a/src/comp/driver/rustc.rs +++ b/src/comp/driver/rustc.rs @@ -103,9 +103,9 @@ fn compile_input(session::session sess, } auto llmod = - time[llvm::ModuleRef](time_passes, "translation", - bind trans::trans_crate(sess, crate, - ty_cx, output)); + time[llvm::llvm::ModuleRef](time_passes, "translation", + bind trans::trans_crate(sess, crate, + ty_cx, output)); time[()](time_passes, "LLVM passes", bind link::write::run_passes(sess, llmod, output)); diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index 0d97a09bfc7..4a8b96d5ed4 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -438,20 +438,40 @@ tag native_item_ { } fn is_exported(ident i, _mod m) -> bool { - auto count = 0; + auto nonlocal = true; + for (@ast::item it in m.items) { + if (item_ident(it) == i) { + nonlocal = false; + } + alt (it.node) { + case (item_tag(_, ?variants, _, _, _)) { + for (variant v in variants) { + if (v.node.name == i) { + nonlocal = false; + } + } + } + case (_) {} + } + } + + + auto count = 0u; for (@ast::view_item vi in m.view_items) { alt (vi.node) { case (ast::view_item_export(?id)) { if (str::eq(i, id)) { + // even if it's nonlocal (since it's explicit) ret true; } - count += 1; + count += 1u; } case (_) { /* fall through */ } } } - // If there are no declared exports then everything is exported - if (count == 0) { + // If there are no declared exports then + // everything not imported is exported + if (count == 0u && !nonlocal) { ret true; } else { ret false; diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs index 2dea137f3ae..29da15fda36 100644 --- a/src/comp/front/parser.rs +++ b/src/comp/front/parser.rs @@ -231,7 +231,7 @@ fn expect(&parser p, token::token t) { } } -fn spanned[T](uint lo, uint hi, &T node) -> ast::spanned[T] { +fn spanned[T](uint lo, uint hi, &T node) -> common::spanned[T] { ret rec(node=node, span=rec(lo=lo, hi=hi)); } @@ -1008,7 +1008,7 @@ fn parse_bottom_expr(&parser p) -> @ast::expr { * loading rust crates to process extensions. */ -fn expand_syntax_ext(&parser p, ast::span sp, +fn expand_syntax_ext(&parser p, common::span sp, &ast::path path, vec[@ast::expr] args, option::t[str] body) -> ast::expr_ { diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index b5803606d58..d3ea00ab92d 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -26,6 +26,7 @@ import util::common::istr; import util::common::new_def_hash; import util::common::new_str_hash; import util::common::local_rhs_span; +import util::common::span; import lib::llvm::llvm; import lib::llvm::builder; @@ -215,7 +216,7 @@ state type fn_ctxt = rec( hashmap[ty::t, derived_tydesc_info] derived_tydescs, // The source span where this function comes from, for error reporting. - ast::span sp, + span sp, // This function's enclosing local context. @local_ctxt lcx @@ -273,7 +274,7 @@ state type block_ctxt = rec( mutable vec[cleanup] cleanups, // The source span where this block comes from, for error reporting. - ast::span sp, + span sp, // The function context for the function to which this block is attached. @fn_ctxt fcx @@ -502,7 +503,7 @@ fn T_glue_fn(&type_names tn) -> TypeRef { ret t; } -fn T_dtor(&@crate_ctxt ccx, &ast::span sp, TypeRef llself_ty) -> TypeRef { +fn T_dtor(&@crate_ctxt ccx, &span sp, TypeRef llself_ty) -> TypeRef { ret type_of_fn_full(ccx, sp, ast::proto_fn, some[TypeRef](llself_ty), vec::empty[ty::arg](), ty::mk_nil(ccx.tcx), 0u); } @@ -693,7 +694,7 @@ fn T_opaque_chan_ptr() -> TypeRef { ret T_ptr(T_i8()); } // return value was always meaningless in that case anyhow). Beware! // // TODO: Enforce via a predicate. -fn type_of(&@crate_ctxt cx, &ast::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)) { cx.sess.span_err (sp, "type_of() called on a type with dynamic size: " + @@ -704,7 +705,7 @@ fn type_of(&@crate_ctxt cx, &ast::span sp, &ty::t t) -> TypeRef { ret type_of_inner(cx, sp, t); } -fn type_of_explicit_args(&@crate_ctxt cx, &ast::span sp, +fn type_of_explicit_args(&@crate_ctxt cx, &span sp, &vec[ty::arg] inputs) -> vec[TypeRef] { let vec[TypeRef] atys = []; for (ty::arg arg in inputs) { @@ -735,7 +736,7 @@ fn type_of_explicit_args(&@crate_ctxt cx, &ast::span sp, // - trans_args fn type_of_fn_full(&@crate_ctxt cx, - &ast::span sp, + &span sp, ast::proto proto, &option::t[TypeRef] obj_self, &vec[ty::arg] inputs, @@ -792,7 +793,7 @@ fn type_of_fn_full(&@crate_ctxt cx, } fn type_of_fn(&@crate_ctxt cx, - &ast::span sp, + &span sp, ast::proto proto, &vec[ty::arg] inputs, &ty::t output, @@ -801,7 +802,7 @@ fn type_of_fn(&@crate_ctxt cx, ty_param_count); } -fn type_of_native_fn(&@crate_ctxt cx, &ast::span sp, ast::native_abi abi, +fn type_of_native_fn(&@crate_ctxt cx, &span sp, ast::native_abi abi, &vec[ty::arg] inputs, &ty::t output, uint ty_param_count) -> TypeRef { @@ -819,7 +820,7 @@ fn type_of_native_fn(&@crate_ctxt cx, &ast::span sp, ast::native_abi abi, ret T_fn(atys, type_of_inner(cx, sp, output)); } -fn type_of_inner(&@crate_ctxt cx, &ast::span sp, &ty::t t) -> TypeRef { +fn type_of_inner(&@crate_ctxt cx, &span sp, &ty::t t) -> TypeRef { // Check the cache. if (cx.lltypes.contains_key(t)) { ret cx.lltypes.get(t); @@ -939,7 +940,7 @@ fn type_of_inner(&@crate_ctxt cx, &ast::span sp, &ty::t t) -> TypeRef { ret llty; } -fn type_of_arg(@local_ctxt cx, &ast::span sp, &ty::arg arg) -> TypeRef { +fn type_of_arg(@local_ctxt cx, &span sp, &ty::arg arg) -> TypeRef { alt (ty::struct(cx.ccx.tcx, arg.ty)) { case (ty::ty_param(_)) { if (arg.mode == ty::mo_alias) { @@ -960,7 +961,7 @@ fn type_of_arg(@local_ctxt cx, &ast::span sp, &ty::arg arg) -> TypeRef { ret typ; } -fn type_of_ty_param_count_and_ty(@local_ctxt lcx, &ast::span sp, +fn type_of_ty_param_count_and_ty(@local_ctxt lcx, &span sp, &ty::ty_param_count_and_ty tpt) -> TypeRef { alt (ty::struct(lcx.ccx.tcx, tpt._1)) { case (ty::ty_fn(?proto, ?inputs, ?output, _)) { @@ -1284,7 +1285,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. -fn static_size_of_tag(&@crate_ctxt cx, &ast::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)) { log_err "dynamically sized type passed to static_size_of_tag()"; fail; @@ -1841,7 +1842,7 @@ fn set_glue_inlining(&@local_ctxt cx, ValueRef f, &ty::t t) { // Generates the declaration for (but doesn't emit) a type descriptor. -fn declare_tydesc(&@local_ctxt cx, &ast::span sp, &ty::t t, +fn declare_tydesc(&@local_ctxt cx, &span sp, &ty::t t, vec[uint] ty_params) -> @tydesc_info { log "+++ declare_tydesc " + ty::ty_to_str(cx.ccx.tcx, t); auto ccx = cx.ccx; @@ -1905,7 +1906,7 @@ fn declare_generic_glue(&@local_ctxt cx, ret llfn; } -fn make_generic_glue(&@local_ctxt cx, &ast::span sp, +fn make_generic_glue(&@local_ctxt cx, &span sp, &ty::t t, ValueRef llfn, &make_generic_glue_helper_fn helper, @@ -3356,7 +3357,7 @@ fn node_ann_type(&@crate_ctxt cx, &ast::ann a) -> ty::t { ret ty::ann_to_monotype(cx.tcx, a); } -fn node_type(&@crate_ctxt cx, &ast::span sp, &ast::ann a) -> TypeRef { +fn node_type(&@crate_ctxt cx, &span sp, &ast::ann a) -> TypeRef { ret type_of(cx, sp, node_ann_type(cx, a)); } @@ -4539,7 +4540,7 @@ fn trans_path(&@block_ctxt cx, &ast::path p, &ast::ann ann) -> lval_result { } } -fn trans_field(&@block_ctxt cx, &ast::span sp, ValueRef v, &ty::t t0, +fn trans_field(&@block_ctxt cx, &span sp, ValueRef v, &ty::t t0, &ast::ident field, &ast::ann ann) -> lval_result { auto r = autoderef(cx, v, t0); @@ -4580,7 +4581,7 @@ fn trans_field(&@block_ctxt cx, &ast::span sp, ValueRef v, &ty::t t0, fail; } -fn trans_index(&@block_ctxt cx, &ast::span sp, &@ast::expr base, +fn trans_index(&@block_ctxt cx, &span sp, &@ast::expr base, &@ast::expr idx, &ast::ann ann) -> lval_result { auto lv = trans_expr(cx, base); @@ -4727,7 +4728,7 @@ fn trans_cast(&@block_ctxt cx, &@ast::expr e, &ast::ann ann) -> result { } fn trans_bind_thunk(&@local_ctxt cx, - &ast::span sp, + &span sp, &ty::t incoming_fty, &ty::t outgoing_fty, &vec[option::t[@ast::expr]] args, @@ -6318,7 +6319,7 @@ fn recv_val(&@block_ctxt cx, ValueRef lhs, &@ast::expr rhs, wrapped inner object. */ -fn trans_anon_obj(&@block_ctxt cx, &ast::span sp, +fn trans_anon_obj(&@block_ctxt cx, &span sp, &ast::anon_obj anon_obj, &vec[ast::ty_param] ty_params, &ast::obj_def_ids oid, @@ -6669,7 +6670,7 @@ fn mk_standard_basic_blocks(ValueRef llfn) -> // - new_fn_ctxt // - trans_args -fn new_fn_ctxt(@local_ctxt cx, &ast::span sp, +fn new_fn_ctxt(@local_ctxt cx, &span sp, ValueRef llfndecl) -> @fn_ctxt { let ValueRef llretptr = llvm::LLVMGetParam(llfndecl, 0u); @@ -6919,7 +6920,7 @@ fn finish_fn(&@fn_ctxt fcx, BasicBlockRef lltop) { // trans_fn: creates an LLVM function corresponding to a source language // function. -fn trans_fn(@local_ctxt cx, &ast::span sp, &ast::_fn f, ast::def_id fid, +fn trans_fn(@local_ctxt cx, &span sp, &ast::_fn f, ast::def_id fid, option::t[tup(TypeRef, ty::t)] ty_self, &vec[ast::ty_param] ty_params, &ast::ann ann) { auto llfndecl = cx.ccx.item_ids.get(fid); @@ -7043,7 +7044,7 @@ fn trans_dtor(@local_ctxt cx, // trans_obj: creates an LLVM function that is the object constructor for the // object being translated. -fn trans_obj(@local_ctxt cx, &ast::span sp, &ast::_obj ob, ast::def_id oid, +fn trans_obj(@local_ctxt cx, &span sp, &ast::_obj ob, ast::def_id oid, &vec[ast::ty_param] ty_params, &ast::ann ann) { // To make a function, we have to create a function context and, inside // that, a number of block contexts for which code is generated. @@ -7368,7 +7369,7 @@ fn get_pair_fn_ty(TypeRef llpairty) -> TypeRef { ret llvm::LLVMGetElementType(pair_tys.(0)); } -fn decl_fn_and_pair(&@crate_ctxt ccx, &ast::span sp, +fn decl_fn_and_pair(&@crate_ctxt ccx, &span sp, vec[str] path, str flav, vec[ast::ty_param] ty_params, @@ -7434,7 +7435,7 @@ fn native_fn_ty_param_count(&@crate_ctxt cx, &ast::def_id id) -> uint { ret count; } -fn native_fn_wrapper_type(&@crate_ctxt cx, &ast::span sp, uint ty_param_count, +fn native_fn_wrapper_type(&@crate_ctxt cx, &span sp, uint ty_param_count, ty::t x) -> TypeRef { alt (ty::struct(cx.tcx, x)) { case (ty::ty_native_fn(?abi, ?args, ?out)) { @@ -7445,7 +7446,7 @@ fn native_fn_wrapper_type(&@crate_ctxt cx, &ast::span sp, uint ty_param_count, } fn decl_native_fn_and_pair(&@crate_ctxt ccx, - &ast::span sp, + &span sp, vec[str] path, str name, &ast::ann ann, diff --git a/src/comp/middle/tstate/collect_locals.rs b/src/comp/middle/tstate/collect_locals.rs index 0a8636a6044..4c0308d1821 100644 --- a/src/comp/middle/tstate/collect_locals.rs +++ b/src/comp/middle/tstate/collect_locals.rs @@ -23,7 +23,6 @@ import front::ast::ident; import middle::walk::walk_crate; import middle::walk::walk_fn; import middle::walk::ast_visitor; -import front::ast::span; import aux::fn_info; import aux::var_info; @@ -31,6 +30,7 @@ import aux::crate_ctxt; import util::common::new_def_hash; import util::common::uistr; +import util::common::span; type identifier = rec(ident name, def_id id, span sp); diff --git a/src/comp/middle/tstate/pre_post_conditions.rs b/src/comp/middle/tstate/pre_post_conditions.rs index 5a0485e1c79..37598763058 100644 --- a/src/comp/middle/tstate/pre_post_conditions.rs +++ b/src/comp/middle/tstate/pre_post_conditions.rs @@ -48,98 +48,7 @@ import bitvectors::declare_var; import bitvectors::bit_num; import bitvectors::gen; -import front::ast::_mod; -import front::ast; -import front::ast::method; -import front::ast::ann; -import front::ast::ty; -import front::ast::mutability; -import front::ast::item_const; -import front::ast::item_mod; -import front::ast::item_ty; -import front::ast::item_tag; -import front::ast::item_native_mod; -import front::ast::obj_field; -import front::ast::stmt; -import front::ast::stmt_; -import front::ast::ident; -import front::ast::def_id; -import front::ast::expr; -import front::ast::path; -import front::ast::crate_directive; -import front::ast::fn_decl; -import front::ast::native_mod; -import front::ast::variant; -import front::ast::ty_param; -import front::ast::proto; -import front::ast::pat; -import front::ast::binop; -import front::ast::unop; -import front::ast::def; -import front::ast::lit; -import front::ast::init_op; -import front::ast::controlflow; -import front::ast::noreturn; -import front::ast::return; -import front::ast::_fn; -import front::ast::_obj; -import front::ast::crate; -import front::ast::item_fn; -import front::ast::item_obj; -import front::ast::def_local; -import front::ast::def_fn; -import front::ast::item; -import front::ast::elt; -import front::ast::field; -import front::ast::decl; -import front::ast::decl_local; -import front::ast::decl_item; -import front::ast::initializer; -import front::ast::local; -import front::ast::arm; -import front::ast::expr_call; -import front::ast::expr_vec; -import front::ast::expr_tup; -import front::ast::expr_path; -import front::ast::expr_field; -import front::ast::expr_index; -import front::ast::expr_log; -import front::ast::expr_block; -import front::ast::expr_rec; -import front::ast::expr_if; -import front::ast::expr_binary; -import front::ast::expr_unary; -import front::ast::expr_move; -import front::ast::expr_assign; -import front::ast::expr_assign_op; -import front::ast::expr_while; -import front::ast::expr_do_while; -import front::ast::expr_alt; -import front::ast::expr_lit; -import front::ast::expr_ret; -import front::ast::expr_self_method; -import front::ast::expr_bind; -import front::ast::expr_spawn; -import front::ast::expr_ext; -import front::ast::expr_fail; -import front::ast::expr_break; -import front::ast::expr_cont; -import front::ast::expr_send; -import front::ast::expr_recv; -import front::ast::expr_put; -import front::ast::expr_port; -import front::ast::expr_chan; -import front::ast::expr_be; -import front::ast::expr_check; -import front::ast::expr_assert; -import front::ast::expr_cast; -import front::ast::expr_for; -import front::ast::expr_for_each; -import front::ast::expr_anon_obj; -import front::ast::stmt_decl; -import front::ast::stmt_expr; -import front::ast::block; -import front::ast::block_; +import front::ast::*; import middle::ty::expr_ann; @@ -155,8 +64,7 @@ import util::common::log_stmt; import util::common::log_expr_err; import util::common::log_block_err; import util::common::log_block; - -import front::ast::span; +import util::common::span; fn find_pre_post_mod(&_mod m) -> _mod { log("implement find_pre_post_mod!"); diff --git a/src/comp/middle/tstate/states.rs b/src/comp/middle/tstate/states.rs index 16739fdcbad..206ac9c68df 100644 --- a/src/comp/middle/tstate/states.rs +++ b/src/comp/middle/tstate/states.rs @@ -59,97 +59,7 @@ import bitvectors::gen_poststate; import bitvectors::kill_poststate; import front::ast; -import front::ast::_fn; -import front::ast::method; -import front::ast::ty; -import front::ast::mutability; -import front::ast::item; -import front::ast::obj_field; -import front::ast::stmt; -import front::ast::stmt_; -import front::ast::def_id; -import front::ast::ann; -import front::ast::expr; -import front::ast::path; -import front::ast::crate_directive; -import front::ast::fn_decl; -import front::ast::_obj; -import front::ast::native_mod; -import front::ast::variant; -import front::ast::ty_param; -import front::ast::proto; -import front::ast::pat; -import front::ast::binop; -import front::ast::unop; -import front::ast::def; -import front::ast::lit; -import front::ast::init_op; -import front::ast::controlflow; -import front::ast::return; -import front::ast::noreturn; -import front::ast::_mod; -import front::ast::crate; -import front::ast::item_fn; -import front::ast::item_mod; -import front::ast::item_ty; -import front::ast::item_tag; -import front::ast::item_native_mod; -import front::ast::item_obj; -import front::ast::item_const; -import front::ast::def_local; -import front::ast::def_fn; -import front::ast::ident; -import front::ast::elt; -import front::ast::field; -import front::ast::decl; -import front::ast::decl_local; -import front::ast::decl_item; -import front::ast::initializer; -import front::ast::local; -import front::ast::arm; -import front::ast::expr_call; -import front::ast::expr_vec; -import front::ast::expr_tup; -import front::ast::expr_path; -import front::ast::expr_field; -import front::ast::expr_index; -import front::ast::expr_log; -import front::ast::expr_block; -import front::ast::expr_rec; -import front::ast::expr_if; -import front::ast::expr_binary; -import front::ast::expr_unary; -import front::ast::expr_move; -import front::ast::expr_assign; -import front::ast::expr_assign_op; -import front::ast::expr_while; -import front::ast::expr_do_while; -import front::ast::expr_alt; -import front::ast::expr_lit; -import front::ast::expr_ret; -import front::ast::expr_self_method; -import front::ast::expr_bind; -import front::ast::expr_spawn; -import front::ast::expr_ext; -import front::ast::expr_fail; -import front::ast::expr_break; -import front::ast::expr_cont; -import front::ast::expr_send; -import front::ast::expr_recv; -import front::ast::expr_put; -import front::ast::expr_port; -import front::ast::expr_chan; -import front::ast::expr_be; -import front::ast::expr_check; -import front::ast::expr_assert; -import front::ast::expr_cast; -import front::ast::expr_for; -import front::ast::expr_for_each; -import front::ast::expr_anon_obj; -import front::ast::stmt_decl; -import front::ast::stmt_expr; -import front::ast::block; -import front::ast::block_; +import front::ast::*; import middle::ty::expr_ann; import middle::ty::expr_ty; diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index a705d84df52..6b69dba49ae 100644 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@ -115,7 +115,7 @@ fn substitute_ty_params(&@crate_ctxt ccx, // Returns the type parameter count and the type for the given definition. -fn ty_param_count_and_ty_for_def(&@fn_ctxt fcx, &ast::span sp, &ast::def defn) +fn ty_param_count_and_ty_for_def(&@fn_ctxt fcx, &span sp, &ast::def defn) -> ty_param_count_and_ty { alt (defn) { case (ast::def_arg(?id)) { diff --git a/src/comp/middle/walk.rs b/src/comp/middle/walk.rs index f0cb9bb5b44..7eea2fe5c8f 100644 --- a/src/comp/middle/walk.rs +++ b/src/comp/middle/walk.rs @@ -4,7 +4,7 @@ import std::option; import std::option::some; import std::option::none; -import front::ast::span; +import util::common::span; // FIXME: Should visit patterns as well. type ast_visitor = diff --git a/src/comp/util/common.rs b/src/comp/util/common.rs index a8e1046cc91..33b89eff26c 100644 --- a/src/comp/util/common.rs +++ b/src/comp/util/common.rs @@ -220,7 +220,7 @@ fn has_nonlocal_exits(&ast::block b) -> bool { ret *has_exits; } -fn local_rhs_span(&@ast::local l, &ast::span def) -> ast::span { +fn local_rhs_span(&@ast::local l, &span def) -> span { alt (l.init) { case (some(?i)) { ret i.expr.span; } case (_) { ret def; } diff --git a/src/lib/str.rs b/src/lib/str.rs index d1e6448e549..388ed3d5825 100644 --- a/src/lib/str.rs +++ b/src/lib/str.rs @@ -2,6 +2,51 @@ import rustrt::sbuf; import vec::rustrt::vbuf; +export sbuf; +export rustrt; +export eq; +export lteq; +export hash; +export is_utf8; +export is_ascii; +export alloc; +export byte_len; +export buf; +export bytes; +export from_bytes; +export unsafe_from_bytes; +export unsafe_from_byte; +export str_from_cstr; +export str_from_buf; +export push_utf8_bytes; +export from_char; +export from_chars; +export utf8_char_width; +export char_range_at; +export char_at; +export char_len; +export to_chars; +export push_char; +export pop_char; +export shift_char; +export unshift_char; +export refcount; +export index; +export rindex; +export find; +export starts_with; +export ends_with; +export substr; +export slice; +export shift_byte; +export pop_byte; +export push_byte; +export unshift_byte; +export split; +export concat; +export connect; +export to_upper; + native "rust" mod rustrt { type sbuf; fn str_buf(str s) -> sbuf; diff --git a/src/test/compile-fail/import-glob-circular.rs b/src/test/compile-fail/import-glob-circular.rs index 9e9b5e3c9db..3fbe2408a52 100644 --- a/src/test/compile-fail/import-glob-circular.rs +++ b/src/test/compile-fail/import-glob-circular.rs @@ -2,6 +2,9 @@ // error-pattern: unresolved name mod circ1 { import circ1::*; + export f1; + export f2; + export common; fn f1() { log "f1"; } @@ -12,6 +15,9 @@ mod circ1 { mod circ2 { import circ2::*; + export f1; + export f2; + export common; fn f2() { log "f2"; } diff --git a/src/test/compile-fail/import-loop-2.rs b/src/test/compile-fail/import-loop-2.rs index 2413ae1f90a..7667c39c894 100644 --- a/src/test/compile-fail/import-loop-2.rs +++ b/src/test/compile-fail/import-loop-2.rs @@ -2,10 +2,12 @@ mod a { import b::x; + export x; } mod b { import a::x; + export x; fn main() { auto y = x; diff --git a/src/test/compile-fail/import-loop.rs b/src/test/compile-fail/import-loop.rs index 7867c00f00e..c5d13ceeecd 100644 --- a/src/test/compile-fail/import-loop.rs +++ b/src/test/compile-fail/import-loop.rs @@ -4,6 +4,7 @@ import y::x; mod y { import x; + export x; } fn main() { diff --git a/src/test/compile-fail/import5.rs b/src/test/compile-fail/import5.rs new file mode 100644 index 00000000000..3e926fd8fff --- /dev/null +++ b/src/test/compile-fail/import5.rs @@ -0,0 +1,15 @@ +// error-pattern:unresolved import: foo + +mod m1 { + fn foo() { log "foo"; } +} + +mod m2 { + import m1::foo; +} + +mod m3 { + import m2::foo; +} + +fn main () {} \ No newline at end of file diff --git a/src/test/run-pass/import-glob-1.rs b/src/test/run-pass/import-glob-1.rs index e02be57dcab..fb9648fe9ac 100644 --- a/src/test/run-pass/import-glob-1.rs +++ b/src/test/run-pass/import-glob-1.rs @@ -3,15 +3,18 @@ import a1::b1::word_traveler; mod a1 { // mod b1 { // import a2::b1::*; // <-\ + export word_traveler; // | } // | mod b2 { // | import a2::b2::*; // <-\ -\ | + export word_traveler; // | | | } // | | | } // | | | // | | | mod a2 { // | | | native mod b1 { // | | | import a1::b2::*; // | <-/ -/ + export word_traveler; // | } // | mod b2 { // | fn word_traveler() { // | diff --git a/src/test/run-pass/import-glob-circular.rs b/src/test/run-pass/import-glob-circular.rs index 921d449af13..333cde25dd3 100644 --- a/src/test/run-pass/import-glob-circular.rs +++ b/src/test/run-pass/import-glob-circular.rs @@ -3,6 +3,9 @@ import test2::*; mod circ1 { import circ1::*; + export f1; + export f2; + export common; fn f1() -> uint { ret 1u } @@ -13,6 +16,9 @@ mod circ1 { mod circ2 { import circ2::*; + export f1; + export f2; + export common; fn f2() -> uint { ret 2u; } diff --git a/src/test/run-pass/import5.rs b/src/test/run-pass/import5.rs index 077cc14cd97..b629520a93b 100644 --- a/src/test/run-pass/import5.rs +++ b/src/test/run-pass/import5.rs @@ -1,6 +1,7 @@ import foo::bar; mod foo { import zed::bar; + export bar; mod zed { fn bar() { log "foo"; diff --git a/src/test/run-pass/import6.rs b/src/test/run-pass/import6.rs index c8268d99c25..d4b82f41ba5 100644 --- a/src/test/run-pass/import6.rs +++ b/src/test/run-pass/import6.rs @@ -9,6 +9,7 @@ mod foo { } mod bar { import zed::baz; + export baz; } fn main(vec[str] args) { baz(); diff --git a/src/test/run-pass/import7.rs b/src/test/run-pass/import7.rs index 6b11762efde..3970ff58d2b 100644 --- a/src/test/run-pass/import7.rs +++ b/src/test/run-pass/import7.rs @@ -9,6 +9,7 @@ mod foo { } mod bar { import zed::baz; + export baz; mod foo { mod zed { }