mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +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 {
|
||||
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);
|
||||
|
@ -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() {}
|
||||
}
|
||||
}
|
||||
|
@ -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() {}
|
||||
|
Loading…
Reference in New Issue
Block a user