Skip to content

Commit afd8df6

Browse files
committed
Add test case for rust-lang#3243, which was fixed as part of fix for rust-lang#3511.
(Lifetime of stack allocated vectors was not being enforced) Closes rust-lang#3243.
1 parent a39be7c commit afd8df6

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/test/compile-fail/issue-3243.rs renamed to src/test/compile-fail/regions-return-stack-allocated-vec.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// xfail-test
12-
fn function() -> &mut [int] {
13-
let mut x: &'static mut [int] = &[1,2,3];
14-
x[0] = 12345;
15-
x //~ ERROR bad
11+
// Test that we cannot return a stack allocated slice
12+
13+
fn function(x: int) -> &'static [int] {
14+
&[x] //~ ERROR mismatched types
1615
}
1716

1817
fn main() {
19-
let x = function();
20-
error!("%?", x);
18+
let x = function(1);
19+
let y = x[0];
2120
}

0 commit comments

Comments
 (0)