about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-07-07 21:01:42 +0000
committerbors <bors@rust-lang.org>2014-07-07 21:01:42 +0000
commitc175ed4425da809d6d28bc509b7dd5301a4a2b33 (patch)
treeb62bfd745481069fd82c59daa47ee63371ad07d6 /src/test
parent49bc17bfdd7143909aede81652d7d624cecd8a70 (diff)
parentaaaf7e00ec67961e89806e0ad58a0ec9bad07ae8 (diff)
downloadrust-c175ed4425da809d6d28bc509b7dd5301a4a2b33.tar.gz
rust-c175ed4425da809d6d28bc509b7dd5301a4a2b33.zip
auto merge of #15440 : pcwalton/rust/struct-aliases, r=brson
Closes #4508.

r? @nick29581
Diffstat (limited to 'src/test')
-rw-r--r--src/test/auxiliary/xcrate_struct_aliases.rs17
-rw-r--r--src/test/compile-fail/issue-14541.rs4
-rw-r--r--src/test/run-pass/struct-aliases-xcrate.rs31
-rw-r--r--src/test/run-pass/struct-aliases.rs33
4 files changed, 83 insertions, 2 deletions
diff --git a/src/test/auxiliary/xcrate_struct_aliases.rs b/src/test/auxiliary/xcrate_struct_aliases.rs
new file mode 100644
index 00000000000..a0ec7272720
--- /dev/null
+++ b/src/test/auxiliary/xcrate_struct_aliases.rs
@@ -0,0 +1,17 @@
+// Copyright 2012 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 S {
+    pub x: int,
+    pub y: int,
+}
+
+pub type S2 = S;
+
diff --git a/src/test/compile-fail/issue-14541.rs b/src/test/compile-fail/issue-14541.rs
index 2dcfeac513c..921e331e960 100644
--- a/src/test/compile-fail/issue-14541.rs
+++ b/src/test/compile-fail/issue-14541.rs
@@ -13,8 +13,8 @@ struct vec3 { y: f32, z: f32 }
 
 fn make(v: vec2) {
     let vec3 { y: _, z: _ } = v;
-    //~^ ERROR mismatched types: expected `vec2` but found `vec3`
+    //~^ ERROR `vec3` does not name the structure `vec2`
     //~^^ ERROR struct `vec2` does not have a field named `z`
 }
 
-fn main() { }
\ No newline at end of file
+fn main() { }
diff --git a/src/test/run-pass/struct-aliases-xcrate.rs b/src/test/run-pass/struct-aliases-xcrate.rs
new file mode 100644
index 00000000000..9046cafe757
--- /dev/null
+++ b/src/test/run-pass/struct-aliases-xcrate.rs
@@ -0,0 +1,31 @@
+// Copyright 2012 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:xcrate_struct_aliases.rs
+extern crate xcrate_struct_aliases;
+
+use xcrate_struct_aliases::{S, S2};
+
+fn main() {
+    let s = S2 {
+        x: 1,
+        y: 2,
+    };
+    match s {
+        S2 {
+            x: x,
+            y: y
+        } => {
+            assert_eq!(x, 1);
+            assert_eq!(y, 2);
+        }
+    }
+}
+
diff --git a/src/test/run-pass/struct-aliases.rs b/src/test/run-pass/struct-aliases.rs
new file mode 100644
index 00000000000..2cf961a5c0c
--- /dev/null
+++ b/src/test/run-pass/struct-aliases.rs
@@ -0,0 +1,33 @@
+// Copyright 2012 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.
+
+struct S {
+    x: int,
+    y: int,
+}
+
+type S2 = S;
+
+fn main() {
+    let s = S2 {
+        x: 1,
+        y: 2,
+    };
+    match s {
+        S2 {
+            x: x,
+            y: y
+        } => {
+            assert_eq!(x, 1);
+            assert_eq!(y, 2);
+        }
+    }
+}
+