about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-08-12 22:42:12 +0000
committerbors <bors@rust-lang.org>2015-08-12 22:42:12 +0000
commit82169afba773828ddb8a7e3770ba62d90c711079 (patch)
tree25a6f73c06816e635a6d05de1ee7940c96966ce1
parent6a5c4e77a841754656b9942624edf916defc005c (diff)
parent1dd0c058cf1a31e2c25d5bedeaa2bab6eaa73dbc (diff)
Auto merge of #27698 - arielb1:foreign-type-import, r=alexcrichton
Fixes #22968
Probably fixes #27602 (the issue needs a reproduction)

r? @alexcrichton 
-rw-r--r--src/librustc_resolve/build_reduced_graph.rs5
-rw-r--r--src/test/auxiliary/use_from_trait_xc.rs6
-rw-r--r--src/test/compile-fail/use-from-trait-xc.rs9
-rw-r--r--src/test/compile-fail/use-from-trait.rs13
4 files changed, 33 insertions, 0 deletions
diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs
index c7e78390179..aa2eaa866ff 100644
--- a/src/librustc_resolve/build_reduced_graph.rs
+++ b/src/librustc_resolve/build_reduced_graph.rs
@@ -785,6 +785,11 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
               debug!("(building reduced graph for external \
                       crate) building type {}", final_ident);
 
+              let modifiers = match new_parent.kind.get() {
+                  NormalModuleKind => modifiers,
+                  _ => modifiers & !DefModifiers::IMPORTABLE
+              };
+
               child_name_bindings.define_type(def, DUMMY_SP, modifiers);
           }
           DefStruct(def_id) => {
diff --git a/src/test/auxiliary/use_from_trait_xc.rs b/src/test/auxiliary/use_from_trait_xc.rs
index 56fb40bc0a4..7024c9dad7c 100644
--- a/src/test/auxiliary/use_from_trait_xc.rs
+++ b/src/test/auxiliary/use_from_trait_xc.rs
@@ -8,16 +8,22 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#![feature(associated_consts)]
+
 pub use self::sub::{Bar, Baz};
 
 pub trait Trait {
     fn foo(&self);
+    type Assoc;
+    const CONST: u32;
 }
 
 struct Foo;
 
 impl Foo {
     pub fn new() {}
+
+    pub const C: u32 = 0;
 }
 
 mod sub {
diff --git a/src/test/compile-fail/use-from-trait-xc.rs b/src/test/compile-fail/use-from-trait-xc.rs
index ff282413580..4f7e38bd26b 100644
--- a/src/test/compile-fail/use-from-trait-xc.rs
+++ b/src/test/compile-fail/use-from-trait-xc.rs
@@ -15,9 +15,18 @@ extern crate use_from_trait_xc;
 use use_from_trait_xc::Trait::foo;
 //~^ ERROR `foo` is not directly importable
 
+use use_from_trait_xc::Trait::Assoc;
+//~^ ERROR `Assoc` is not directly importable
+
+use use_from_trait_xc::Trait::CONST;
+//~^ ERROR `CONST` is not directly importable
+
 use use_from_trait_xc::Foo::new;
 //~^ ERROR `new` is not directly importable
 
+use use_from_trait_xc::Foo::C;
+//~^ ERROR unresolved import `use_from_trait_xc::Foo::C`
+
 use use_from_trait_xc::Bar::new as bnew;
 //~^ ERROR `bnew` is not directly importable
 
diff --git a/src/test/compile-fail/use-from-trait.rs b/src/test/compile-fail/use-from-trait.rs
index 49d8622976b..28e933bc7aa 100644
--- a/src/test/compile-fail/use-from-trait.rs
+++ b/src/test/compile-fail/use-from-trait.rs
@@ -8,19 +8,32 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#![feature(associated_consts)]
+
 use Trait::foo;
 //~^ ERROR `foo` is not directly importable
+use Trait::Assoc;
+//~^ ERROR `Assoc` is not directly importable
+use Trait::C;
+//~^ ERROR `C` is not directly importable
+
 use Foo::new;
 //~^ ERROR unresolved import `Foo::new`. Not a module `Foo`
 
+use Foo::C2;
+//~^ ERROR unresolved import `Foo::C2`. Not a module `Foo`
+
 pub trait Trait {
     fn foo();
+    type Assoc;
+    const C: u32;
 }
 
 struct Foo;
 
 impl Foo {
     fn new() {}
+    const C2: u32 = 0;
 }
 
 fn main() {}