about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-04-11 18:31:59 +0000
committerbors <bors@rust-lang.org>2015-04-11 18:31:59 +0000
commit6790b0e51967b1487728d155e0800a1ed03a30d3 (patch)
tree51c11cb951751d408b68c401a487c5f2fbe26157 /src/test
parent67a8f61730418768f07d8ed0f9735a31d0c5d84d (diff)
parent0a2885ad944aa1a5f60a72a7551b1b45367637f6 (diff)
downloadrust-6790b0e51967b1487728d155e0800a1ed03a30d3.tar.gz
rust-6790b0e51967b1487728d155e0800a1ed03a30d3.zip
Auto merge of #24328 - Manishearth:rollup, r=Manishearth
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/borrowck-escaping-closure-error-1.rs25
-rw-r--r--src/test/compile-fail/borrowck-escaping-closure-error-2.rs25
-rw-r--r--src/test/compile-fail/coherence-overlap-all-t-and-tuple.rs28
-rw-r--r--src/test/compile-fail/issue-16747.rs4
-rw-r--r--src/test/compile-fail/issue-20772.rs15
-rw-r--r--src/test/compile-fail/issue-20939.rs16
-rw-r--r--src/test/compile-fail/issue-21950.rs20
-rw-r--r--src/test/compile-fail/issue-22034.rs19
-rw-r--r--src/test/compile-fail/issue-4335.rs2
-rw-r--r--src/test/compile-fail/regions-nested-fns-2.rs2
-rw-r--r--src/test/run-pass/issue-19097.rs22
11 files changed, 174 insertions, 4 deletions
diff --git a/src/test/compile-fail/borrowck-escaping-closure-error-1.rs b/src/test/compile-fail/borrowck-escaping-closure-error-1.rs
new file mode 100644
index 00000000000..87e40df7663
--- /dev/null
+++ b/src/test/compile-fail/borrowck-escaping-closure-error-1.rs
@@ -0,0 +1,25 @@
+// Copyright 2015 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.
+
+use std::thread::spawn;
+
+// Test that we give a custom error (E0373) for the case where a
+// closure is escaping current frame, and offer a suggested code edit.
+// I refrained from including the precise message here, but the
+// original text as of the time of this writing is:
+//
+//    closure may outlive the current function, but it borrows `books`,
+//    which is owned by the current function
+
+fn main() {
+    let mut books = vec![1,2,3];
+    spawn(|| books.push(4));
+    //~^ ERROR E0373
+}
diff --git a/src/test/compile-fail/borrowck-escaping-closure-error-2.rs b/src/test/compile-fail/borrowck-escaping-closure-error-2.rs
new file mode 100644
index 00000000000..67700be890b
--- /dev/null
+++ b/src/test/compile-fail/borrowck-escaping-closure-error-2.rs
@@ -0,0 +1,25 @@
+// Copyright 2015 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.
+
+// Test that we give a custom error (E0373) for the case where a
+// closure is escaping current frame, and offer a suggested code edit.
+// I refrained from including the precise message here, but the
+// original text as of the time of this writing is:
+//
+//    closure may outlive the current function, but it borrows `books`,
+//    which is owned by the current function
+
+fn foo<'a>(x: &'a i32) -> Box<FnMut()+'a> {
+    let mut books = vec![1,2,3];
+    Box::new(|| books.push(4))
+    //~^ ERROR E0373
+}
+
+fn main() { }
diff --git a/src/test/compile-fail/coherence-overlap-all-t-and-tuple.rs b/src/test/compile-fail/coherence-overlap-all-t-and-tuple.rs
new file mode 100644
index 00000000000..3fd635b3d61
--- /dev/null
+++ b/src/test/compile-fail/coherence-overlap-all-t-and-tuple.rs
@@ -0,0 +1,28 @@
+// Copyright 2015 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.
+
+// Check that we detect an overlap here in the case where:
+//
+//    for some type X:
+//      T = (X,)
+//      T11 = X, U11 = X
+//
+// Seems pretty basic, but then there was issue #24241. :)
+
+trait From<U> {
+}
+
+impl <T> From<T> for T { //~ ERROR E0119
+}
+
+impl <T11, U11> From<(U11,)> for (T11,) {
+}
+
+fn main() { }
diff --git a/src/test/compile-fail/issue-16747.rs b/src/test/compile-fail/issue-16747.rs
index 64334fe4392..b4abef0bd28 100644
--- a/src/test/compile-fail/issue-16747.rs
+++ b/src/test/compile-fail/issue-16747.rs
@@ -18,10 +18,10 @@ trait Collection { fn len(&self) -> usize; }
 
 struct List<'a, T: ListItem<'a>> {
 //~^ ERROR the parameter type `T` may not live long enough
-//~^^ NOTE ...so that the reference type `&'a [T]` does not outlive the data it points at
+//~| HELP consider adding an explicit lifetime bound
+//~| NOTE ...so that the reference type `&'a [T]` does not outlive the data it points at
     slice: &'a [T]
 }
-//~^ HELP consider adding an explicit lifetime bound
 impl<'a, T: ListItem<'a>> Collection for List<'a, T> {
     fn len(&self) -> usize {
         0
diff --git a/src/test/compile-fail/issue-20772.rs b/src/test/compile-fail/issue-20772.rs
new file mode 100644
index 00000000000..44c92f946f0
--- /dev/null
+++ b/src/test/compile-fail/issue-20772.rs
@@ -0,0 +1,15 @@
+// Copyright 2015 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.
+
+trait T : Iterator<Item=Self::Item>
+//~^ ERROR unsupported cyclic reference between types/traits detected
+{}
+
+fn main() {}
diff --git a/src/test/compile-fail/issue-20939.rs b/src/test/compile-fail/issue-20939.rs
new file mode 100644
index 00000000000..88197166ee0
--- /dev/null
+++ b/src/test/compile-fail/issue-20939.rs
@@ -0,0 +1,16 @@
+// Copyright 2015 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.
+
+trait Foo {}
+
+impl<'a> Foo for Foo+'a {}
+//~^ ERROR the object type `Foo + 'a` automatically implements the trait `Foo`
+
+fn main() {}
diff --git a/src/test/compile-fail/issue-21950.rs b/src/test/compile-fail/issue-21950.rs
new file mode 100644
index 00000000000..315a4cd90c5
--- /dev/null
+++ b/src/test/compile-fail/issue-21950.rs
@@ -0,0 +1,20 @@
+// Copyright 2015 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.
+
+// ignore-tidy-linelength
+
+use std::ops::Add;
+
+fn main() {
+    let x = &10 as
+            //~^ ERROR the value of the associated type `Output` (from the trait `core::ops::Add`) must be specified
+            &Add;
+            //~^ ERROR the type parameter `RHS` must be explicitly specified in an object type because its default value `Self` references the type `Self`
+}
diff --git a/src/test/compile-fail/issue-22034.rs b/src/test/compile-fail/issue-22034.rs
new file mode 100644
index 00000000000..004e33b76a9
--- /dev/null
+++ b/src/test/compile-fail/issue-22034.rs
@@ -0,0 +1,19 @@
+// Copyright 2015 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 libc;
+
+fn main() {
+    let foo: *mut libc::c_void;
+    let cb: &mut Fn() = unsafe {
+        &mut *(foo as *mut Fn())
+        //~^ ERROR use of possibly uninitialized variable: `foo`
+    };
+}
diff --git a/src/test/compile-fail/issue-4335.rs b/src/test/compile-fail/issue-4335.rs
index 55a793f7480..0089bff3e8f 100644
--- a/src/test/compile-fail/issue-4335.rs
+++ b/src/test/compile-fail/issue-4335.rs
@@ -15,7 +15,7 @@ fn id<T>(t: T) -> T { t }
 fn f<'r, T>(v: &'r T) -> Box<FnMut() -> T + 'r> {
     // FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
     id(Box::new(|| *v))
-        //~^ ERROR `v` does not live long enough
+        //~^ ERROR E0373
         //~| ERROR cannot move out of borrowed content
 }
 
diff --git a/src/test/compile-fail/regions-nested-fns-2.rs b/src/test/compile-fail/regions-nested-fns-2.rs
index bdebadb2832..948dc8cd219 100644
--- a/src/test/compile-fail/regions-nested-fns-2.rs
+++ b/src/test/compile-fail/regions-nested-fns-2.rs
@@ -13,7 +13,7 @@ fn ignore<F>(_f: F) where F: for<'z> FnOnce(&'z isize) -> &'z isize {}
 fn nested() {
     let y = 3;
     ignore(
-        |z| { //~ ERROR `y` does not live long enough
+        |z| { //~ ERROR E0373
             if false { &y } else { z }
         });
 }
diff --git a/src/test/run-pass/issue-19097.rs b/src/test/run-pass/issue-19097.rs
new file mode 100644
index 00000000000..ca4b72f9e5b
--- /dev/null
+++ b/src/test/run-pass/issue-19097.rs
@@ -0,0 +1,22 @@
+// 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.
+
+// regression test for #19097
+
+struct Foo<T>(T);
+
+impl<'a, T> Foo<&'a T> {
+    fn foo(&self) {}
+}
+impl<'a, T> Foo<&'a mut T> {
+    fn foo(&self) {}
+}
+
+fn main() {}