Importing from types was disallowed in #6462. Flag was set for paths whether it is a module or a type. Type flag was set when impl was seen. The problem is, for cross-crate situations, when reexport is involved, it is possible that impl is seen too late because metadata is loaded lazily.
Fix #15664.
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) => {
child_name_bindings.define_module(parent_link,
Some(def_id),
- NormalModuleKind,
+ kind,
true,
is_public,
DUMMY_SP);
// 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();
}
impl Foo {
pub fn new() {}
}
+
+mod sub {
+ pub struct Bar;
+
+ impl Bar {
+ pub fn 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
+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() {}