]> git.lizzy.rs Git - rust.git/commitdiff
Add tests
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Wed, 18 Jan 2017 14:41:57 +0000 (17:41 +0300)
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Tue, 24 Jan 2017 19:56:02 +0000 (22:56 +0300)
13 files changed:
src/test/compile-fail/impl-trait/no-trait.rs [new file with mode: 0644]
src/test/compile-fail/where-equality-constraints.rs [new file with mode: 0644]
src/test/compile-fail/where-lifetime-resolution.rs [new file with mode: 0644]
src/test/parse-fail/bounds-lifetime-1.rs [new file with mode: 0644]
src/test/parse-fail/bounds-lifetime-2.rs [new file with mode: 0644]
src/test/parse-fail/bounds-lifetime-3.rs [new file with mode: 0644]
src/test/parse-fail/bounds-lifetime-where-1.rs [new file with mode: 0644]
src/test/parse-fail/bounds-lifetime-where-2.rs [new file with mode: 0644]
src/test/parse-fail/bounds-lifetime-where.rs [new file with mode: 0644]
src/test/parse-fail/bounds-lifetime.rs [new file with mode: 0644]
src/test/parse-fail/bounds-type-where-1.rs [new file with mode: 0644]
src/test/parse-fail/bounds-type-where.rs [new file with mode: 0644]
src/test/parse-fail/bounds-type.rs [new file with mode: 0644]

diff --git a/src/test/compile-fail/impl-trait/no-trait.rs b/src/test/compile-fail/impl-trait/no-trait.rs
new file mode 100644 (file)
index 0000000..ce61c5b
--- /dev/null
@@ -0,0 +1,15 @@
+// Copyright 2017 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.
+
+#![feature(conservative_impl_trait)]
+
+fn f() -> impl 'static {} //~ ERROR at least one trait must be specified
+
+fn main() {}
diff --git a/src/test/compile-fail/where-equality-constraints.rs b/src/test/compile-fail/where-equality-constraints.rs
new file mode 100644 (file)
index 0000000..5b2fe29
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright 2017 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.
+
+fn f() where u8 = u16 {}
+//~^ ERROR equality constraints are not yet supported in where clauses
+fn g() where for<'a> &(u8,) == u16, {}
+//~^ ERROR equality constraints are not yet supported in where clauses
+
+fn main() {}
diff --git a/src/test/compile-fail/where-lifetime-resolution.rs b/src/test/compile-fail/where-lifetime-resolution.rs
new file mode 100644 (file)
index 0000000..f4c6842
--- /dev/null
@@ -0,0 +1,23 @@
+// Copyright 2017 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 Trait1 {}
+trait Trait2 {}
+
+fn f() where
+    for<'a> Trait1<'a>: Trait1<'a>, // OK
+    (for<'a> Trait1<'a>): Trait1<'a>,
+    //~^ ERROR use of undeclared lifetime name `'a`
+    for<'a> for<'b> Trait2<'a, 'b>: Trait2<'a, 'b>,
+    //~^ ERROR use of undeclared lifetime name `'b`
+    //~| ERROR nested quantification of lifetimes
+{}
+
+fn main() {}
diff --git a/src/test/parse-fail/bounds-lifetime-1.rs b/src/test/parse-fail/bounds-lifetime-1.rs
new file mode 100644 (file)
index 0000000..824d243
--- /dev/null
@@ -0,0 +1,15 @@
+// Copyright 2017 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.
+
+// compile-flags: -Z parse-only
+
+type A = for<'a 'b> fn(); //~ ERROR expected one of `,`, `:`, or `>`, found `'b`
+
+fn main() {}
diff --git a/src/test/parse-fail/bounds-lifetime-2.rs b/src/test/parse-fail/bounds-lifetime-2.rs
new file mode 100644 (file)
index 0000000..3c67dda
--- /dev/null
@@ -0,0 +1,15 @@
+// Copyright 2017 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.
+
+// compile-flags: -Z parse-only
+
+type A = for<'a + 'b> fn(); //~ ERROR expected one of `,`, `:`, or `>`, found `+`
+
+fn main() {}
diff --git a/src/test/parse-fail/bounds-lifetime-3.rs b/src/test/parse-fail/bounds-lifetime-3.rs
new file mode 100644 (file)
index 0000000..be7c197
--- /dev/null
@@ -0,0 +1,15 @@
+// Copyright 2017 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.
+
+// compile-flags: -Z parse-only
+
+type A = for<,> fn(); //~ ERROR expected `>`, found `,`
+
+fn main() {}
diff --git a/src/test/parse-fail/bounds-lifetime-where-1.rs b/src/test/parse-fail/bounds-lifetime-where-1.rs
new file mode 100644 (file)
index 0000000..aae9d72
--- /dev/null
@@ -0,0 +1,15 @@
+// Copyright 2017 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.
+
+// compile-flags: -Z parse-only
+
+type A where 'a; //~ ERROR expected `:`, found `;`
+
+fn main() {}
diff --git a/src/test/parse-fail/bounds-lifetime-where-2.rs b/src/test/parse-fail/bounds-lifetime-where-2.rs
new file mode 100644 (file)
index 0000000..97dcd5c
--- /dev/null
@@ -0,0 +1,15 @@
+// Copyright 2017 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.
+
+// compile-flags: -Z parse-only
+
+type A where , = u8; //~ ERROR expected `=`, found `,`
+
+fn main() {}
diff --git a/src/test/parse-fail/bounds-lifetime-where.rs b/src/test/parse-fail/bounds-lifetime-where.rs
new file mode 100644 (file)
index 0000000..f7f5644
--- /dev/null
@@ -0,0 +1,21 @@
+// Copyright 2017 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.
+
+// compile-flags: -Z parse-only
+
+type A where 'a: 'b + 'c = u8; // OK
+type A where 'a: 'b, = u8; // OK
+type A where 'a: = u8; // OK
+type A where 'a:, = u8; // OK
+type A where 'a: 'b + 'c = u8; // OK
+type A where = u8; // OK
+type A where 'a: 'b + = u8; //~ ERROR expected one of `,` or `=`, found `+`
+
+fn main() {}
diff --git a/src/test/parse-fail/bounds-lifetime.rs b/src/test/parse-fail/bounds-lifetime.rs
new file mode 100644 (file)
index 0000000..71547b5
--- /dev/null
@@ -0,0 +1,23 @@
+// Copyright 2017 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.
+
+// compile-flags: -Z parse-only -Z continue-parse-after-error
+
+type A = for<'a: 'b + 'c> fn(); // OK
+type A = for<'a: 'b,> fn(); // OK
+type A = for<'a:> fn(); // OK
+type A = for<'a:,> fn(); // OK
+type A = for<'a> fn(); // OK
+type A = for<> fn(); // OK
+
+type A = for<'a, T> fn(); //~ ERROR only lifetime parameters can be used in this context
+type A = for<'a: 'b +> fn(); //~ ERROR expected one of `,` or `>`, found `+`
+
+fn main() {}
diff --git a/src/test/parse-fail/bounds-type-where-1.rs b/src/test/parse-fail/bounds-type-where-1.rs
new file mode 100644 (file)
index 0000000..52b5035
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright 2017 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.
+
+// compile-flags: -Z parse-only
+
+type A where T, = u8;
+//~^ ERROR expected one of `!`, `(`, `+`, `::`, `:`, `<`, `==`, or `=`, found `,`
+
+fn main() {}
diff --git a/src/test/parse-fail/bounds-type-where.rs b/src/test/parse-fail/bounds-type-where.rs
new file mode 100644 (file)
index 0000000..789a093
--- /dev/null
@@ -0,0 +1,21 @@
+// Copyright 2017 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.
+
+// compile-flags: -Z parse-only
+
+type A where for<'a> for<'b> Trait1 + ?Trait2: 'a + Trait = u8; // OK
+type A where T: Trait, = u8; // OK
+type A where T: = u8; // OK
+type A where T:, = u8; // OK
+type A where T: Trait + Trait = u8; // OK
+type A where = u8; // OK
+type A where T: Trait + = u8; //~ ERROR expected one of `(`, `,`, `::`, `<`, or `=`, found `+`
+
+fn main() {}
diff --git a/src/test/parse-fail/bounds-type.rs b/src/test/parse-fail/bounds-type.rs
new file mode 100644 (file)
index 0000000..6e33942
--- /dev/null
@@ -0,0 +1,23 @@
+// Copyright 2017 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.
+
+// compile-flags: -Z parse-only -Z continue-parse-after-error
+
+struct S<
+    T: 'a + Tr, // OK
+    T: Tr + 'a, // OK
+    T: 'a, // OK
+    T:, // OK
+    T: ?for<'a: 'b + 'c> Trait, // OK
+    T: ?'a, //~ ERROR `?` may only modify trait bounds, not lifetime bounds
+    T: Tr +, //~ ERROR expected one of `(`, `,`, `::`, `<`, `=`, or `>`, found `+`
+>;
+
+fn main() {}