about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-06-28 18:21:34 +0000
committerbors <bors@rust-lang.org>2014-06-28 18:21:34 +0000
commitde337f3ddfbef800a8cf731e0b593e341af1e3e5 (patch)
tree7f35eb443f0b58d81dc39f6d19da42bac4645d7e /src/test
parentb47f2226a25654c5b781d27a91f2fa5274b3a347 (diff)
parent05e3248a7974f55b64f75a2483b37ff8c001a4ff (diff)
downloadrust-de337f3ddfbef800a8cf731e0b593e341af1e3e5.tar.gz
rust-de337f3ddfbef800a8cf731e0b593e341af1e3e5.zip
auto merge of #15191 : pcwalton/rust/variance-in-trait-matching, r=huonw
I believe that #5781 got fixed by the DST work. It duplicated the
variance inference work in #12828. Therefore, all that is left in #5781
is adding a test.

Closes #5781.

r? @huonw
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/regions-escape-via-trait-or-not.rs2
-rw-r--r--src/test/compile-fail/variance-trait-matching-2.rs31
-rw-r--r--src/test/compile-fail/variance-trait-matching.rs30
-rw-r--r--src/test/run-fail/fail-task-name-none.rs7
-rw-r--r--src/test/run-fail/fail-task-name-owned.rs6
-rw-r--r--src/test/run-fail/fail-task-name-send-str.rs11
-rw-r--r--src/test/run-fail/fail-task-name-static.rs8
-rw-r--r--src/test/run-fail/task-spawn-barefn.rs5
-rw-r--r--src/test/run-pass/trait-contravariant-self.rs2
9 files changed, 88 insertions, 14 deletions
diff --git a/src/test/compile-fail/regions-escape-via-trait-or-not.rs b/src/test/compile-fail/regions-escape-via-trait-or-not.rs
index 7f54fe298a1..980a4aed34f 100644
--- a/src/test/compile-fail/regions-escape-via-trait-or-not.rs
+++ b/src/test/compile-fail/regions-escape-via-trait-or-not.rs
@@ -23,7 +23,7 @@ fn with<R:deref>(f: |x: &int| -> R) -> int {
 }
 
 fn return_it() -> int {
-    with(|o| o) //~ ERROR lifetime of function argument does not outlive the function call
+    with(|o| o) //~ ERROR cannot infer an appropriate lifetime
 }
 
 fn main() {
diff --git a/src/test/compile-fail/variance-trait-matching-2.rs b/src/test/compile-fail/variance-trait-matching-2.rs
new file mode 100644
index 00000000000..f549c78be9d
--- /dev/null
+++ b/src/test/compile-fail/variance-trait-matching-2.rs
@@ -0,0 +1,31 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+extern crate serialize;
+
+use std::io::MemWriter;
+use std::io;
+use serialize::{Encodable, Encoder};
+
+pub fn buffer_encode<'a,
+                     T:Encodable<serialize::json::Encoder<'a>,io::IoError>>(
+                     to_encode_object: &T)
+                     -> Vec<u8> {
+    let mut m = MemWriter::new();
+    {
+        let mut encoder =
+            serialize::json::Encoder::new(&mut m as &mut io::Writer);
+        //~^ ERROR `m` does not live long enough
+        to_encode_object.encode(&mut encoder);
+    }
+    m.unwrap()
+}
+
+fn main() {}
diff --git a/src/test/compile-fail/variance-trait-matching.rs b/src/test/compile-fail/variance-trait-matching.rs
new file mode 100644
index 00000000000..1644705222f
--- /dev/null
+++ b/src/test/compile-fail/variance-trait-matching.rs
@@ -0,0 +1,30 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Issue #5781. Tests that subtyping is handled properly in trait matching.
+
+trait Make<'a> {
+    fn make(x: &'a mut int) -> Self;
+}
+
+impl<'a> Make<'a> for &'a mut int {
+    fn make(x: &'a mut int) -> &'a mut int {
+        x
+    }
+}
+
+fn f() -> &'static mut int {
+    let mut x = 1;
+    let y: &'static mut int = Make::make(&mut x);   //~ ERROR `x` does not live long enough
+    y
+}
+
+fn main() {}
+
diff --git a/src/test/run-fail/fail-task-name-none.rs b/src/test/run-fail/fail-task-name-none.rs
index 3f662e6d0e3..75d23d0f4fd 100644
--- a/src/test/run-fail/fail-task-name-none.rs
+++ b/src/test/run-fail/fail-task-name-none.rs
@@ -13,8 +13,9 @@
 use std::task;
 
 fn main() {
-    task::try(proc() {
+    let r: Result<int,_> = task::try(proc() {
         fail!("test");
-        1
-    }).unwrap()
+        1i
+    });
+    assert!(r.is_ok());
 }
diff --git a/src/test/run-fail/fail-task-name-owned.rs b/src/test/run-fail/fail-task-name-owned.rs
index ea643fd26d9..b1c8963e684 100644
--- a/src/test/run-fail/fail-task-name-owned.rs
+++ b/src/test/run-fail/fail-task-name-owned.rs
@@ -13,8 +13,10 @@
 use std::task::TaskBuilder;
 
 fn main() {
-    TaskBuilder::new().named("owned name".to_string()).try(proc() {
+    let r: Result<int,_> = TaskBuilder::new().named("owned name".to_string())
+                                             .try(proc() {
         fail!("test");
         1
-    }).unwrap()
+    });
+    assert!(r.is_ok());
 }
diff --git a/src/test/run-fail/fail-task-name-send-str.rs b/src/test/run-fail/fail-task-name-send-str.rs
index d99c805323f..5153c5f2807 100644
--- a/src/test/run-fail/fail-task-name-send-str.rs
+++ b/src/test/run-fail/fail-task-name-send-str.rs
@@ -11,8 +11,11 @@
 // error-pattern:task 'send name' failed at 'test'
 
 fn main() {
-    ::std::task::TaskBuilder::new().named("send name".into_maybe_owned()).try(proc() {
-        fail!("test");
-        3
-    }).unwrap()
+    let r: Result<int,_> =
+        ::std::task::TaskBuilder::new().named("send name".into_maybe_owned())
+                                       .try(proc() {
+            fail!("test");
+            3
+        });
+    assert!(r.is_ok());
 }
diff --git a/src/test/run-fail/fail-task-name-static.rs b/src/test/run-fail/fail-task-name-static.rs
index e0c98c5744e..0b2901889cb 100644
--- a/src/test/run-fail/fail-task-name-static.rs
+++ b/src/test/run-fail/fail-task-name-static.rs
@@ -11,7 +11,9 @@
 // error-pattern:task 'static name' failed at 'test'
 
 fn main() {
-    ::std::task::TaskBuilder::new().named("static name").try(proc() {
-        fail!("test");
-    }).unwrap()
+    let r: Result<int,_> =
+        ::std::task::TaskBuilder::new().named("static name").try(proc() {
+            fail!("test");
+        });
+    assert!(r.is_ok());
 }
diff --git a/src/test/run-fail/task-spawn-barefn.rs b/src/test/run-fail/task-spawn-barefn.rs
index ae189889967..e7fd97f8d31 100644
--- a/src/test/run-fail/task-spawn-barefn.rs
+++ b/src/test/run-fail/task-spawn-barefn.rs
@@ -15,7 +15,10 @@ use std::task;
 fn main() {
     // the purpose of this test is to make sure that task::spawn()
     // works when provided with a bare function:
-    task::try(startfn).unwrap();
+    let r = task::try(startfn);
+    if r.is_err() {
+        fail!()
+    }
 }
 
 fn startfn() {
diff --git a/src/test/run-pass/trait-contravariant-self.rs b/src/test/run-pass/trait-contravariant-self.rs
index d8df5d5600c..e06e01b9e05 100644
--- a/src/test/run-pass/trait-contravariant-self.rs
+++ b/src/test/run-pass/trait-contravariant-self.rs
@@ -1,3 +1,5 @@
+// ignore-test
+
 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.