about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJed Davis <jld@panix.com>2013-02-24 13:15:05 -0800
committerJed Davis <jld@panix.com>2013-03-06 20:41:57 -0800
commit80844f993d8964ca89630115c5c0f7e8beb315cb (patch)
tree37139ecd0ee207141c78edd63a25be128f09d8a3
parentc7325c417257646afdd93fd3cc10ef891d167643 (diff)
downloadrust-80844f993d8964ca89630115c5c0f7e8beb315cb.tar.gz
rust-80844f993d8964ca89630115c5c0f7e8beb315cb.zip
Add regression tests for a subtle aspect of expr_struct translation.
The first is reduced from a case in rustdoc (originally involving an
ARC); the other is related.  No committed version has gotten these
wrong, but when I broke them it showed up only in rustdoc; there was
nothing in the test suite (or the compiler!) that failed.

The general issue is that the statics and trans have to agree on order
of evaluation, or else you get use-after-move-out-of errors at runtime.
-rw-r--r--src/test/run-pass/struct-order-of-eval-1.rs16
-rw-r--r--src/test/run-pass/struct-order-of-eval-2.rs16
2 files changed, 32 insertions, 0 deletions
diff --git a/src/test/run-pass/struct-order-of-eval-1.rs b/src/test/run-pass/struct-order-of-eval-1.rs
new file mode 100644
index 00000000000..db7c73cbfc5
--- /dev/null
+++ b/src/test/run-pass/struct-order-of-eval-1.rs
@@ -0,0 +1,16 @@
+// Copyright 2013 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 { f0: ~str, f1: int }
+
+pub fn main() {
+    let s = ~"Hello, world!";
+    let _s = S { f0: str::from_slice(s), ..S { f0: s, f1: 23 } };
+}
diff --git a/src/test/run-pass/struct-order-of-eval-2.rs b/src/test/run-pass/struct-order-of-eval-2.rs
new file mode 100644
index 00000000000..413f185659a
--- /dev/null
+++ b/src/test/run-pass/struct-order-of-eval-2.rs
@@ -0,0 +1,16 @@
+// Copyright 2013 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 { f0: ~str, f1: ~str }
+
+pub fn main() {
+    let s = ~"Hello, world!";
+    let _s = S { f1: str::from_slice(s), f0: s };
+}