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.
This commit is contained in:
parent
c7325c4172
commit
80844f993d
16
src/test/run-pass/struct-order-of-eval-1.rs
Normal file
16
src/test/run-pass/struct-order-of-eval-1.rs
Normal file
@ -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 } };
|
||||||
|
}
|
16
src/test/run-pass/struct-order-of-eval-2.rs
Normal file
16
src/test/run-pass/struct-order-of-eval-2.rs
Normal file
@ -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 };
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user