From afd8df6af283ccf74184fbbaadec11cf27bc20c7 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 28 Jan 2014 16:38:07 -0500 Subject: [PATCH] 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. --- ...243.rs => regions-return-stack-allocated-vec.rs} | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) rename src/test/compile-fail/{issue-3243.rs => regions-return-stack-allocated-vec.rs} (73%) diff --git a/src/test/compile-fail/issue-3243.rs b/src/test/compile-fail/regions-return-stack-allocated-vec.rs similarity index 73% rename from src/test/compile-fail/issue-3243.rs rename to src/test/compile-fail/regions-return-stack-allocated-vec.rs index f235c4bc97c41..b5f4fcadf89fe 100644 --- a/src/test/compile-fail/issue-3243.rs +++ b/src/test/compile-fail/regions-return-stack-allocated-vec.rs @@ -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]; }