about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-12-12 09:12:08 +0000
committerbors <bors@rust-lang.org>2014-12-12 09:12:08 +0000
commitd2e2bd1b442948d4754bb1eb09ff1914a83604dd (patch)
treee9dca85d4acf8fba54aa0753866591dff1645cdf /src/test
parentda83ad8e2c8e2c5f522dc59963e00f55b1f8c03b (diff)
parent086c9493c822e8de53bdb5ccf6b32d2e05c3963f (diff)
downloadrust-d2e2bd1b442948d4754bb1eb09ff1914a83604dd.tar.gz
rust-d2e2bd1b442948d4754bb1eb09ff1914a83604dd.zip
auto merge of #19568 : barosl/rust/enum-struct-variants-ice, r=alexcrichton
This pull request tries to fix #19340, which states two ICE cases related to enum struct variants.

It is my first attempt to fix the compiler. I found this solution by trial and error, so the method used to fix the issue looks very hacky. Please review it, and direct me to find a better solution.

I'm also to add test cases. Where should I put them? Maybe `src/test/run-pass/issue-19340.rs`?
Diffstat (limited to 'src/test')
-rw-r--r--src/test/auxiliary/issue-19340-1.rs13
-rw-r--r--src/test/run-pass/issue-19340-1.rs23
-rw-r--r--src/test/run-pass/issue-19340-2.rs30
3 files changed, 66 insertions, 0 deletions
diff --git a/src/test/auxiliary/issue-19340-1.rs b/src/test/auxiliary/issue-19340-1.rs
new file mode 100644
index 00000000000..fc61b78d8a7
--- /dev/null
+++ b/src/test/auxiliary/issue-19340-1.rs
@@ -0,0 +1,13 @@
+// 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.
+
+pub enum Homura {
+    Madoka { name: String },
+}
diff --git a/src/test/run-pass/issue-19340-1.rs b/src/test/run-pass/issue-19340-1.rs
new file mode 100644
index 00000000000..b7a6391ee04
--- /dev/null
+++ b/src/test/run-pass/issue-19340-1.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.
+
+// aux-build:issue-19340-1.rs
+
+extern crate "issue-19340-1" as lib;
+
+use lib::Homura;
+
+fn main() {
+    let homura = Homura::Madoka { name: "Kaname".into_string() };
+
+    match homura {
+        Homura::Madoka { name } => (),
+    };
+}
diff --git a/src/test/run-pass/issue-19340-2.rs b/src/test/run-pass/issue-19340-2.rs
new file mode 100644
index 00000000000..5179c1e2acb
--- /dev/null
+++ b/src/test/run-pass/issue-19340-2.rs
@@ -0,0 +1,30 @@
+// 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.
+
+enum Homura {
+    Madoka {
+        name: String,
+        age: u32,
+    },
+}
+
+fn main() {
+    let homura = Homura::Madoka {
+        name: "Akemi".into_string(),
+        age: 14,
+    };
+
+    match homura {
+        Homura::Madoka {
+            name,
+            age,
+        } => (),
+    };
+}