Skip to content

Commit 9f5dddf

Browse files
committed
Now imports are not re-exported unless 'export' is explicitly used.
1 parent 8b141d5 commit 9f5dddf

21 files changed

+148
-227
lines changed

src/comp/back/upcall.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import middle::trans;
22

33
import trans::decl_cdecl_fn;
4-
import trans::type_names;
5-
import trans::ModuleRef;
6-
import trans::TypeRef;
7-
import trans::ValueRef;
84

95
import trans::T_f32;
106
import trans::T_f64;
@@ -23,6 +19,11 @@ import trans::T_taskptr;
2319
import trans::T_tydesc;
2420
import trans::T_void;
2521

22+
import lib::llvm::type_names;
23+
import lib::llvm::llvm::ModuleRef;
24+
import lib::llvm::llvm::ValueRef;
25+
import lib::llvm::llvm::TypeRef;
26+
2627
type upcalls = rec(
2728
ValueRef grow_task,
2829
ValueRef log_int,

src/comp/driver/rustc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ fn compile_input(session::session sess,
103103
}
104104

105105
auto llmod =
106-
time[llvm::ModuleRef](time_passes, "translation",
107-
bind trans::trans_crate(sess, crate,
108-
ty_cx, output));
106+
time[llvm::llvm::ModuleRef](time_passes, "translation",
107+
bind trans::trans_crate(sess, crate,
108+
ty_cx, output));
109109

110110
time[()](time_passes, "LLVM passes",
111111
bind link::write::run_passes(sess, llmod, output));

src/comp/front/ast.rs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -438,20 +438,40 @@ tag native_item_ {
438438
}
439439

440440
fn is_exported(ident i, _mod m) -> bool {
441-
auto count = 0;
441+
auto nonlocal = true;
442+
for (@ast::item it in m.items) {
443+
if (item_ident(it) == i) {
444+
nonlocal = false;
445+
}
446+
alt (it.node) {
447+
case (item_tag(_, ?variants, _, _, _)) {
448+
for (variant v in variants) {
449+
if (v.node.name == i) {
450+
nonlocal = false;
451+
}
452+
}
453+
}
454+
case (_) {}
455+
}
456+
}
457+
458+
459+
auto count = 0u;
442460
for (@ast::view_item vi in m.view_items) {
443461
alt (vi.node) {
444462
case (ast::view_item_export(?id)) {
445463
if (str::eq(i, id)) {
464+
// even if it's nonlocal (since it's explicit)
446465
ret true;
447466
}
448-
count += 1;
467+
count += 1u;
449468
}
450469
case (_) { /* fall through */ }
451470
}
452471
}
453-
// If there are no declared exports then everything is exported
454-
if (count == 0) {
472+
// If there are no declared exports then
473+
// everything not imported is exported
474+
if (count == 0u && !nonlocal) {
455475
ret true;
456476
} else {
457477
ret false;

src/comp/front/parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ fn expect(&parser p, token::token t) {
231231
}
232232
}
233233

234-
fn spanned[T](uint lo, uint hi, &T node) -> ast::spanned[T] {
234+
fn spanned[T](uint lo, uint hi, &T node) -> common::spanned[T] {
235235
ret rec(node=node, span=rec(lo=lo, hi=hi));
236236
}
237237

@@ -1008,7 +1008,7 @@ fn parse_bottom_expr(&parser p) -> @ast::expr {
10081008
* loading rust crates to process extensions.
10091009
*/
10101010

1011-
fn expand_syntax_ext(&parser p, ast::span sp,
1011+
fn expand_syntax_ext(&parser p, common::span sp,
10121012
&ast::path path, vec[@ast::expr] args,
10131013
option::t[str] body) -> ast::expr_ {
10141014

src/comp/middle/trans.rs

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import util::common::istr;
2626
import util::common::new_def_hash;
2727
import util::common::new_str_hash;
2828
import util::common::local_rhs_span;
29+
import util::common::span;
2930

3031
import lib::llvm::llvm;
3132
import lib::llvm::builder;
@@ -215,7 +216,7 @@ state type fn_ctxt = rec(
215216
hashmap[ty::t, derived_tydesc_info] derived_tydescs,
216217

217218
// The source span where this function comes from, for error reporting.
218-
ast::span sp,
219+
span sp,
219220

220221
// This function's enclosing local context.
221222
@local_ctxt lcx
@@ -273,7 +274,7 @@ state type block_ctxt = rec(
273274
mutable vec[cleanup] cleanups,
274275

275276
// The source span where this block comes from, for error reporting.
276-
ast::span sp,
277+
span sp,
277278

278279
// The function context for the function to which this block is attached.
279280
@fn_ctxt fcx
@@ -502,7 +503,7 @@ fn T_glue_fn(&type_names tn) -> TypeRef {
502503
ret t;
503504
}
504505

505-
fn T_dtor(&@crate_ctxt ccx, &ast::span sp, TypeRef llself_ty) -> TypeRef {
506+
fn T_dtor(&@crate_ctxt ccx, &span sp, TypeRef llself_ty) -> TypeRef {
506507
ret type_of_fn_full(ccx, sp, ast::proto_fn, some[TypeRef](llself_ty),
507508
vec::empty[ty::arg](), ty::mk_nil(ccx.tcx), 0u);
508509
}
@@ -693,7 +694,7 @@ fn T_opaque_chan_ptr() -> TypeRef { ret T_ptr(T_i8()); }
693694
// return value was always meaningless in that case anyhow). Beware!
694695
//
695696
// TODO: Enforce via a predicate.
696-
fn type_of(&@crate_ctxt cx, &ast::span sp, &ty::t t) -> TypeRef {
697+
fn type_of(&@crate_ctxt cx, &span sp, &ty::t t) -> TypeRef {
697698
if (ty::type_has_dynamic_size(cx.tcx, t)) {
698699
cx.sess.span_err (sp,
699700
"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 {
704705
ret type_of_inner(cx, sp, t);
705706
}
706707

707-
fn type_of_explicit_args(&@crate_ctxt cx, &ast::span sp,
708+
fn type_of_explicit_args(&@crate_ctxt cx, &span sp,
708709
&vec[ty::arg] inputs) -> vec[TypeRef] {
709710
let vec[TypeRef] atys = [];
710711
for (ty::arg arg in inputs) {
@@ -735,7 +736,7 @@ fn type_of_explicit_args(&@crate_ctxt cx, &ast::span sp,
735736
// - trans_args
736737

737738
fn type_of_fn_full(&@crate_ctxt cx,
738-
&ast::span sp,
739+
&span sp,
739740
ast::proto proto,
740741
&option::t[TypeRef] obj_self,
741742
&vec[ty::arg] inputs,
@@ -792,7 +793,7 @@ fn type_of_fn_full(&@crate_ctxt cx,
792793
}
793794

794795
fn type_of_fn(&@crate_ctxt cx,
795-
&ast::span sp,
796+
&span sp,
796797
ast::proto proto,
797798
&vec[ty::arg] inputs,
798799
&ty::t output,
@@ -801,7 +802,7 @@ fn type_of_fn(&@crate_ctxt cx,
801802
ty_param_count);
802803
}
803804

804-
fn type_of_native_fn(&@crate_ctxt cx, &ast::span sp, ast::native_abi abi,
805+
fn type_of_native_fn(&@crate_ctxt cx, &span sp, ast::native_abi abi,
805806
&vec[ty::arg] inputs,
806807
&ty::t output,
807808
uint ty_param_count) -> TypeRef {
@@ -819,7 +820,7 @@ fn type_of_native_fn(&@crate_ctxt cx, &ast::span sp, ast::native_abi abi,
819820
ret T_fn(atys, type_of_inner(cx, sp, output));
820821
}
821822

822-
fn type_of_inner(&@crate_ctxt cx, &ast::span sp, &ty::t t) -> TypeRef {
823+
fn type_of_inner(&@crate_ctxt cx, &span sp, &ty::t t) -> TypeRef {
823824
// Check the cache.
824825
if (cx.lltypes.contains_key(t)) {
825826
ret cx.lltypes.get(t);
@@ -939,7 +940,7 @@ fn type_of_inner(&@crate_ctxt cx, &ast::span sp, &ty::t t) -> TypeRef {
939940
ret llty;
940941
}
941942

942-
fn type_of_arg(@local_ctxt cx, &ast::span sp, &ty::arg arg) -> TypeRef {
943+
fn type_of_arg(@local_ctxt cx, &span sp, &ty::arg arg) -> TypeRef {
943944
alt (ty::struct(cx.ccx.tcx, arg.ty)) {
944945
case (ty::ty_param(_)) {
945946
if (arg.mode == ty::mo_alias) {
@@ -960,7 +961,7 @@ fn type_of_arg(@local_ctxt cx, &ast::span sp, &ty::arg arg) -> TypeRef {
960961
ret typ;
961962
}
962963

963-
fn type_of_ty_param_count_and_ty(@local_ctxt lcx, &ast::span sp,
964+
fn type_of_ty_param_count_and_ty(@local_ctxt lcx, &span sp,
964965
&ty::ty_param_count_and_ty tpt) -> TypeRef {
965966
alt (ty::struct(lcx.ccx.tcx, tpt._1)) {
966967
case (ty::ty_fn(?proto, ?inputs, ?output, _)) {
@@ -1284,7 +1285,7 @@ fn simplify_type(&@crate_ctxt ccx, &ty::t typ) -> ty::t {
12841285
}
12851286

12861287
// Computes the size of the data part of a non-dynamically-sized tag.
1287-
fn static_size_of_tag(&@crate_ctxt cx, &ast::span sp, &ty::t t) -> uint {
1288+
fn static_size_of_tag(&@crate_ctxt cx, &span sp, &ty::t t) -> uint {
12881289
if (ty::type_has_dynamic_size(cx.tcx, t)) {
12891290
log_err "dynamically sized type passed to static_size_of_tag()";
12901291
fail;
@@ -1841,7 +1842,7 @@ fn set_glue_inlining(&@local_ctxt cx, ValueRef f, &ty::t t) {
18411842

18421843

18431844
// Generates the declaration for (but doesn't emit) a type descriptor.
1844-
fn declare_tydesc(&@local_ctxt cx, &ast::span sp, &ty::t t,
1845+
fn declare_tydesc(&@local_ctxt cx, &span sp, &ty::t t,
18451846
vec[uint] ty_params) -> @tydesc_info {
18461847
log "+++ declare_tydesc " + ty::ty_to_str(cx.ccx.tcx, t);
18471848
auto ccx = cx.ccx;
@@ -1905,7 +1906,7 @@ fn declare_generic_glue(&@local_ctxt cx,
19051906
ret llfn;
19061907
}
19071908

1908-
fn make_generic_glue(&@local_ctxt cx, &ast::span sp,
1909+
fn make_generic_glue(&@local_ctxt cx, &span sp,
19091910
&ty::t t,
19101911
ValueRef llfn,
19111912
&make_generic_glue_helper_fn helper,
@@ -3356,7 +3357,7 @@ fn node_ann_type(&@crate_ctxt cx, &ast::ann a) -> ty::t {
33563357
ret ty::ann_to_monotype(cx.tcx, a);
33573358
}
33583359

3359-
fn node_type(&@crate_ctxt cx, &ast::span sp, &ast::ann a) -> TypeRef {
3360+
fn node_type(&@crate_ctxt cx, &span sp, &ast::ann a) -> TypeRef {
33603361
ret type_of(cx, sp, node_ann_type(cx, a));
33613362
}
33623363

@@ -4539,7 +4540,7 @@ fn trans_path(&@block_ctxt cx, &ast::path p, &ast::ann ann) -> lval_result {
45394540
}
45404541
}
45414542

4542-
fn trans_field(&@block_ctxt cx, &ast::span sp, ValueRef v, &ty::t t0,
4543+
fn trans_field(&@block_ctxt cx, &span sp, ValueRef v, &ty::t t0,
45434544
&ast::ident field, &ast::ann ann) -> lval_result {
45444545

45454546
auto r = autoderef(cx, v, t0);
@@ -4580,7 +4581,7 @@ fn trans_field(&@block_ctxt cx, &ast::span sp, ValueRef v, &ty::t t0,
45804581
fail;
45814582
}
45824583

4583-
fn trans_index(&@block_ctxt cx, &ast::span sp, &@ast::expr base,
4584+
fn trans_index(&@block_ctxt cx, &span sp, &@ast::expr base,
45844585
&@ast::expr idx, &ast::ann ann) -> lval_result {
45854586

45864587
auto lv = trans_expr(cx, base);
@@ -4727,7 +4728,7 @@ fn trans_cast(&@block_ctxt cx, &@ast::expr e, &ast::ann ann) -> result {
47274728
}
47284729

47294730
fn trans_bind_thunk(&@local_ctxt cx,
4730-
&ast::span sp,
4731+
&span sp,
47314732
&ty::t incoming_fty,
47324733
&ty::t outgoing_fty,
47334734
&vec[option::t[@ast::expr]] args,
@@ -6318,7 +6319,7 @@ fn recv_val(&@block_ctxt cx, ValueRef lhs, &@ast::expr rhs,
63186319
wrapped inner object.
63196320
63206321
*/
6321-
fn trans_anon_obj(&@block_ctxt cx, &ast::span sp,
6322+
fn trans_anon_obj(&@block_ctxt cx, &span sp,
63226323
&ast::anon_obj anon_obj,
63236324
&vec[ast::ty_param] ty_params,
63246325
&ast::obj_def_ids oid,
@@ -6669,7 +6670,7 @@ fn mk_standard_basic_blocks(ValueRef llfn) ->
66696670
// - new_fn_ctxt
66706671
// - trans_args
66716672

6672-
fn new_fn_ctxt(@local_ctxt cx, &ast::span sp,
6673+
fn new_fn_ctxt(@local_ctxt cx, &span sp,
66736674
ValueRef llfndecl) -> @fn_ctxt {
66746675

66756676
let ValueRef llretptr = llvm::LLVMGetParam(llfndecl, 0u);
@@ -6919,7 +6920,7 @@ fn finish_fn(&@fn_ctxt fcx, BasicBlockRef lltop) {
69196920

69206921
// trans_fn: creates an LLVM function corresponding to a source language
69216922
// function.
6922-
fn trans_fn(@local_ctxt cx, &ast::span sp, &ast::_fn f, ast::def_id fid,
6923+
fn trans_fn(@local_ctxt cx, &span sp, &ast::_fn f, ast::def_id fid,
69236924
option::t[tup(TypeRef, ty::t)] ty_self,
69246925
&vec[ast::ty_param] ty_params, &ast::ann ann) {
69256926
auto llfndecl = cx.ccx.item_ids.get(fid);
@@ -7043,7 +7044,7 @@ fn trans_dtor(@local_ctxt cx,
70437044

70447045
// trans_obj: creates an LLVM function that is the object constructor for the
70457046
// object being translated.
7046-
fn trans_obj(@local_ctxt cx, &ast::span sp, &ast::_obj ob, ast::def_id oid,
7047+
fn trans_obj(@local_ctxt cx, &span sp, &ast::_obj ob, ast::def_id oid,
70477048
&vec[ast::ty_param] ty_params, &ast::ann ann) {
70487049
// To make a function, we have to create a function context and, inside
70497050
// that, a number of block contexts for which code is generated.
@@ -7368,7 +7369,7 @@ fn get_pair_fn_ty(TypeRef llpairty) -> TypeRef {
73687369
ret llvm::LLVMGetElementType(pair_tys.(0));
73697370
}
73707371

7371-
fn decl_fn_and_pair(&@crate_ctxt ccx, &ast::span sp,
7372+
fn decl_fn_and_pair(&@crate_ctxt ccx, &span sp,
73727373
vec[str] path,
73737374
str flav,
73747375
vec[ast::ty_param] ty_params,
@@ -7434,7 +7435,7 @@ fn native_fn_ty_param_count(&@crate_ctxt cx, &ast::def_id id) -> uint {
74347435
ret count;
74357436
}
74367437

7437-
fn native_fn_wrapper_type(&@crate_ctxt cx, &ast::span sp, uint ty_param_count,
7438+
fn native_fn_wrapper_type(&@crate_ctxt cx, &span sp, uint ty_param_count,
74387439
ty::t x) -> TypeRef {
74397440
alt (ty::struct(cx.tcx, x)) {
74407441
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,
74457446
}
74467447

74477448
fn decl_native_fn_and_pair(&@crate_ctxt ccx,
7448-
&ast::span sp,
7449+
&span sp,
74497450
vec[str] path,
74507451
str name,
74517452
&ast::ann ann,

src/comp/middle/tstate/collect_locals.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ import front::ast::ident;
2323
import middle::walk::walk_crate;
2424
import middle::walk::walk_fn;
2525
import middle::walk::ast_visitor;
26-
import front::ast::span;
2726

2827
import aux::fn_info;
2928
import aux::var_info;
3029
import aux::crate_ctxt;
3130

3231
import util::common::new_def_hash;
3332
import util::common::uistr;
33+
import util::common::span;
3434

3535
type identifier = rec(ident name, def_id id, span sp);
3636

0 commit comments

Comments
 (0)