about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-11-06 13:31:18 -0800
committerAlex Crichton <alex@alexcrichton.com>2014-11-06 13:31:18 -0800
commit76d2abe0e7fb33ed41137a0c99fbbc2905d8ca91 (patch)
tree1ea979f4b18b619db872eded0bbdb7971e6cc379 /src/test
parent08ddfc10e4170ac5f4522a71c0d1aea8cf799f29 (diff)
parentd0fa4c6239accc08aae11d9db3e13d4153add432 (diff)
downloadrust-76d2abe0e7fb33ed41137a0c99fbbc2905d8ca91.tar.gz
rust-76d2abe0e7fb33ed41137a0c99fbbc2905d8ca91.zip
rollup merge of #18630 : nikomatsakis/purge-the-bars
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/issue-14092.rs2
-rw-r--r--src/test/compile-fail/issue-18423.rs18
-rw-r--r--src/test/compile-fail/unboxed-closure-sugar-default.rs37
-rw-r--r--src/test/compile-fail/unboxed-closure-sugar-equiv.rs39
-rw-r--r--src/test/compile-fail/unboxed-closure-sugar-nonexistent-trait.rs2
-rw-r--r--src/test/compile-fail/unboxed-closure-sugar-region.rs45
-rw-r--r--src/test/compile-fail/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs16
-rw-r--r--src/test/compile-fail/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs16
-rw-r--r--src/test/compile-fail/unboxed-closure-sugar-wrong-number-number-type-parameters.rs16
-rw-r--r--src/test/compile-fail/unboxed-closure-sugar-wrong-trait.rs2
-rw-r--r--src/test/run-pass/unboxed-closures-manual-impl.rs2
-rw-r--r--src/test/run-pass/unboxed-closures-prelude.rs2
-rw-r--r--src/test/run-pass/unboxed-closures-sugar-1.rs34
-rw-r--r--src/test/run-pass/unboxed-closures-sugar-object.rs34
-rw-r--r--src/test/run-pass/unboxed-closures-unboxing-shim.rs2
15 files changed, 261 insertions, 6 deletions
diff --git a/src/test/compile-fail/issue-14092.rs b/src/test/compile-fail/issue-14092.rs
index 4d663d00fb2..0ab37a88826 100644
--- a/src/test/compile-fail/issue-14092.rs
+++ b/src/test/compile-fail/issue-14092.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn fn1(0: Box) {} //~ ERROR: not enough type parameters supplied to `Box<T>`
+fn fn1(0: Box) {} //~ ERROR: wrong number of type arguments: expected 1, found 0
 
 fn main() {}
 
diff --git a/src/test/compile-fail/issue-18423.rs b/src/test/compile-fail/issue-18423.rs
new file mode 100644
index 00000000000..63b110b5579
--- /dev/null
+++ b/src/test/compile-fail/issue-18423.rs
@@ -0,0 +1,18 @@
+// 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.
+
+// Test that `Box` cannot be used with a lifetime parameter.
+
+struct Foo<'a> {
+    x: Box<'a, int> //~ ERROR wrong number of lifetime parameters
+}
+
+pub fn main() {
+}
diff --git a/src/test/compile-fail/unboxed-closure-sugar-default.rs b/src/test/compile-fail/unboxed-closure-sugar-default.rs
new file mode 100644
index 00000000000..9866a200045
--- /dev/null
+++ b/src/test/compile-fail/unboxed-closure-sugar-default.rs
@@ -0,0 +1,37 @@
+// 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.
+
+// Test interaction between unboxed closure sugar and default type
+// parameters (should be exactly as if angle brackets were used).
+
+#![feature(default_type_params)]
+#![allow(dead_code)]
+
+struct Foo<T,U,V=T> {
+    t: T, u: U
+}
+
+trait Eq<X> { }
+impl<X> Eq<X> for X { }
+fn eq<A,B:Eq<A>>() { }
+
+fn test<'a,'b>() {
+    // Parens are equivalent to omitting default in angle.
+    eq::< Foo<(int,),()>,               Foo(int)                      >();
+
+    // In angle version, we supply something other than the default
+    eq::< Foo<(int,),(),int>,           Foo(int)                      >();
+    //~^ ERROR not implemented
+
+    // Supply default explicitly.
+    eq::< Foo<(int,),(),(int,)>,        Foo(int)                      >();
+}
+
+fn main() { }
diff --git a/src/test/compile-fail/unboxed-closure-sugar-equiv.rs b/src/test/compile-fail/unboxed-closure-sugar-equiv.rs
new file mode 100644
index 00000000000..c38010c1ee2
--- /dev/null
+++ b/src/test/compile-fail/unboxed-closure-sugar-equiv.rs
@@ -0,0 +1,39 @@
+// 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.
+
+// Test that the unboxed closure sugar can be used with an arbitrary
+// struct type and that it is equivalent to the same syntax using
+// angle brackets. This test covers only simple types and in
+// particular doesn't test bound regions.
+
+#![allow(dead_code)]
+
+struct Foo<T,U> {
+    t: T, u: U
+}
+
+trait Eq<X> { }
+impl<X> Eq<X> for X { }
+fn eq<A,B:Eq<A>>() { }
+
+fn test<'a,'b>() {
+    // No errors expected:
+    eq::< Foo<(),()>,                   Foo()                         >();
+    eq::< Foo<(int,),()>,               Foo(int)                      >();
+    eq::< Foo<(int,uint),()>,           Foo(int,uint)                 >();
+    eq::< Foo<(int,uint),uint>,         Foo(int,uint) -> uint         >();
+    eq::< Foo<(&'a int,&'b uint),uint>, Foo(&'a int,&'b uint) -> uint >();
+
+    // Errors expected:
+    eq::< Foo<(),()>,                   Foo(char)                     >();
+    //~^ ERROR not implemented
+}
+
+fn main() { }
diff --git a/src/test/compile-fail/unboxed-closure-sugar-nonexistent-trait.rs b/src/test/compile-fail/unboxed-closure-sugar-nonexistent-trait.rs
index f51160a1b23..d89c3802508 100644
--- a/src/test/compile-fail/unboxed-closure-sugar-nonexistent-trait.rs
+++ b/src/test/compile-fail/unboxed-closure-sugar-nonexistent-trait.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn f<F:Nonexist(int) -> int>(x: F) {} //~ ERROR unresolved trait
+fn f<F:Nonexist(int) -> int>(x: F) {} //~ ERROR nonexistent trait `Nonexist`
 
 type Typedef = int;
 
diff --git a/src/test/compile-fail/unboxed-closure-sugar-region.rs b/src/test/compile-fail/unboxed-closure-sugar-region.rs
new file mode 100644
index 00000000000..962e233dea6
--- /dev/null
+++ b/src/test/compile-fail/unboxed-closure-sugar-region.rs
@@ -0,0 +1,45 @@
+// 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.
+
+// Test interaction between unboxed closure sugar and region
+// parameters (should be exactly as if angle brackets were used
+// and regions omitted).
+
+#![feature(default_type_params)]
+#![allow(dead_code)]
+
+use std::kinds::marker;
+
+struct Foo<'a,T,U> {
+    t: T,
+    u: U,
+    m: marker::InvariantLifetime<'a>
+}
+
+trait Eq<X> { }
+impl<X> Eq<X> for X { }
+fn eq<A,B:Eq<A>>() { }
+fn same_type<A,B:Eq<A>>(a: A, b: B) { }
+
+fn test<'a,'b>() {
+    // Parens are equivalent to omitting default in angle.
+    eq::< Foo<(int,),()>,               Foo(int)                      >();
+
+    // Here we specify 'static explicitly in angle-bracket version.
+    // Parenthesized winds up getting inferred.
+    eq::< Foo<'static, (int,),()>,               Foo(int)                      >();
+}
+
+fn test2(x: Foo<(int,),()>, y: Foo(int)) {
+    // Here, the omitted lifetimes are expanded to distinct things.
+    same_type(x, y) //~ ERROR cannot infer
+}
+
+fn main() { }
diff --git a/src/test/compile-fail/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs b/src/test/compile-fail/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs
new file mode 100644
index 00000000000..e122b87b1e0
--- /dev/null
+++ b/src/test/compile-fail/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs
@@ -0,0 +1,16 @@
+// 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.
+
+struct One<A>;
+
+fn foo(_: One()) //~ ERROR wrong number of type arguments
+{}
+
+fn main() { }
diff --git a/src/test/compile-fail/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs b/src/test/compile-fail/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs
new file mode 100644
index 00000000000..7a66abb39df
--- /dev/null
+++ b/src/test/compile-fail/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs
@@ -0,0 +1,16 @@
+// 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.
+
+struct Three<A,B,C>;
+
+fn foo(_: Three()) //~ ERROR wrong number of type arguments
+{}
+
+fn main() { }
diff --git a/src/test/compile-fail/unboxed-closure-sugar-wrong-number-number-type-parameters.rs b/src/test/compile-fail/unboxed-closure-sugar-wrong-number-number-type-parameters.rs
new file mode 100644
index 00000000000..e265a3d56b8
--- /dev/null
+++ b/src/test/compile-fail/unboxed-closure-sugar-wrong-number-number-type-parameters.rs
@@ -0,0 +1,16 @@
+// 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.
+
+struct Zero;
+
+fn foo(_: Zero()) //~ ERROR wrong number of type arguments
+{}
+
+fn main() { }
diff --git a/src/test/compile-fail/unboxed-closure-sugar-wrong-trait.rs b/src/test/compile-fail/unboxed-closure-sugar-wrong-trait.rs
index a751ae1c518..1394f8fa65f 100644
--- a/src/test/compile-fail/unboxed-closure-sugar-wrong-trait.rs
+++ b/src/test/compile-fail/unboxed-closure-sugar-wrong-trait.rs
@@ -11,7 +11,7 @@
 trait Trait {}
 
 fn f<F:Trait(int) -> int>(x: F) {}
-//~^ ERROR unboxed function trait must be one of `Fn`, `FnMut`, or `FnOnce`
+//~^ ERROR wrong number of type arguments: expected 0, found 2
 
 fn main() {}
 
diff --git a/src/test/run-pass/unboxed-closures-manual-impl.rs b/src/test/run-pass/unboxed-closures-manual-impl.rs
index b0947f46a86..8f6cfe04997 100644
--- a/src/test/run-pass/unboxed-closures-manual-impl.rs
+++ b/src/test/run-pass/unboxed-closures-manual-impl.rs
@@ -25,7 +25,7 @@ fn call_it<F:FnMut(int)->int>(mut f: F, x: int) -> int {
     f.call_mut((x,)) + 3
 }
 
-fn call_box(f: &mut |&mut: int|->int, x: int) -> int {
+fn call_box(f: &mut FnMut(int) -> int, x: int) -> int {
     f.call_mut((x,)) + 3
 }
 
diff --git a/src/test/run-pass/unboxed-closures-prelude.rs b/src/test/run-pass/unboxed-closures-prelude.rs
index 4226ed427e7..f9d2ba02123 100644
--- a/src/test/run-pass/unboxed-closures-prelude.rs
+++ b/src/test/run-pass/unboxed-closures-prelude.rs
@@ -13,7 +13,7 @@
 #![feature(unboxed_closures, unboxed_closure_sugar)]
 
 fn main() {
-    let task: Box<|: int| -> int> = box |: x| x;
+    let task: Box<FnOnce(int) -> int> = box |: x| x;
     task.call_once((0i, ));
 }
 
diff --git a/src/test/run-pass/unboxed-closures-sugar-1.rs b/src/test/run-pass/unboxed-closures-sugar-1.rs
new file mode 100644
index 00000000000..b358e7ce288
--- /dev/null
+++ b/src/test/run-pass/unboxed-closures-sugar-1.rs
@@ -0,0 +1,34 @@
+// 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.
+
+// Test that the unboxed closure sugar can be used with an arbitrary
+// struct type and that it is equivalent to the same syntax using
+// angle brackets. This test covers only simple types and in
+// particular doesn't test bound regions.
+
+#![allow(dead_code)]
+
+struct Foo<T,U> {
+    t: T, u: U
+}
+
+trait Eq<X> { }
+impl<X> Eq<X> for X { }
+fn eq<A,B:Eq<A>>() { }
+
+fn test<'a,'b>() {
+    eq::< Foo<(),()>,                   Foo()                         >();
+    eq::< Foo<(int,),()>,               Foo(int)                      >();
+    eq::< Foo<(int,uint),()>,           Foo(int,uint)                 >();
+    eq::< Foo<(int,uint),uint>,         Foo(int,uint) -> uint         >();
+    eq::< Foo<(&'a int,&'b uint),uint>, Foo(&'a int,&'b uint) -> uint >();
+}
+
+fn main() { }
diff --git a/src/test/run-pass/unboxed-closures-sugar-object.rs b/src/test/run-pass/unboxed-closures-sugar-object.rs
new file mode 100644
index 00000000000..3b38f72432f
--- /dev/null
+++ b/src/test/run-pass/unboxed-closures-sugar-object.rs
@@ -0,0 +1,34 @@
+// 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.
+
+// Test unboxed closure sugar used in object types.
+
+#![allow(dead_code)]
+
+struct Foo<T,U> {
+    t: T, u: U
+}
+
+trait Getter<A,R> {
+    fn get(&self, arg: A) -> R;
+}
+
+struct Identity;
+impl<X> Getter<X,X> for Identity {
+    fn get(&self, arg: X) -> X {
+        arg
+    }
+}
+
+fn main() {
+    let x: &Getter(int) -> (int,) = &Identity;
+    let (y,) = x.get((22,));
+    assert_eq!(y, 22);
+}
diff --git a/src/test/run-pass/unboxed-closures-unboxing-shim.rs b/src/test/run-pass/unboxed-closures-unboxing-shim.rs
index 0a7baa3ba36..426352cadd8 100644
--- a/src/test/run-pass/unboxed-closures-unboxing-shim.rs
+++ b/src/test/run-pass/unboxed-closures-unboxing-shim.rs
@@ -13,7 +13,7 @@
 use std::ops::FnOnce;
 
 fn main() {
-    let task: Box<|: int| -> int> = box |: x| x;
+    let task: Box<FnOnce(int) -> int> = box |: x| x;
     assert!(task.call_once((1234i,)) == 1234i);
 }