1
Fork 0

auto merge of #11889 : nikomatsakis/rust/issue-3243-stack-alloc-vec, r=nikomatsakis

(Lifetime of stack allocated vectors was not being enforced)

Closes #3243.
This commit is contained in:
bors 2014-01-29 05:06:44 -08:00
commit 7b1432f6c0

View file

@ -8,14 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// xfail-test
fn function() -> &mut [int] {
let mut x: &'static mut [int] = &[1,2,3];
x[0] = 12345;
x //~ ERROR bad
// Test that we cannot return a stack allocated slice
fn function(x: int) -> &'static [int] {
&[x] //~ ERROR mismatched types
}
fn main() {
let x = function();
error!("%?", x);
let x = function(1);
let y = x[0];
}