rust/tests/ui/regions/regions-return-stack-allocated-vec.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

11 lines
221 B
Rust
Raw Normal View History

// Test that we cannot return a stack allocated slice
fn function(x: isize) -> &'static [isize] {
&[x] //~ ERROR cannot return reference to temporary value
2012-12-06 18:32:13 -08:00
}
fn main() {
let x = function(1);
let y = x[0];
}