Skip to content

Commit b4c3b83

Browse files
committed
Fix bug: globbed imports were importing everything visible from the other
module, not just everything exported.
1 parent adc18bb commit b4c3b83

File tree

7 files changed

+38
-11
lines changed

7 files changed

+38
-11
lines changed

src/comp/middle/resolve.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -940,9 +940,9 @@ fn lookup_in_local_mod(&env e, node_id node_id, &span sp, &ident id,
940940
}
941941
}
942942
}
943-
// not local or explicitly imported; try globs:
944943

945-
ret lookup_glob_in_mod(e, info, sp, id, ns, dr);
944+
// not local or explicitly imported; try globs:
945+
ret lookup_glob_in_mod(e, info, sp, id, ns, outside);
946946
}
947947

948948
fn lookup_glob_in_mod(&env e, @indexed_mod info, &span sp, &ident id,

src/comp/middle/tstate/auxiliary.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
import std::bitv;
3+
import std::str;
34
import std::vec;
45
import std::vec::len;
56
import std::vec::grow;
@@ -12,6 +13,7 @@ import front::ast;
1213
import front::ast::*;
1314
import util::common;
1415
import util::common::span;
16+
import util::common::spanned;
1517
import util::common::respan;
1618
import util::common::log_block;
1719
import util::common::new_int_hash;

src/comp/middle/tstate/collect_locals.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import std::vec;
33
import std::vec::plus_option;
44
import front::ast;
55
import front::ast::*;
6-
import option::*;
6+
import std::option::*;
77
import middle::walk::walk_crate;
88
import middle::walk::walk_fn;
99
import middle::walk::ast_visitor;

src/comp/middle/ty.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ export mt;
9696
export node_type_table;
9797
export pat_node_id;
9898
export pat_ty;
99+
export cname;
99100
export path_to_str;
100101
export rename;
101102
export ret_ty_of_fn;
@@ -170,6 +171,7 @@ export type_is_tup_like;
170171
export type_is_str;
171172
export type_owns_heap_mem;
172173
export type_param;
174+
export def_to_str;
173175
export unify;
174176
export variant_info;
175177
export walk_ty;
@@ -273,7 +275,7 @@ tag sty {
273275
type constr_def = spanned[constr_general[uint]];
274276

275277
type constr_general[T] =
276-
rec(path path, vec[@constr_arg_general[T]] args, def_id id);
278+
rec(ast::path path, vec[@constr_arg_general[T]] args, def_id id);
277279

278280

279281
// Data structures used in type unification

src/comp/pretty/ppaux.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11

22
import std::io;
3+
import std::vec;
4+
import std::str;
5+
import std::option;
6+
import std::option::none;
7+
import std::option::some;
38
import middle::ty::*;
49
import front::lexer;
10+
import front::ast;
511
import pp::word;
612
import pp::eof;
713
import pp::zerobreak;
814
import pp::hardbreak;
915
import front::codemap;
1016
import front::codemap::codemap;
17+
import util::common::istr;
18+
import util::common::uistr;
19+
import util::common::ty_mach_to_str;
1120

1221
fn ty_to_str(&ctxt cx, &t typ) -> str {
1322
fn fn_input_to_str(&ctxt cx, &rec(middle::ty::mode mode, t ty) input) ->
@@ -123,8 +132,8 @@ fn ty_to_str(&ctxt cx, &t typ) -> str {
123132

124133
fn ty_to_short_str(&ctxt cx, t typ) -> str {
125134
auto f = def_to_str;
126-
auto ecx = @rec(ds=f, tcx=cx, abbrevs=metadata::ac_no_abbrevs);
127-
auto s = metadata::Encode::ty_str(ecx, typ);
135+
auto ecx = @rec(ds=f, tcx=cx, abbrevs=middle::metadata::ac_no_abbrevs);
136+
auto s = middle::metadata::Encode::ty_str(ecx, typ);
128137
if (str::byte_len(s) >= 32u) { s = str::substr(s, 0u, 32u); }
129138
ret s;
130139
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
// error-pattern:unresolved name
3+
4+
import m1::*;
5+
6+
mod m1 {
7+
export f1;
8+
fn f1() {}
9+
fn f2() {}
10+
}
11+
12+
fn main () {
13+
f2();
14+
}

src/test/run-pass/import-glob-circular.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ mod test1 {
3333
assert(f1() == 1u);
3434
//make sure that cached lookups work...
3535
assert(f1() == 1u);
36-
assert(f2() == 2u);
37-
assert(f2() == 2u);
36+
//assert(f2() == 2u); //TODO: renable when 'reexport' is implemented
37+
//assert(f2() == 2u);
3838
assert(common() == 1u);
3939
assert(common() == 1u);
4040
}
@@ -43,9 +43,9 @@ mod test1 {
4343
mod test2 {
4444
import circ2::*;
4545
fn test2() {
46-
assert(f1() == 1u);
47-
//make sure that cached lookups work...
48-
assert(f1() == 1u);
46+
//assert(f1() == 1u); //TODO: renable when 'reexport' is implemented
47+
////make sure that cached lookups work...
48+
//assert(f1() == 1u);
4949
assert(f2() == 2u);
5050
assert(f2() == 2u);
5151
assert(common() == 2u);

0 commit comments

Comments
 (0)