Add tests
This commit is contained in:
parent
b795abeb1d
commit
a8f5047430
15
src/test/compile-fail/impl-trait/no-trait.rs
Normal file
15
src/test/compile-fail/impl-trait/no-trait.rs
Normal file
@ -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() {}
|
16
src/test/compile-fail/where-equality-constraints.rs
Normal file
16
src/test/compile-fail/where-equality-constraints.rs
Normal file
@ -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() {}
|
23
src/test/compile-fail/where-lifetime-resolution.rs
Normal file
23
src/test/compile-fail/where-lifetime-resolution.rs
Normal file
@ -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() {}
|
15
src/test/parse-fail/bounds-lifetime-1.rs
Normal file
15
src/test/parse-fail/bounds-lifetime-1.rs
Normal file
@ -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() {}
|
15
src/test/parse-fail/bounds-lifetime-2.rs
Normal file
15
src/test/parse-fail/bounds-lifetime-2.rs
Normal file
@ -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() {}
|
15
src/test/parse-fail/bounds-lifetime-3.rs
Normal file
15
src/test/parse-fail/bounds-lifetime-3.rs
Normal file
@ -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() {}
|
15
src/test/parse-fail/bounds-lifetime-where-1.rs
Normal file
15
src/test/parse-fail/bounds-lifetime-where-1.rs
Normal file
@ -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() {}
|
15
src/test/parse-fail/bounds-lifetime-where-2.rs
Normal file
15
src/test/parse-fail/bounds-lifetime-where-2.rs
Normal file
@ -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() {}
|
21
src/test/parse-fail/bounds-lifetime-where.rs
Normal file
21
src/test/parse-fail/bounds-lifetime-where.rs
Normal file
@ -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() {}
|
23
src/test/parse-fail/bounds-lifetime.rs
Normal file
23
src/test/parse-fail/bounds-lifetime.rs
Normal file
@ -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() {}
|
16
src/test/parse-fail/bounds-type-where-1.rs
Normal file
16
src/test/parse-fail/bounds-type-where-1.rs
Normal file
@ -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() {}
|
21
src/test/parse-fail/bounds-type-where.rs
Normal file
21
src/test/parse-fail/bounds-type-where.rs
Normal file
@ -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() {}
|
23
src/test/parse-fail/bounds-type.rs
Normal file
23
src/test/parse-fail/bounds-type.rs
Normal file
@ -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() {}
|
Loading…
Reference in New Issue
Block a user