]> git.lizzy.rs Git - rust.git/commitdiff
stop cross-crate associated types from being imported
authorAriel Ben-Yehuda <arielb1@mail.tau.ac.il>
Wed, 12 Aug 2015 16:58:32 +0000 (19:58 +0300)
committerAriel Ben-Yehuda <arielb1@mail.tau.ac.il>
Wed, 12 Aug 2015 16:58:32 +0000 (19:58 +0300)
Fixes #22968
Probably fixes #27602

src/librustc_resolve/build_reduced_graph.rs
src/test/auxiliary/use_from_trait_xc.rs
src/test/compile-fail/use-from-trait-xc.rs
src/test/compile-fail/use-from-trait.rs

index c7e7839017930ba1834de0f00c60cdf5afbafede..aa2eaa866ff74f4a55e41683108768e9acf59960 100644 (file)
@@ -785,6 +785,11 @@ fn handle_external_def(&mut self,
               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) => {
index 56fb40bc0a469af3021f8e4a9346fb0a3161b197..7024c9dad7c11acb37fe157e021eaf19732eb4b5 100644 (file)
@@ -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 {
index ff2824135801a38523d0bebb7de26c0de0472cb5..4f7e38bd26b0a6e877e4e36e1a824741807e3961 100644 (file)
 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
 
index 49d8622976bb2dfd43159d1ee1ce01c9d764591b..28e933bc7aa0a2d180e874f4e25c173214acfeff 100644 (file)
@@ -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() {}