about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorNick Cameron <ncameron@mozilla.com>2014-09-11 17:07:49 +1200
committerNick Cameron <ncameron@mozilla.com>2014-09-19 15:11:00 +1200
commitce0907e46e8e1aa23ee39f69e4f628f68bfbb0d7 (patch)
tree9ea529bfee7d62b85288d37b0e2bbcdd1c866e0d /src/test
parentaf3889f6979647b9bd2dc5f5132d80e3e5b405a5 (diff)
downloadrust-ce0907e46e8e1aa23ee39f69e4f628f68bfbb0d7.tar.gz
rust-ce0907e46e8e1aa23ee39f69e4f628f68bfbb0d7.zip
Add enum variants to the type namespace
Change to resolve and update compiler and libs for uses.

[breaking-change]

Enum variants are now in both the value and type namespaces. This means that
if you have a variant with the same name as a type in scope in a module, you
will get a name clash and thus an error. The solution is to either rename the
type or the variant.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/auxiliary/macro_crate_test.rs2
-rw-r--r--src/test/auxiliary/xcrate_unit_struct.rs2
-rw-r--r--src/test/compile-fail/enum-variant-type-2.rs (renamed from src/test/run-pass/issue-3186.rs)12
-rw-r--r--src/test/compile-fail/enum-variant-type.rs23
-rw-r--r--src/test/compile-fail/issue-3008-1.rs2
-rw-r--r--src/test/compile-fail/issue-3008-2.rs2
-rw-r--r--src/test/compile-fail/recursion.rs4
-rw-r--r--src/test/pretty/tag-blank-lines.rs4
-rw-r--r--src/test/run-fail/issue-2444.rs2
-rw-r--r--src/test/run-pass/borrowck-univariant-enum.rs6
-rw-r--r--src/test/run-pass/coerce-to-closure-and-proc.rs10
-rw-r--r--src/test/run-pass/issue-2804.rs2
-rw-r--r--src/test/run-pass/issue-3874.rs4
-rw-r--r--src/test/run-pass/match-arm-statics.rs6
-rw-r--r--src/test/run-pass/tag-align-shape.rs6
-rw-r--r--src/test/run-pass/tag-align-u64.rs4
-rw-r--r--src/test/run-pass/xcrate-unit-struct.rs4
17 files changed, 61 insertions, 34 deletions
diff --git a/src/test/auxiliary/macro_crate_test.rs b/src/test/auxiliary/macro_crate_test.rs
index dd1f9c3404f..befd33fca4e 100644
--- a/src/test/auxiliary/macro_crate_test.rs
+++ b/src/test/auxiliary/macro_crate_test.rs
@@ -35,7 +35,7 @@ pub fn plugin_registrar(reg: &mut Registry) {
     reg.register_macro("identity", expand_identity);
     reg.register_syntax_extension(
         token::intern("into_foo"),
-        ItemModifier(box expand_into_foo));
+        Modifier(box expand_into_foo));
 }
 
 fn expand_make_a_1(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree])
diff --git a/src/test/auxiliary/xcrate_unit_struct.rs b/src/test/auxiliary/xcrate_unit_struct.rs
index 7619513a2a6..6487c704765 100644
--- a/src/test/auxiliary/xcrate_unit_struct.rs
+++ b/src/test/auxiliary/xcrate_unit_struct.rs
@@ -15,7 +15,7 @@
 pub struct Struct;
 
 pub enum Unit {
-    Unit,
+    UnitVariant,
     Argument(Struct)
 }
 
diff --git a/src/test/run-pass/issue-3186.rs b/src/test/compile-fail/enum-variant-type-2.rs
index 6b35cd7e0c9..bf80626793d 100644
--- a/src/test/run-pass/issue-3186.rs
+++ b/src/test/compile-fail/enum-variant-type-2.rs
@@ -1,4 +1,4 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// 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.
 //
@@ -8,8 +8,12 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-enum y { x }
+// Test that enum variants are not actually types.
 
-enum x {}
+enum Foo {
+    Bar
+}
 
-pub fn main() {}
+fn foo(x: Bar) {} //~ERROR found value name used as a type
+
+fn main() {}
diff --git a/src/test/compile-fail/enum-variant-type.rs b/src/test/compile-fail/enum-variant-type.rs
new file mode 100644
index 00000000000..93d44f96c8a
--- /dev/null
+++ b/src/test/compile-fail/enum-variant-type.rs
@@ -0,0 +1,23 @@
+// 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.
+
+// Test that enum variants are in the type namespace.
+
+enum Foo {
+    Foo //~ERROR duplicate definition of type or module `Foo`
+}
+
+enum Bar {
+    Baz
+}
+
+trait Baz {} //~ERROR duplicate definition of type or module `Baz`
+
+pub fn main() {}
diff --git a/src/test/compile-fail/issue-3008-1.rs b/src/test/compile-fail/issue-3008-1.rs
index 3613fb8ccbe..d2d7d800470 100644
--- a/src/test/compile-fail/issue-3008-1.rs
+++ b/src/test/compile-fail/issue-3008-1.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-enum foo { foo(bar) }
+enum foo { foo_(bar) }
 enum bar { bar_none, bar_some(bar) }
 //~^ ERROR illegal recursive enum type; wrap the inner value in a box to make it representable
 
diff --git a/src/test/compile-fail/issue-3008-2.rs b/src/test/compile-fail/issue-3008-2.rs
index db3124214bd..1e8f81a05e7 100644
--- a/src/test/compile-fail/issue-3008-2.rs
+++ b/src/test/compile-fail/issue-3008-2.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-enum foo { foo(bar) }
+enum foo { foo_(bar) }
 struct bar { x: bar }
 //~^ ERROR illegal recursive struct type; wrap the inner value in a box to make it representable
 //~^^ ERROR this type cannot be instantiated without an instance of itself
diff --git a/src/test/compile-fail/recursion.rs b/src/test/compile-fail/recursion.rs
index 96676257184..c99ec5187b0 100644
--- a/src/test/compile-fail/recursion.rs
+++ b/src/test/compile-fail/recursion.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-enum Nil {Nil}
+enum Nil {NilValue}
 struct Cons<T> {head:int, tail:T}
 trait Dot {fn dot(&self, other:Self) -> int;}
 impl Dot for Nil {
@@ -29,6 +29,6 @@ fn test<T:Dot> (n:int, i:int, first:T, second:T) ->int {
   }
 }
 pub fn main() {
-  let n = test(1, 0, Nil, Nil);
+  let n = test(1, 0, NilValue, NilValue);
   println!("{}", n);
 }
diff --git a/src/test/pretty/tag-blank-lines.rs b/src/test/pretty/tag-blank-lines.rs
index 93373b0066d..29a3b965251 100644
--- a/src/test/pretty/tag-blank-lines.rs
+++ b/src/test/pretty/tag-blank-lines.rs
@@ -11,8 +11,8 @@
 // pp-exact
 
 enum foo {
-    foo, // a foo.
-    bar,
+    bar, // a bar.
+    baz,
 }
 
 fn main() { }
diff --git a/src/test/run-fail/issue-2444.rs b/src/test/run-fail/issue-2444.rs
index dbe2a9e9229..9a5a8e7c38f 100644
--- a/src/test/run-fail/issue-2444.rs
+++ b/src/test/run-fail/issue-2444.rs
@@ -12,7 +12,7 @@
 
 use std::sync::Arc;
 
-enum e<T> { e(Arc<T>) }
+enum e<T> { ee(Arc<T>) }
 
 fn foo() -> e<int> {fail!();}
 
diff --git a/src/test/run-pass/borrowck-univariant-enum.rs b/src/test/run-pass/borrowck-univariant-enum.rs
index 0910f02dc29..8192566da19 100644
--- a/src/test/run-pass/borrowck-univariant-enum.rs
+++ b/src/test/run-pass/borrowck-univariant-enum.rs
@@ -13,7 +13,7 @@ use std::cell::Cell;
 use std::gc::GC;
 
 enum newtype {
-    newtype(int)
+    newvar(int)
 }
 
 pub fn main() {
@@ -22,9 +22,9 @@ pub fn main() {
     // specially.
 
     let x = box(GC) Cell::new(5);
-    let y = box(GC) Cell::new(newtype(3));
+    let y = box(GC) Cell::new(newvar(3));
     let z = match y.get() {
-      newtype(b) => {
+      newvar(b) => {
         x.set(x.get() + 1);
         x.get() * b
       }
diff --git a/src/test/run-pass/coerce-to-closure-and-proc.rs b/src/test/run-pass/coerce-to-closure-and-proc.rs
index 15870b627b2..44a3517cc75 100644
--- a/src/test/run-pass/coerce-to-closure-and-proc.rs
+++ b/src/test/run-pass/coerce-to-closure-and-proc.rs
@@ -17,7 +17,7 @@ struct Foo<T>(T);
 
 #[deriving(PartialEq, Show)]
 enum Bar<T> {
-    Bar(T)
+    Baz(T)
 }
 
 pub fn main() {
@@ -33,11 +33,11 @@ pub fn main() {
     let f: proc(int) -> Foo<int> = Foo;
     assert_eq!(f(5), Foo(5));
 
-    let f: |int| -> Bar<int> = Bar;
-    assert_eq!(f(5), Bar(5));
+    let f: |int| -> Bar<int> = Baz;
+    assert_eq!(f(5), Baz(5));
 
-    let f: proc(int) -> Bar<int> = Bar;
-    assert_eq!(f(5), Bar(5));
+    let f: proc(int) -> Bar<int> = Baz;
+    assert_eq!(f(5), Baz(5));
 
     let f: |int| -> Option<int> = Some;
     assert_eq!(f(5), Some(5));
diff --git a/src/test/run-pass/issue-2804.rs b/src/test/run-pass/issue-2804.rs
index d4b77ea4976..b160fa34c91 100644
--- a/src/test/run-pass/issue-2804.rs
+++ b/src/test/run-pass/issue-2804.rs
@@ -22,7 +22,7 @@ enum object {
     int_value(i64),
 }
 
-fn lookup(table: json::Object, key: String, default: String) -> String
+fn lookup(table: json::JsonObject, key: String, default: String) -> String
 {
     match table.find(&key.to_string()) {
         option::Some(&json::String(ref s)) => {
diff --git a/src/test/run-pass/issue-3874.rs b/src/test/run-pass/issue-3874.rs
index 40725311f31..75f6a2faa80 100644
--- a/src/test/run-pass/issue-3874.rs
+++ b/src/test/run-pass/issue-3874.rs
@@ -8,10 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-enum PureCounter { PureCounter(uint) }
+enum PureCounter { PureCounterVariant(uint) }
 
 fn each(thing: PureCounter, blk: |v: &uint|) {
-    let PureCounter(ref x) = thing;
+    let PureCounterVariant(ref x) = thing;
     blk(x);
 }
 
diff --git a/src/test/run-pass/match-arm-statics.rs b/src/test/run-pass/match-arm-statics.rs
index a8f6d9c3917..6eb0a4dad1b 100644
--- a/src/test/run-pass/match-arm-statics.rs
+++ b/src/test/run-pass/match-arm-statics.rs
@@ -88,10 +88,10 @@ fn issue_14576() {
 }
 
 fn issue_13731() {
-    enum A { A(()) }
-    static B: A = A(());
+    enum A { AA(()) }
+    static B: A = AA(());
 
-    match A(()) {
+    match AA(()) {
         B => ()
     }
 }
diff --git a/src/test/run-pass/tag-align-shape.rs b/src/test/run-pass/tag-align-shape.rs
index e161f6887e1..e032a5e4156 100644
--- a/src/test/run-pass/tag-align-shape.rs
+++ b/src/test/run-pass/tag-align-shape.rs
@@ -11,7 +11,7 @@
 extern crate debug;
 
 enum a_tag {
-    a_tag(u64)
+    a_tag_var(u64)
 }
 
 struct t_rec {
@@ -20,8 +20,8 @@ struct t_rec {
 }
 
 pub fn main() {
-    let x = t_rec {c8: 22u8, t: a_tag(44u64)};
+    let x = t_rec {c8: 22u8, t: a_tag_var(44u64)};
     let y = format!("{:?}", x);
     println!("y = {}", y);
-    assert_eq!(y, "t_rec{c8: 22u8, t: a_tag(44u64)}".to_string());
+    assert_eq!(y, "t_rec{c8: 22u8, t: a_tag_var(44u64)}".to_string());
 }
diff --git a/src/test/run-pass/tag-align-u64.rs b/src/test/run-pass/tag-align-u64.rs
index 8942e0b6b5d..398a0939d97 100644
--- a/src/test/run-pass/tag-align-u64.rs
+++ b/src/test/run-pass/tag-align-u64.rs
@@ -14,7 +14,7 @@
 use std::mem;
 
 enum Tag {
-    Tag(u64)
+    TagInner(u64)
 }
 
 struct Rec {
@@ -23,7 +23,7 @@ struct Rec {
 }
 
 fn mk_rec() -> Rec {
-    return Rec { c8:0u8, t:Tag(0u64) };
+    return Rec { c8:0u8, t:TagInner(0u64) };
 }
 
 fn is_8_byte_aligned(u: &Tag) -> bool {
diff --git a/src/test/run-pass/xcrate-unit-struct.rs b/src/test/run-pass/xcrate-unit-struct.rs
index ae8d628289d..9ba4b707268 100644
--- a/src/test/run-pass/xcrate-unit-struct.rs
+++ b/src/test/run-pass/xcrate-unit-struct.rs
@@ -12,7 +12,7 @@
 extern crate xcrate_unit_struct;
 
 static s1: xcrate_unit_struct::Struct = xcrate_unit_struct::Struct;
-static s2: xcrate_unit_struct::Unit = xcrate_unit_struct::Unit;
+static s2: xcrate_unit_struct::Unit = xcrate_unit_struct::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);
@@ -22,7 +22,7 @@ fn f2(_: xcrate_unit_struct::Unit) {}
 
 pub fn main() {
     f1(xcrate_unit_struct::Struct);
-    f2(xcrate_unit_struct::Unit);
+    f2(xcrate_unit_struct::UnitVariant);
     f2(xcrate_unit_struct::Argument(xcrate_unit_struct::Struct));
 
     f1(s1);