about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2012-04-30 10:37:58 -0700
committerNiko Matsakis <niko@alum.mit.edu>2012-04-30 19:53:02 -0700
commit2db4259b3531e0cfa1f6df2ff95e30a4c871a105 (patch)
tree192b8d969e34bd1390bd769e17d68b2e9c57e77e /src/test
parent079c3b02a86aa73d0d070876612ed889dc187354 (diff)
downloadrust-2db4259b3531e0cfa1f6df2ff95e30a4c871a105.tar.gz
rust-2db4259b3531e0cfa1f6df2ff95e30a4c871a105.zip
Stop inferring bot/static when types/regions are unconstrained.
Also, some other changes that came up along the way:
- add a 'blk' region for the current block.
- detect unused type/region variables.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/issue-1763.rs7
-rw-r--r--src/test/compile-fail/issue-2163.rs2
-rw-r--r--src/test/compile-fail/region-unused.rs3
-rw-r--r--src/test/compile-fail/regions-blk.rs15
-rw-r--r--src/test/compile-fail/regions-in-consts.rs7
-rw-r--r--src/test/compile-fail/regions-in-type-items.rs2
-rw-r--r--src/test/compile-fail/regions-out-of-scope-slice.rs13
-rw-r--r--src/test/compile-fail/regions-var-type-out-of-scope.rs13
-rw-r--r--src/test/compile-fail/use-after-send.rs3
-rw-r--r--src/test/compile-fail/vector-no-ann.rs3
-rw-r--r--src/test/run-fail/bug-811.rs2
-rw-r--r--src/test/run-fail/issue-1763.rs14
-rw-r--r--src/test/run-fail/result-get-fail.rs2
-rw-r--r--src/test/run-pass/class-poly-methods-cross-crate.rs2
-rw-r--r--src/test/run-pass/iter-to-vec.rs5
-rw-r--r--src/test/run-pass/regions-mock-trans.rs2
-rw-r--r--src/test/run-pass/unreachable-code-1.rs (renamed from src/test/compile-fail/unreachable-code-1.rs)1
-rw-r--r--src/test/run-pass/unreachable-code.rs57
-rw-r--r--src/test/run-pass/vector-no-ann.rs4
-rw-r--r--src/test/run-pass/weird-exprs.rs7
20 files changed, 77 insertions, 87 deletions
diff --git a/src/test/compile-fail/issue-1763.rs b/src/test/compile-fail/issue-1763.rs
new file mode 100644
index 00000000000..678e3cc57ea
--- /dev/null
+++ b/src/test/compile-fail/issue-1763.rs
@@ -0,0 +1,7 @@
+// Issue #1763 - infer types correctly
+
+type actor<T> = { //! ERROR Type parameter T is unused.
+    unused: bool
+};
+
+fn main() {}
diff --git a/src/test/compile-fail/issue-2163.rs b/src/test/compile-fail/issue-2163.rs
index 89437289ebc..15b3d6d96c7 100644
--- a/src/test/compile-fail/issue-2163.rs
+++ b/src/test/compile-fail/issue-2163.rs
@@ -1,5 +1,5 @@
 fn main(s: [str]) {
-    let a = [];
+    let a: [int] = [];
     vec::each(a) { |x| //! ERROR in function `anon`, not all control paths
     }                  //! ERROR see function return type of `bool`
 }
diff --git a/src/test/compile-fail/region-unused.rs b/src/test/compile-fail/region-unused.rs
new file mode 100644
index 00000000000..617315853af
--- /dev/null
+++ b/src/test/compile-fail/region-unused.rs
@@ -0,0 +1,3 @@
+type foo/& = {f: int}; //! ERROR lifetime `self` unused
+
+fn main() {}
\ No newline at end of file
diff --git a/src/test/compile-fail/regions-blk.rs b/src/test/compile-fail/regions-blk.rs
new file mode 100644
index 00000000000..0d0cdb6d93f
--- /dev/null
+++ b/src/test/compile-fail/regions-blk.rs
@@ -0,0 +1,15 @@
+fn foo(cond: bool) {
+    let x = 5;
+    let mut y: &blk.int = &x;
+
+    let mut z: &blk.int;
+    if cond {
+        z = &x;
+    } else {
+        let w: &blk.int = &x;
+        z = w; //! ERROR mismatched types
+    }
+}
+
+fn main() {
+}
\ No newline at end of file
diff --git a/src/test/compile-fail/regions-in-consts.rs b/src/test/compile-fail/regions-in-consts.rs
new file mode 100644
index 00000000000..c48fec0f8ac
--- /dev/null
+++ b/src/test/compile-fail/regions-in-consts.rs
@@ -0,0 +1,7 @@
+// xfail-test
+
+const c_x: &blk.int = 22; //! ERROR only the static region is allowed here
+const c_y: &static.int = &22; //! ERROR only the static region is allowed here
+
+fn main() {
+}
\ No newline at end of file
diff --git a/src/test/compile-fail/regions-in-type-items.rs b/src/test/compile-fail/regions-in-type-items.rs
index 49202a340a1..c4619001e7c 100644
--- a/src/test/compile-fail/regions-in-type-items.rs
+++ b/src/test/compile-fail/regions-in-type-items.rs
@@ -18,7 +18,7 @@ type item_ty_yes1/& = {
     x: &self.uint
 };
 
-type item_ty_yes2/& = {
+type item_ty_yes2/& = { //! ERROR lifetime `self` unused inside reference-parameterized type
     x: &foo.uint //! ERROR named regions other than `self` are not allowed as part of a type declaration
 };
 
diff --git a/src/test/compile-fail/regions-out-of-scope-slice.rs b/src/test/compile-fail/regions-out-of-scope-slice.rs
new file mode 100644
index 00000000000..5f5aadaa107
--- /dev/null
+++ b/src/test/compile-fail/regions-out-of-scope-slice.rs
@@ -0,0 +1,13 @@
+// xfail-test
+
+fn foo(cond: bool) {
+    // Here we will infer a type that uses the
+    // region of the if stmt then block, but in the scope:
+    let mut x; //! ERROR foo
+
+    if cond {
+        x = [1,2,3]/&blk;
+    }
+}
+
+fn main() {}
\ No newline at end of file
diff --git a/src/test/compile-fail/regions-var-type-out-of-scope.rs b/src/test/compile-fail/regions-var-type-out-of-scope.rs
new file mode 100644
index 00000000000..b8aecb05e89
--- /dev/null
+++ b/src/test/compile-fail/regions-var-type-out-of-scope.rs
@@ -0,0 +1,13 @@
+// xfail-test
+
+fn foo(cond: bool) {
+    // Here we will infer a type that uses the
+    // region of the if stmt then block:
+    let mut x; //! ERROR foo
+
+    if cond {
+        x = &3;
+    }
+}
+
+fn main() {}
\ No newline at end of file
diff --git a/src/test/compile-fail/use-after-send.rs b/src/test/compile-fail/use-after-send.rs
index 3f1c0ab41e6..4fe164878a8 100644
--- a/src/test/compile-fail/use-after-send.rs
+++ b/src/test/compile-fail/use-after-send.rs
@@ -4,7 +4,8 @@ fn send<T: send>(ch: _chan<T>, -data: T) {
     log(debug, data);
     fail;
 }
-type _chan<T> = int;
+
+enum _chan<T> = int;
 
 // Tests that "log(debug, message);" is flagged as using
 // message after the send deinitializes it
diff --git a/src/test/compile-fail/vector-no-ann.rs b/src/test/compile-fail/vector-no-ann.rs
new file mode 100644
index 00000000000..8d4478d949f
--- /dev/null
+++ b/src/test/compile-fail/vector-no-ann.rs
@@ -0,0 +1,3 @@
+fn main() {
+    let _foo = []; //! ERROR unconstrained type
+}
diff --git a/src/test/run-fail/bug-811.rs b/src/test/run-fail/bug-811.rs
index 62206f93994..a7d360ff8fc 100644
--- a/src/test/run-fail/bug-811.rs
+++ b/src/test/run-fail/bug-811.rs
@@ -4,7 +4,7 @@ fn test00_start(ch: chan_t<int>, message: int) { send(ch, copy message); }
 type task_id = int;
 type port_id = int;
 
-type chan_t<T: send> = {task: task_id, port: port_id};
+enum chan_t<T: send> = {task: task_id, port: port_id};
 
 fn send<T: send>(ch: chan_t<T>, -data: T) { fail; }
 
diff --git a/src/test/run-fail/issue-1763.rs b/src/test/run-fail/issue-1763.rs
deleted file mode 100644
index 36ea0d961b7..00000000000
--- a/src/test/run-fail/issue-1763.rs
+++ /dev/null
@@ -1,14 +0,0 @@
-// Issue #1763 - infer types correctly
-// error-pattern:explicit failure
-
-type actor<T> = {
-    unused: bool
-};
-
-fn act2<T>() -> actor<T> {
-    fail;
-}
-
-fn main() {
-    let a: actor<int> = act2();
-}
diff --git a/src/test/run-fail/result-get-fail.rs b/src/test/run-fail/result-get-fail.rs
index 3b8e693e969..6f614258bcb 100644
--- a/src/test/run-fail/result-get-fail.rs
+++ b/src/test/run-fail/result-get-fail.rs
@@ -1,4 +1,4 @@
 // error-pattern:get called on error result: "kitty"
 fn main() {
-  log(error, result::get(result::err("kitty")));
+  log(error, result::get(result::err::<int,str>("kitty")));
 }
\ No newline at end of file
diff --git a/src/test/run-pass/class-poly-methods-cross-crate.rs b/src/test/run-pass/class-poly-methods-cross-crate.rs
index 28ddbfdd1e2..d46f501f0fa 100644
--- a/src/test/run-pass/class-poly-methods-cross-crate.rs
+++ b/src/test/run-pass/class-poly-methods-cross-crate.rs
@@ -1,3 +1,5 @@
+// xfail-test
+
 // xfail-fast
 // aux-build:cci_class_6.rs
 use cci_class_6;
diff --git a/src/test/run-pass/iter-to-vec.rs b/src/test/run-pass/iter-to-vec.rs
index 1f7afdb1c7b..3b2f1b2ced5 100644
--- a/src/test/run-pass/iter-to-vec.rs
+++ b/src/test/run-pass/iter-to-vec.rs
@@ -1,7 +1,8 @@
 fn main() {
     assert [1u, 3u].to_vec() == [1u, 3u];
-    assert [].to_vec() == [];
-    assert none.to_vec() == [];
+    let e: [uint] = [];
+    assert e.to_vec() == [];
+    assert none::<uint>.to_vec() == [];
     assert some(1u).to_vec() == [1u];
     assert some(2u).to_vec() == [2u];
 }
\ No newline at end of file
diff --git a/src/test/run-pass/regions-mock-trans.rs b/src/test/run-pass/regions-mock-trans.rs
index 4568bca444c..822ed735f77 100644
--- a/src/test/run-pass/regions-mock-trans.rs
+++ b/src/test/run-pass/regions-mock-trans.rs
@@ -16,7 +16,7 @@ type ccx = {
 };
 
 fn alloc(_bcx : &a.arena) -> &a.bcx unsafe {
-    ret unsafe::reinterpret_cast(libc::malloc(sys::size_of::<bcx>()));
+    ret unsafe::reinterpret_cast(libc::malloc(sys::size_of::<bcx/&blk>()));
 }
 
 fn h(bcx : &a.bcx) -> &a.bcx {
diff --git a/src/test/compile-fail/unreachable-code-1.rs b/src/test/run-pass/unreachable-code-1.rs
index 1dba6f952b5..38b97b47e4b 100644
--- a/src/test/compile-fail/unreachable-code-1.rs
+++ b/src/test/run-pass/unreachable-code-1.rs
@@ -8,7 +8,6 @@ fn call_id() {
 }
 
 fn call_id_3() { id(ret) && id(ret); }
-    //!^ ERROR the type of this value must be known
 
 fn main() {
 }
diff --git a/src/test/run-pass/unreachable-code.rs b/src/test/run-pass/unreachable-code.rs
deleted file mode 100644
index c97224144e2..00000000000
--- a/src/test/run-pass/unreachable-code.rs
+++ /dev/null
@@ -1,57 +0,0 @@
-// xfail-pretty
-
-fn id(x: bool) -> bool { x }
-
-fn call_id() {
-    let c <- fail;
-    id(c);
-}
-
-fn call_id_2() { id(true) && id(ret); }
-
-fn call_id_4() { while id(ret) { } }
-
-fn bind_id_1() { bind id(fail); }
-
-fn bind_id_2() { bind id(ret); }
-
-fn fail_fail() { fail fail; }
-
-fn log_fail() { log(error, fail); }
-
-fn log_ret() { log(error, ret); }
-
-fn log_break() { loop { log(error, break); } }
-
-fn log_cont() { do { log(error, cont); } while false }
-
-fn ret_ret() -> int { ret 3 + (ret 2); }
-
-fn ret_guard() {
-    alt check 2 {
-      x if (ret) { x; }
-    }
-}
-
-fn rec_ret() { let _r: {c: int} = {c: ret}; }
-
-fn vec_ret() { let _v: [int] = [1, 2, ret, 4]; }
-
-fn fail_then_concat() {
-    let mut x = [], y = [3];
-    fail;
-    x += y;
-    "good" + "bye";
-}
-
-fn main() {
-  // Call the functions that don't fail.
-  rec_ret();
-  vec_ret();
-  ret_ret();
-  log_ret();
-  call_id_2();
-  call_id_4();
-  bind_id_2();
-  ret_guard();
-}
diff --git a/src/test/run-pass/vector-no-ann.rs b/src/test/run-pass/vector-no-ann.rs
deleted file mode 100644
index dec8ca27db6..00000000000
--- a/src/test/run-pass/vector-no-ann.rs
+++ /dev/null
@@ -1,4 +0,0 @@
-fn main() {
-    // We will infer this to have the type vec[bot]
-    let _foo = [];
-}
diff --git a/src/test/run-pass/weird-exprs.rs b/src/test/run-pass/weird-exprs.rs
index e13c1a0d6af..bf3bd4c8ae6 100644
--- a/src/test/run-pass/weird-exprs.rs
+++ b/src/test/run-pass/weird-exprs.rs
@@ -1,6 +1,6 @@
 // Just a grab bag of stuff that you wouldn't want to actually write.
 
-fn strange() -> bool { let _x = ret true; }
+fn strange() -> bool { let _x: bool = ret true; }
 
 fn funny() {
     fn f(_x: ()) { }
@@ -20,13 +20,14 @@ fn zombiejesus() {
         while (ret) {
             if (ret) {
                 alt (ret) {
-                    _ {
+                    1 {
                         if (ret) {
                             ret
                         } else {
                             ret
                         }
                     }
+                    _ { ret }
                 };
             } else if (ret) {
                 ret;
@@ -51,7 +52,7 @@ fn canttouchthis() -> uint {
     pure fn p() -> bool { true }
     let _a = (assert (true)) == (check (p()));
     let _c = (check (p())) == ();
-    let _b = (log(debug, 0) == (ret 0u));
+    let _b: bool = (log(debug, 0) == (ret 0u));
 }
 
 fn angrydome() {