about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2014-01-28 16:38:07 -0500
committerNiko Matsakis <niko@alum.mit.edu>2014-01-28 16:53:50 -0500
commitafd8df6af283ccf74184fbbaadec11cf27bc20c7 (patch)
tree32ddd9124cace0b79afab624a9a49fb375d3f705
parenta39be7ca2ef65f08c160404c1675d93ee7d0f059 (diff)
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.
-rw-r--r--src/test/compile-fail/regions-return-stack-allocated-vec.rs (renamed from src/test/compile-fail/issue-3243.rs)13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/test/compile-fail/issue-3243.rs b/src/test/compile-fail/regions-return-stack-allocated-vec.rs
index f235c4bc97c..b5f4fcadf89 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];
 }