Skip to content

Commit 7b1432f

Browse files
committed
auto merge of #11889 : nikomatsakis/rust/issue-3243-stack-alloc-vec, r=nikomatsakis
(Lifetime of stack allocated vectors was not being enforced) Closes #3243.
2 parents 1d80a9a + afd8df6 commit 7b1432f

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)