mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-01 03:03:40 +00:00
Fix bug: globbed imports were importing everything visible from the other
module, not just everything exported.
This commit is contained in:
parent
adc18bb24a
commit
b4c3b83f26
@ -940,9 +940,9 @@ fn lookup_in_local_mod(&env e, node_id node_id, &span sp, &ident id,
|
||||
}
|
||||
}
|
||||
}
|
||||
// not local or explicitly imported; try globs:
|
||||
|
||||
ret lookup_glob_in_mod(e, info, sp, id, ns, dr);
|
||||
// not local or explicitly imported; try globs:
|
||||
ret lookup_glob_in_mod(e, info, sp, id, ns, outside);
|
||||
}
|
||||
|
||||
fn lookup_glob_in_mod(&env e, @indexed_mod info, &span sp, &ident id,
|
||||
|
@ -1,5 +1,6 @@
|
||||
|
||||
import std::bitv;
|
||||
import std::str;
|
||||
import std::vec;
|
||||
import std::vec::len;
|
||||
import std::vec::grow;
|
||||
@ -12,6 +13,7 @@ import front::ast;
|
||||
import front::ast::*;
|
||||
import util::common;
|
||||
import util::common::span;
|
||||
import util::common::spanned;
|
||||
import util::common::respan;
|
||||
import util::common::log_block;
|
||||
import util::common::new_int_hash;
|
||||
|
@ -3,7 +3,7 @@ import std::vec;
|
||||
import std::vec::plus_option;
|
||||
import front::ast;
|
||||
import front::ast::*;
|
||||
import option::*;
|
||||
import std::option::*;
|
||||
import middle::walk::walk_crate;
|
||||
import middle::walk::walk_fn;
|
||||
import middle::walk::ast_visitor;
|
||||
|
@ -96,6 +96,7 @@ export mt;
|
||||
export node_type_table;
|
||||
export pat_node_id;
|
||||
export pat_ty;
|
||||
export cname;
|
||||
export path_to_str;
|
||||
export rename;
|
||||
export ret_ty_of_fn;
|
||||
@ -170,6 +171,7 @@ export type_is_tup_like;
|
||||
export type_is_str;
|
||||
export type_owns_heap_mem;
|
||||
export type_param;
|
||||
export def_to_str;
|
||||
export unify;
|
||||
export variant_info;
|
||||
export walk_ty;
|
||||
@ -273,7 +275,7 @@ tag sty {
|
||||
type constr_def = spanned[constr_general[uint]];
|
||||
|
||||
type constr_general[T] =
|
||||
rec(path path, vec[@constr_arg_general[T]] args, def_id id);
|
||||
rec(ast::path path, vec[@constr_arg_general[T]] args, def_id id);
|
||||
|
||||
|
||||
// Data structures used in type unification
|
||||
|
@ -1,13 +1,22 @@
|
||||
|
||||
import std::io;
|
||||
import std::vec;
|
||||
import std::str;
|
||||
import std::option;
|
||||
import std::option::none;
|
||||
import std::option::some;
|
||||
import middle::ty::*;
|
||||
import front::lexer;
|
||||
import front::ast;
|
||||
import pp::word;
|
||||
import pp::eof;
|
||||
import pp::zerobreak;
|
||||
import pp::hardbreak;
|
||||
import front::codemap;
|
||||
import front::codemap::codemap;
|
||||
import util::common::istr;
|
||||
import util::common::uistr;
|
||||
import util::common::ty_mach_to_str;
|
||||
|
||||
fn ty_to_str(&ctxt cx, &t typ) -> str {
|
||||
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 {
|
||||
|
||||
fn ty_to_short_str(&ctxt cx, t typ) -> str {
|
||||
auto f = def_to_str;
|
||||
auto ecx = @rec(ds=f, tcx=cx, abbrevs=metadata::ac_no_abbrevs);
|
||||
auto s = metadata::Encode::ty_str(ecx, typ);
|
||||
auto ecx = @rec(ds=f, tcx=cx, abbrevs=middle::metadata::ac_no_abbrevs);
|
||||
auto s = middle::metadata::Encode::ty_str(ecx, typ);
|
||||
if (str::byte_len(s) >= 32u) { s = str::substr(s, 0u, 32u); }
|
||||
ret s;
|
||||
}
|
||||
|
14
src/test/compile-fail/import-glob-export.rs
Normal file
14
src/test/compile-fail/import-glob-export.rs
Normal file
@ -0,0 +1,14 @@
|
||||
|
||||
// error-pattern:unresolved name
|
||||
|
||||
import m1::*;
|
||||
|
||||
mod m1 {
|
||||
export f1;
|
||||
fn f1() {}
|
||||
fn f2() {}
|
||||
}
|
||||
|
||||
fn main () {
|
||||
f2();
|
||||
}
|
@ -33,8 +33,8 @@ mod test1 {
|
||||
assert(f1() == 1u);
|
||||
//make sure that cached lookups work...
|
||||
assert(f1() == 1u);
|
||||
assert(f2() == 2u);
|
||||
assert(f2() == 2u);
|
||||
//assert(f2() == 2u); //TODO: renable when 'reexport' is implemented
|
||||
//assert(f2() == 2u);
|
||||
assert(common() == 1u);
|
||||
assert(common() == 1u);
|
||||
}
|
||||
@ -43,9 +43,9 @@ mod test1 {
|
||||
mod test2 {
|
||||
import circ2::*;
|
||||
fn test2() {
|
||||
assert(f1() == 1u);
|
||||
//make sure that cached lookups work...
|
||||
assert(f1() == 1u);
|
||||
//assert(f1() == 1u); //TODO: renable when 'reexport' is implemented
|
||||
////make sure that cached lookups work...
|
||||
//assert(f1() == 1u);
|
||||
assert(f2() == 2u);
|
||||
assert(f2() == 2u);
|
||||
assert(common() == 2u);
|
||||
|
Loading…
Reference in New Issue
Block a user