rust/tests/ui/regions/regions-return-stack-allocated-vec.rs
2023-01-11 09:32:08 +00:00

11 lines
221 B
Rust

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