-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for GAT parameter number and kindness
- Loading branch information
Showing
2 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
src/test/ui/rfc1598-generic-associated-types/parameter_number_and_kind.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright 2012 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(generic_associated_types)] | ||
#![feature(associated_type_defaults)] | ||
|
||
//FIXME(#44265): "lifetime parameters are not allowed on this type" errors will be addressed in a | ||
//follow-up PR | ||
|
||
//FIXME(#44265): Update expected errors once E110 is resolved, now does not get past `trait Foo` | ||
|
||
trait Foo { | ||
type A<'a>; | ||
type B<'a, 'b>; | ||
type C; | ||
type D<T>; | ||
type E<'a, T>; | ||
// Test parameters in default values | ||
type FOk<T> = Self::E<'static, T>; | ||
//~^ ERROR type parameters are not allowed on this type [E0109] | ||
//~| ERROR lifetime parameters are not allowed on this type [E0110] | ||
type FErr1 = Self::E<'static, 'static>; // Error | ||
//~^ ERROR lifetime parameters are not allowed on this type [E0110] | ||
type FErr2<T> = Self::E<'static, T, u32>; // Error | ||
//~^ ERROR type parameters are not allowed on this type [E0109] | ||
//~| ERROR lifetime parameters are not allowed on this type [E0110] | ||
} | ||
|
||
struct Fooy; | ||
|
||
impl Foo for Fooy { | ||
type A = u32; // Error: parameter expected | ||
type B<'a, T> = Vec<T>; // Error: lifetime param expected | ||
type C<'a> = u32; // Error: no param expected | ||
type D<'a> = u32; // Error: type param expected | ||
type E<T, U> = u32; // Error: lifetime expected as the first param | ||
} | ||
|
||
struct Fooer; | ||
|
||
impl Foo for Fooer { | ||
type A<T> = u32; // Error: lifetime parameter expected | ||
type B<'a> = u32; // Error: another lifetime param expected | ||
type C<T> = T; // Error: no param expected | ||
type D<'b, T> = u32; // Error: unexpected lifetime param | ||
type E<'a, 'b> = u32; // Error: type expected as the second param | ||
} | ||
|
||
fn main() {} |
34 changes: 34 additions & 0 deletions
34
src/test/ui/rfc1598-generic-associated-types/parameter_number_and_kind.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
error[E0109]: type parameters are not allowed on this type | ||
--> $DIR/parameter_number_and_kind.rs:26:36 | ||
| | ||
LL | type FOk<T> = Self::E<'static, T>; | ||
| ^ type parameter not allowed | ||
|
||
error[E0110]: lifetime parameters are not allowed on this type | ||
--> $DIR/parameter_number_and_kind.rs:26:27 | ||
| | ||
LL | type FOk<T> = Self::E<'static, T>; | ||
| ^^^^^^^ lifetime parameter not allowed on this type | ||
|
||
error[E0110]: lifetime parameters are not allowed on this type | ||
--> $DIR/parameter_number_and_kind.rs:29:26 | ||
| | ||
LL | type FErr1 = Self::E<'static, 'static>; // Error | ||
| ^^^^^^^ lifetime parameter not allowed on this type | ||
|
||
error[E0109]: type parameters are not allowed on this type | ||
--> $DIR/parameter_number_and_kind.rs:31:38 | ||
| | ||
LL | type FErr2<T> = Self::E<'static, T, u32>; // Error | ||
| ^ type parameter not allowed | ||
|
||
error[E0110]: lifetime parameters are not allowed on this type | ||
--> $DIR/parameter_number_and_kind.rs:31:29 | ||
| | ||
LL | type FErr2<T> = Self::E<'static, T, u32>; // Error | ||
| ^^^^^^^ lifetime parameter not allowed on this type | ||
|
||
error: aborting due to 5 previous errors | ||
|
||
Some errors occurred: E0109, E0110. | ||
For more information about an error, try `rustc --explain E0109`. |