about summary refs log tree commit diff
path: root/src/test/run-pass
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/run-pass
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/run-pass')
-rw-r--r--src/test/run-pass/struct-aliases-xcrate.rs31
-rw-r--r--src/test/run-pass/struct-aliases.rs33
2 files changed, 64 insertions, 0 deletions
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);
+        }
+    }
+}
+