about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-07-08 02:36:43 +0000
committerbors <bors@rust-lang.org>2014-07-08 02:36:43 +0000
commit6f46621b335d398f3c837750d31797014f63578b (patch)
tree223a7d1185cf31956d798cb5cbec014a166551db /src/test
parenta3257804df2bace236f83d9e5a9e887a1df30ef5 (diff)
parent3c9443b6e58c2c1a7bd9e6e2a74e183c33c98ebc (diff)
downloadrust-6f46621b335d398f3c837750d31797014f63578b.tar.gz
rust-6f46621b335d398f3c837750d31797014f63578b.zip
auto merge of #15443 : pcwalton/rust/module-and-type-with-same-name, r=nick29581
This will break code that looks like:

    struct Foo {
        ...
    }

    mod Foo {
        ...
    }

Change this code to:

    struct Foo {
        ...
    }

    impl Foo {
        ...
    }

Or rename the module.

Closes #15205.

[breaking-change]

r? @nick29581
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/dup-struct-enum-struct-variant.rs4
-rw-r--r--src/test/compile-fail/enum-and-module-in-same-scope.rs19
-rw-r--r--src/test/compile-fail/issue-3099-a.rs2
-rw-r--r--src/test/compile-fail/issue-3099-b.rs2
4 files changed, 23 insertions, 4 deletions
diff --git a/src/test/compile-fail/dup-struct-enum-struct-variant.rs b/src/test/compile-fail/dup-struct-enum-struct-variant.rs
index 064a3b9b168..47b576b2b85 100644
--- a/src/test/compile-fail/dup-struct-enum-struct-variant.rs
+++ b/src/test/compile-fail/dup-struct-enum-struct-variant.rs
@@ -11,9 +11,9 @@
 #![feature(struct_variant)]
 
 enum Foo { C { a: int, b: int } }
-struct C { a: int, b: int }         //~ ERROR error: duplicate definition of type `C`
+struct C { a: int, b: int }         //~ ERROR error: duplicate definition of type or module `C`
 
 struct A { x: int }
-enum Bar { A { x: int } }           //~ ERROR error: duplicate definition of type `A`
+enum Bar { A { x: int } }           //~ ERROR error: duplicate definition of type or module `A`
 
 fn main() {}
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
new file mode 100644
index 00000000000..7464764666c
--- /dev/null
+++ b/src/test/compile-fail/enum-and-module-in-same-scope.rs
@@ -0,0 +1,19 @@
+// 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.
+
+mod Foo {
+    pub static X: int = 42;
+}
+
+enum Foo {  //~ ERROR duplicate definition of type or module `Foo`
+    X
+}
+
+fn main() {}
diff --git a/src/test/compile-fail/issue-3099-a.rs b/src/test/compile-fail/issue-3099-a.rs
index 1b11fcac8a3..316199b6730 100644
--- a/src/test/compile-fail/issue-3099-a.rs
+++ b/src/test/compile-fail/issue-3099-a.rs
@@ -10,6 +10,6 @@
 
 enum a { b, c }
 
-enum a { d, e } //~ ERROR duplicate definition of type `a`
+enum a { d, e } //~ ERROR duplicate definition of type or module `a`
 
 fn main() {}
diff --git a/src/test/compile-fail/issue-3099-b.rs b/src/test/compile-fail/issue-3099-b.rs
index 5502b18f094..b3f1b2a32ea 100644
--- a/src/test/compile-fail/issue-3099-b.rs
+++ b/src/test/compile-fail/issue-3099-b.rs
@@ -10,6 +10,6 @@
 
 pub mod a {}
 
-pub mod a {} //~ ERROR duplicate definition of module `a`
+pub mod a {} //~ ERROR duplicate definition of type or module `a`
 
 fn main() {}