about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorSteven Fackler <sfackler@gmail.com>2014-10-18 23:46:08 -0700
committerSteven Fackler <sfackler@gmail.com>2014-10-31 20:43:35 -0700
commitd7ff7da65a1e8e45cbbec7cd487773ee468e12ed (patch)
treef151ea585ee27632b583cc051f4c993767a4eae8 /src/test
parent88b6e93d35c34e143ba060a617e71c8af10fa15e (diff)
downloadrust-d7ff7da65a1e8e45cbbec7cd487773ee468e12ed.tar.gz
rust-d7ff7da65a1e8e45cbbec7cd487773ee468e12ed.zip
First stage of enum namespacing changes
Diffstat (limited to 'src/test')
-rw-r--r--src/test/auxiliary/namespaced_enum_emulate_flat.rs38
-rw-r--r--src/test/auxiliary/namespaced_enums.rs22
-rw-r--r--src/test/auxiliary/use_from_trait_xc.rs8
-rw-r--r--src/test/compile-fail/enum-and-module-in-same-scope.rs2
-rw-r--r--src/test/compile-fail/namespaced-enum-glob-import-no-impls-xcrate.rs28
-rw-r--r--src/test/compile-fail/namespaced-enum-glob-import-no-impls.rs36
-rw-r--r--src/test/compile-fail/use-from-trait-xc.rs11
-rw-r--r--src/test/compile-fail/use-from-trait.rs4
-rw-r--r--src/test/run-pass/namespaced-enum-emulate-flat-xc.rs32
-rw-r--r--src/test/run-pass/namespaced-enum-emulate-flat.rs51
-rw-r--r--src/test/run-pass/namespaced-enum-glob-import-xcrate.rs34
-rw-r--r--src/test/run-pass/namespaced-enum-glob-import.rs42
-rw-r--r--src/test/run-pass/namespaced-enums-xcrate.rs25
-rw-r--r--src/test/run-pass/namespaced-enums.rs24
14 files changed, 349 insertions, 8 deletions
diff --git a/src/test/auxiliary/namespaced_enum_emulate_flat.rs b/src/test/auxiliary/namespaced_enum_emulate_flat.rs
new file mode 100644
index 00000000000..3a11f30049c
--- /dev/null
+++ b/src/test/auxiliary/namespaced_enum_emulate_flat.rs
@@ -0,0 +1,38 @@
+// 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.
+#![feature(globs, struct_variant)]
+
+pub use Foo::*;
+
+pub enum Foo {
+    A,
+    B(int),
+    C { a: int },
+}
+
+impl Foo {
+    pub fn foo() {}
+}
+
+pub mod nest {
+    pub use self::Bar::*;
+
+    pub enum Bar {
+        D,
+        E(int),
+        F { a: int },
+    }
+
+    impl Bar {
+        pub fn foo() {}
+    }
+}
+
+
diff --git a/src/test/auxiliary/namespaced_enums.rs b/src/test/auxiliary/namespaced_enums.rs
new file mode 100644
index 00000000000..a6e6f9b0191
--- /dev/null
+++ b/src/test/auxiliary/namespaced_enums.rs
@@ -0,0 +1,22 @@
+// 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.
+#![feature(struct_variant)]
+
+pub enum Foo {
+    A,
+    B(int),
+    C { a: int },
+}
+
+impl Foo {
+    pub fn foo() {}
+    pub fn bar(&self) {}
+}
+
diff --git a/src/test/auxiliary/use_from_trait_xc.rs b/src/test/auxiliary/use_from_trait_xc.rs
index 8c547c28002..22e0d3168ca 100644
--- a/src/test/auxiliary/use_from_trait_xc.rs
+++ b/src/test/auxiliary/use_from_trait_xc.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-pub use self::sub::Bar;
+pub use self::sub::{Bar, Baz};
 
 pub trait Trait {
     fn foo();
@@ -26,4 +26,10 @@ mod sub {
     impl Bar {
         pub fn new() {}
     }
+
+    pub enum Baz {}
+
+    impl Baz {
+        pub fn new() {}
+    }
 }
diff --git a/src/test/compile-fail/enum-and-module-in-same-scope.rs b/src/test/compile-fail/enum-and-module-in-same-scope.rs
index 7464764666c..7526c6753e6 100644
--- a/src/test/compile-fail/enum-and-module-in-same-scope.rs
+++ b/src/test/compile-fail/enum-and-module-in-same-scope.rs
@@ -13,7 +13,7 @@ mod Foo {
 }
 
 enum Foo {  //~ ERROR duplicate definition of type or module `Foo`
-    X
+    X //~ ERROR duplicate definition of value `X`
 }
 
 fn main() {}
diff --git a/src/test/compile-fail/namespaced-enum-glob-import-no-impls-xcrate.rs b/src/test/compile-fail/namespaced-enum-glob-import-no-impls-xcrate.rs
new file mode 100644
index 00000000000..09916a11f72
--- /dev/null
+++ b/src/test/compile-fail/namespaced-enum-glob-import-no-impls-xcrate.rs
@@ -0,0 +1,28 @@
+// 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
+#![feature(struct_variant, globs)]
+
+extern crate namespaced_enums;
+
+mod m {
+    pub use namespaced_enums::Foo::*;
+}
+
+pub fn main() {
+    use namespaced_enums::Foo::*;
+
+    foo(); //~ ERROR unresolved name `foo`
+    m::foo(); //~ ERROR unresolved name `m::foo`
+    bar(); //~ ERROR unresolved name `bar`
+    m::bar(); //~ ERROR unresolved name `m::bar`
+}
+
diff --git a/src/test/compile-fail/namespaced-enum-glob-import-no-impls.rs b/src/test/compile-fail/namespaced-enum-glob-import-no-impls.rs
new file mode 100644
index 00000000000..1554d410070
--- /dev/null
+++ b/src/test/compile-fail/namespaced-enum-glob-import-no-impls.rs
@@ -0,0 +1,36 @@
+// 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.
+#![feature(struct_variant, globs)]
+
+mod m2 {
+    pub enum Foo {
+        A,
+        B(int),
+        C { a: int },
+    }
+
+    impl Foo {
+        pub fn foo() {}
+        pub fn bar(&self) {}
+    }
+}
+
+mod m {
+    pub use m2::Foo::*;
+}
+
+pub fn main() {
+    use m2::Foo::*;
+
+    foo(); //~ ERROR unresolved name `foo`
+    m::foo(); //~ ERROR unresolved name `m::foo`
+    bar(); //~ ERROR unresolved name `bar`
+    m::bar(); //~ ERROR unresolved name `m::bar`
+}
diff --git a/src/test/compile-fail/use-from-trait-xc.rs b/src/test/compile-fail/use-from-trait-xc.rs
index cea85955d37..ff282413580 100644
--- a/src/test/compile-fail/use-from-trait-xc.rs
+++ b/src/test/compile-fail/use-from-trait-xc.rs
@@ -13,12 +13,15 @@
 extern crate use_from_trait_xc;
 
 use use_from_trait_xc::Trait::foo;
-//~^ ERROR unresolved import `use_from_trait_xc::Trait::foo`. Cannot import from a trait or type imp
+//~^ ERROR `foo` is not directly importable
 
 use use_from_trait_xc::Foo::new;
-//~^ ERROR unresolved import `use_from_trait_xc::Foo::new`. Cannot import from a trait or type imple
+//~^ ERROR `new` is not directly importable
 
-use use_from_trait_xc::Bar::new;
-//~^ ERROR unresolved import `use_from_trait_xc::Bar::new`. Cannot import from a trait or type
+use use_from_trait_xc::Bar::new as bnew;
+//~^ ERROR `bnew` is not directly importable
+
+use use_from_trait_xc::Baz::new as baznew;
+//~^ ERROR `baznew` is not directly importable
 
 fn main() {}
diff --git a/src/test/compile-fail/use-from-trait.rs b/src/test/compile-fail/use-from-trait.rs
index c9eea3c5df2..2a97155dd2e 100644
--- a/src/test/compile-fail/use-from-trait.rs
+++ b/src/test/compile-fail/use-from-trait.rs
@@ -9,9 +9,9 @@
 // except according to those terms.
 
 use Trait::foo;
-//~^ ERROR unresolved import `Trait::foo`. Cannot import from a trait or type implementation
+//~^ ERROR `foo` is not directly importable
 use Foo::new;
-//~^ ERROR unresolved import `Foo::new`. Cannot import from a trait or type implementation
+//~^ ERROR `new` is not directly importable
 
 pub trait Trait {
     fn foo();
diff --git a/src/test/run-pass/namespaced-enum-emulate-flat-xc.rs b/src/test/run-pass/namespaced-enum-emulate-flat-xc.rs
new file mode 100644
index 00000000000..540a0acb123
--- /dev/null
+++ b/src/test/run-pass/namespaced-enum-emulate-flat-xc.rs
@@ -0,0 +1,32 @@
+// 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_enum_emulate_flat.rs
+#![feature(struct_variant)]
+
+extern crate namespaced_enum_emulate_flat;
+
+use namespaced_enum_emulate_flat::{Foo, A, B, C};
+use namespaced_enum_emulate_flat::nest::{Bar, D, E, F};
+
+fn _f(f: Foo) {
+    match f {
+        A | B(_) | C { .. } => {}
+    }
+}
+
+fn _f2(f: Bar) {
+    match f {
+        D | E(_) | F { .. } => {}
+    }
+}
+
+pub fn main() {}
+
diff --git a/src/test/run-pass/namespaced-enum-emulate-flat.rs b/src/test/run-pass/namespaced-enum-emulate-flat.rs
new file mode 100644
index 00000000000..2aad9bcff56
--- /dev/null
+++ b/src/test/run-pass/namespaced-enum-emulate-flat.rs
@@ -0,0 +1,51 @@
+// 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.
+#![feature(globs, struct_variant)]
+
+pub use Foo::*;
+use nest::{Bar, D, E, F};
+
+pub enum Foo {
+    A,
+    B(int),
+    C { a: int },
+}
+
+impl Foo {
+    pub fn foo() {}
+}
+
+fn _f(f: Foo) {
+    match f {
+        A | B(_) | C { .. } => {}
+    }
+}
+
+mod nest {
+    pub use self::Bar::*;
+
+    pub enum Bar {
+        D,
+        E(int),
+        F { a: int },
+    }
+
+    impl Bar {
+        pub fn foo() {}
+    }
+}
+
+fn _f2(f: Bar) {
+    match f {
+        D | E(_) | F { .. } => {}
+    }
+}
+
+fn main() {}
diff --git a/src/test/run-pass/namespaced-enum-glob-import-xcrate.rs b/src/test/run-pass/namespaced-enum-glob-import-xcrate.rs
new file mode 100644
index 00000000000..35fb6676954
--- /dev/null
+++ b/src/test/run-pass/namespaced-enum-glob-import-xcrate.rs
@@ -0,0 +1,34 @@
+// 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
+#![feature(globs, struct_variant)]
+
+extern crate namespaced_enums;
+
+fn _f(f: namespaced_enums::Foo) {
+    use namespaced_enums::Foo::*;
+
+    match f {
+        A | B(_) | C { .. } => {}
+    }
+}
+
+mod m {
+    pub use namespaced_enums::Foo::*;
+}
+
+fn _f2(f: namespaced_enums::Foo) {
+    match f {
+        m::A | m::B(_) | m::C { .. } => {}
+    }
+}
+
+pub fn main() {}
diff --git a/src/test/run-pass/namespaced-enum-glob-import.rs b/src/test/run-pass/namespaced-enum-glob-import.rs
new file mode 100644
index 00000000000..fe6f3427383
--- /dev/null
+++ b/src/test/run-pass/namespaced-enum-glob-import.rs
@@ -0,0 +1,42 @@
+// 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.
+#![feature(globs, struct_variant)]
+
+mod m2 {
+    pub enum Foo {
+        A,
+        B(int),
+        C { a: int },
+    }
+
+    impl Foo {
+        pub fn foo() {}
+    }
+}
+
+mod m {
+    pub use m2::Foo::*;
+}
+
+fn _f(f: m2::Foo) {
+    use m2::Foo::*;
+
+    match f {
+        A | B(_) | C { .. } => {}
+    }
+}
+
+fn _f2(f: m2::Foo) {
+    match f {
+        m::A | m::B(_) | m::C { .. } => {}
+    }
+}
+
+pub fn main() {}
diff --git a/src/test/run-pass/namespaced-enums-xcrate.rs b/src/test/run-pass/namespaced-enums-xcrate.rs
new file mode 100644
index 00000000000..c5f80eaea5a
--- /dev/null
+++ b/src/test/run-pass/namespaced-enums-xcrate.rs
@@ -0,0 +1,25 @@
+// 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
+#![feature(struct_variant)]
+
+extern crate namespaced_enums;
+
+use namespaced_enums::Foo;
+
+fn _foo (f: Foo) {
+    match f {
+        Foo::A | Foo::B(_) | Foo::C { .. } => {}
+    }
+}
+
+pub fn main() {}
+
diff --git a/src/test/run-pass/namespaced-enums.rs b/src/test/run-pass/namespaced-enums.rs
new file mode 100644
index 00000000000..afa39c326b6
--- /dev/null
+++ b/src/test/run-pass/namespaced-enums.rs
@@ -0,0 +1,24 @@
+// 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.
+#![feature(struct_variant)]
+
+enum Foo {
+    A,
+    B(int),
+    C { a: int },
+}
+
+fn _foo (f: Foo) {
+    match f {
+        Foo::A | Foo::B(_) | Foo::C { .. } => {}
+    }
+}
+
+pub fn main() {}