mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
Disallow importing from types when reexport is involved
This commit is contained in:
parent
058242141b
commit
99bd9265d9
@ -1599,6 +1599,12 @@ impl<'a> Resolver<'a> {
|
|||||||
if is_exported {
|
if is_exported {
|
||||||
self.external_exports.insert(def.def_id());
|
self.external_exports.insert(def.def_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let kind = match def {
|
||||||
|
DefStruct(..) | DefTy(..) => ImplModuleKind,
|
||||||
|
_ => NormalModuleKind
|
||||||
|
};
|
||||||
|
|
||||||
match def {
|
match def {
|
||||||
DefMod(def_id) | DefForeignMod(def_id) | DefStruct(def_id) |
|
DefMod(def_id) | DefForeignMod(def_id) | DefStruct(def_id) |
|
||||||
DefTy(def_id) => {
|
DefTy(def_id) => {
|
||||||
@ -1617,7 +1623,7 @@ impl<'a> Resolver<'a> {
|
|||||||
|
|
||||||
child_name_bindings.define_module(parent_link,
|
child_name_bindings.define_module(parent_link,
|
||||||
Some(def_id),
|
Some(def_id),
|
||||||
NormalModuleKind,
|
kind,
|
||||||
true,
|
true,
|
||||||
is_public,
|
is_public,
|
||||||
DUMMY_SP);
|
DUMMY_SP);
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
pub use self::sub::Bar;
|
||||||
|
|
||||||
pub trait Trait {
|
pub trait Trait {
|
||||||
fn foo();
|
fn foo();
|
||||||
}
|
}
|
||||||
@ -17,3 +19,11 @@ struct Foo;
|
|||||||
impl Foo {
|
impl Foo {
|
||||||
pub fn new() {}
|
pub fn new() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mod sub {
|
||||||
|
pub struct Bar;
|
||||||
|
|
||||||
|
impl Bar {
|
||||||
|
pub fn new() {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -18,4 +18,7 @@ use use_from_trait_xc::Trait::foo;
|
|||||||
use use_from_trait_xc::Foo::new;
|
use use_from_trait_xc::Foo::new;
|
||||||
//~^ ERROR unresolved import `use_from_trait_xc::Foo::new`. Cannot import from a trait or type imple
|
//~^ 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() {}
|
fn main() {}
|
||||||
|
Loading…
Reference in New Issue
Block a user