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:
commit
7b1432f6c0
1 changed files with 6 additions and 7 deletions
|
@ -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];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue