From 80844f993d8964ca89630115c5c0f7e8beb315cb Mon Sep 17 00:00:00 2001 From: Jed Davis Date: Sun, 24 Feb 2013 13:15:05 -0800 Subject: [PATCH] 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. --- src/test/run-pass/struct-order-of-eval-1.rs | 16 ++++++++++++++++ src/test/run-pass/struct-order-of-eval-2.rs | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 src/test/run-pass/struct-order-of-eval-1.rs create mode 100644 src/test/run-pass/struct-order-of-eval-2.rs 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 000000000000..db7c73cbfc5e --- /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 or the MIT license +// , 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 000000000000..413f185659a6 --- /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 or the MIT license +// , 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 }; +}