Disallow importing from types when reexport is involved

This commit is contained in:
Seo Sanghyeon 2014-07-17 13:50:54 +09:00
parent 058242141b
commit 99bd9265d9
3 changed files with 20 additions and 1 deletions

View File

@ -1599,6 +1599,12 @@ impl<'a> Resolver<'a> {
if is_exported {
self.external_exports.insert(def.def_id());
}
let kind = match def {
DefStruct(..) | DefTy(..) => ImplModuleKind,
_ => NormalModuleKind
};
match def {
DefMod(def_id) | DefForeignMod(def_id) | DefStruct(def_id) |
DefTy(def_id) => {
@ -1617,7 +1623,7 @@ impl<'a> Resolver<'a> {
child_name_bindings.define_module(parent_link,
Some(def_id),
NormalModuleKind,
kind,
true,
is_public,
DUMMY_SP);

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
pub use self::sub::Bar;
pub trait Trait {
fn foo();
}
@ -17,3 +19,11 @@ struct Foo;
impl Foo {
pub fn new() {}
}
mod sub {
pub struct Bar;
impl Bar {
pub fn new() {}
}
}

View File

@ -18,4 +18,7 @@ use use_from_trait_xc::Trait::foo;
use use_from_trait_xc::Foo::new;
//~^ ERROR unresolved import `use_from_trait_xc::Foo::new`. Cannot import from a trait or type imple
use use_from_trait_xc::Bar::new;
//~^ ERROR unresolved import `use_from_trait_xc::Bar::new`. Cannot import from a trait or type
fn main() {}