Add test case for #3243, which was fixed as part of fix for #3511.

(Lifetime of stack allocated vectors was not being enforced)

Closes #3243.
This commit is contained in:
Niko Matsakis 2014-01-28 16:38:07 -05:00
parent a39be7ca2e
commit afd8df6af2

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];
}