]> git.lizzy.rs Git - rust.git/commitdiff
Fix xcrate enum namespacing
authorSteven Fackler <sfackler@gmail.com>
Tue, 25 Nov 2014 18:00:46 +0000 (10:00 -0800)
committerSteven Fackler <sfackler@gmail.com>
Tue, 25 Nov 2014 19:02:47 +0000 (11:02 -0800)
Closes #19293

13 files changed:
src/librustc/metadata/encoder.rs
src/librustc_llvm/lib.rs
src/test/auxiliary/issue-13872-2.rs
src/test/auxiliary/issue_19293.rs [new file with mode: 0644]
src/test/compile-fail/enums-are-namespaced-xc.rs [new file with mode: 0644]
src/test/compile-fail/unreachable-variant.rs
src/test/compile-fail/xc-private-method2.rs
src/test/run-pass/issue-19293.rs [new file with mode: 0644]
src/test/run-pass/issue-2316-c.rs
src/test/run-pass/issue-8259.rs
src/test/run-pass/struct_variant_xc.rs
src/test/run-pass/struct_variant_xc_match.rs
src/test/run-pass/xcrate-unit-struct.rs

index 7e4d2621f1837ab4dee232b4640e4a882ac20640..7f4e811f514a1a1406d695ad3ca9ce01893f2aed 100644 (file)
@@ -500,20 +500,10 @@ fn encode_reexported_static_methods(ecx: &EncodeContext,
 /// Iterates through "auxiliary node IDs", which are node IDs that describe
 /// top-level items that are sub-items of the given item. Specifically:
 ///
-/// * For enums, iterates through the node IDs of the variants.
-///
 /// * For newtype structs, iterates through the node ID of the constructor.
 fn each_auxiliary_node_id(item: &ast::Item, callback: |NodeId| -> bool) -> bool {
     let mut continue_ = true;
     match item.node {
-        ast::ItemEnum(ref enum_def, _) => {
-            for variant in enum_def.variants.iter() {
-                continue_ = callback(variant.node.id);
-                if !continue_ {
-                    break
-                }
-            }
-        }
         ast::ItemStruct(ref struct_def, _) => {
             // If this is a newtype struct, return the constructor.
             match struct_def.ctor_id {
index d67d0fa59ae28899c5cec1faa385de71537982be..8d14912a6d4da2213c01b58280c66b313002493b 100644 (file)
@@ -45,6 +45,7 @@
 pub use self::CallConv::*;
 pub use self::Visibility::*;
 pub use self::DiagnosticSeverity::*;
+pub use self::Linkage::*;
 
 use std::c_str::ToCStr;
 use std::cell::RefCell;
index e2744b7910f983685f10f6ea3cd05121602b2f08..8294d2b4594cfb00ebce192ca8d5513de99d01c1 100644 (file)
@@ -10,4 +10,4 @@
 
 extern crate "issue-13872-1" as foo;
 
-pub use foo::B;
+pub use foo::A::B;
diff --git a/src/test/auxiliary/issue_19293.rs b/src/test/auxiliary/issue_19293.rs
new file mode 100644 (file)
index 0000000..40c8eb9
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+pub struct Foo (pub int);
+pub enum MyEnum {
+    Foo(Foo),
+}
diff --git a/src/test/compile-fail/enums-are-namespaced-xc.rs b/src/test/compile-fail/enums-are-namespaced-xc.rs
new file mode 100644 (file)
index 0000000..5315e6c
--- /dev/null
@@ -0,0 +1,18 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// aux-build:namespaced_enums.rs
+extern crate namespaced_enums;
+
+fn main() {
+    let _ = namespaced_enums::A; //~ ERROR unresolved name
+    let _ = namespaced_enums::B(10); //~ ERROR unresolved name
+    let _ = namespaced_enums::C { a: 10 }; //~ ERROR does not name a structure
+}
index a6f17efe6b5e94683031d4087ee76b18ba78c7b2..ef991d8533737d646f9606ba53e4b89264e1db51 100644 (file)
@@ -13,5 +13,5 @@
 extern crate "unreachable-variant" as other;
 
 fn main() {
-    let _x = other::super_sekrit::baz; //~ ERROR is private
+    let _x = other::super_sekrit::sooper_sekrit::baz; //~ ERROR is private
 }
index 48b07a39eb8984cb49cc710aaa2bc4b475ebbae2..26e055d7cbb9d93a56b80459c1a7f9ae4e00a51e 100644 (file)
@@ -16,6 +16,6 @@ fn main() {
     let _ = xc_private_method_lib::Struct{ x: 10 }.meth_struct();
     //~^ ERROR method `meth_struct` is private
 
-    let _ = xc_private_method_lib::Variant1(20).meth_enum();
+    let _ = xc_private_method_lib::Enum::Variant1(20).meth_enum();
     //~^ ERROR method `meth_enum` is private
 }
diff --git a/src/test/run-pass/issue-19293.rs b/src/test/run-pass/issue-19293.rs
new file mode 100644 (file)
index 0000000..4a446a7
--- /dev/null
@@ -0,0 +1,17 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// aux-build:issue_19293.rs
+extern crate issue_19293;
+use issue_19293::{Foo, MyEnum};
+
+fn main() {
+    MyEnum::Foo(Foo(5));
+}
index a27f0b8d6598cbd2a84c54aff3b49a8a2ca62aea..a6fac423bb6772f1ea86a1de55e6447df7453db1 100644 (file)
@@ -15,5 +15,5 @@
 use issue_2316_b::cloth;
 
 pub fn main() {
-  let _c: cloth::fabric = cloth::calico;
+  let _c: cloth::fabric = cloth::fabric::calico;
 }
index 4805b7713ee9978d9ced9712f2eee4416f89fc2f..fb893873bc4d337bdb962d0f2eadf04d4bd66044 100644 (file)
@@ -11,6 +11,6 @@
 // aux-build:issue-8259.rs
 
 extern crate "issue-8259" as other;
-static a: other::Foo<'static> = other::A;
+static a: other::Foo<'static> = other::Foo::A;
 
 pub fn main() {}
index 11521e86117b489a231cca6e3ffb86781ef24489..923a1427869f53bd1f73e251d33049a519be4860 100644 (file)
@@ -11,7 +11,7 @@
 // aux-build:struct_variant_xc_aux.rs
 extern crate struct_variant_xc_aux;
 
-use struct_variant_xc_aux::StructVariant;
+use struct_variant_xc_aux::Enum::StructVariant;
 
 pub fn main() {
     let _ = StructVariant { arg: 1 };
index e7bc61c1fb99c74b259848673fd9492d25d7d07f..41dcb7ddbc86bc084853500799c585aadb1358ea 100644 (file)
@@ -11,7 +11,7 @@
 // aux-build:struct_variant_xc_aux.rs
 extern crate struct_variant_xc_aux;
 
-use struct_variant_xc_aux::{StructVariant, Variant};
+use struct_variant_xc_aux::Enum::{StructVariant, Variant};
 
 pub fn main() {
     let arg = match (StructVariant { arg: 42 }) {
index 7eb73968db5ef9e96e8302b3b4208433789d981d..30b5f47b2ae2e30e166affded3ab62a561fb4c61 100644 (file)
 extern crate xcrate_unit_struct;
 
 const s1: xcrate_unit_struct::Struct = xcrate_unit_struct::Struct;
-static s2: xcrate_unit_struct::Unit = xcrate_unit_struct::UnitVariant;
+static s2: xcrate_unit_struct::Unit = xcrate_unit_struct::Unit::UnitVariant;
 static s3: xcrate_unit_struct::Unit =
-                xcrate_unit_struct::Argument(xcrate_unit_struct::Struct);
-static s4: xcrate_unit_struct::Unit = xcrate_unit_struct::Argument(s1);
+                xcrate_unit_struct::Unit::Argument(xcrate_unit_struct::Struct);
+static s4: xcrate_unit_struct::Unit = xcrate_unit_struct::Unit::Argument(s1);
 static s5: xcrate_unit_struct::TupleStruct = xcrate_unit_struct::TupleStruct(20, "foo");
 
 fn f1(_: xcrate_unit_struct::Struct) {}
@@ -24,8 +24,8 @@ fn f3(_: xcrate_unit_struct::TupleStruct) {}
 
 pub fn main() {
     f1(xcrate_unit_struct::Struct);
-    f2(xcrate_unit_struct::UnitVariant);
-    f2(xcrate_unit_struct::Argument(xcrate_unit_struct::Struct));
+    f2(xcrate_unit_struct::Unit::UnitVariant);
+    f2(xcrate_unit_struct::Unit::Argument(xcrate_unit_struct::Struct));
     f3(xcrate_unit_struct::TupleStruct(10, "bar"));
 
     f1(s1);