Skip to content

Commit 80844f9

Browse files
committed
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.
1 parent c7325c4 commit 80844f9

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
struct S { f0: ~str, f1: int }
12+
13+
pub fn main() {
14+
let s = ~"Hello, world!";
15+
let _s = S { f0: str::from_slice(s), ..S { f0: s, f1: 23 } };
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
struct S { f0: ~str, f1: ~str }
12+
13+
pub fn main() {
14+
let s = ~"Hello, world!";
15+
let _s = S { f1: str::from_slice(s), f0: s };
16+
}

0 commit comments

Comments
 (0)