Skip to content

Commit 0617b92

Browse files
committed
Add tests for GAT parameter number and kindness
1 parent a66a011 commit 0617b92

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(generic_associated_types)]
12+
#![feature(associated_type_defaults)]
13+
14+
//FIXME(#44265): "lifetime parameters are not allowed on this type" errors will be addressed in a
15+
//follow-up PR
16+
17+
//FIXME(#44265): Update expected errors once E110 is resolved, now does not get past `trait Foo`
18+
19+
trait Foo {
20+
type A<'a>;
21+
type B<'a, 'b>;
22+
type C;
23+
type D<T>;
24+
type E<'a, T>;
25+
// Test parameters in default values
26+
type FOk<T> = Self::E<'static, T>;
27+
//~^ ERROR type parameters are not allowed on this type [E0109]
28+
//~| ERROR lifetime parameters are not allowed on this type [E0110]
29+
type FErr1 = Self::E<'static, 'static>; // Error
30+
//~^ ERROR lifetime parameters are not allowed on this type [E0110]
31+
type FErr2<T> = Self::E<'static, T, u32>; // Error
32+
//~^ ERROR type parameters are not allowed on this type [E0109]
33+
//~| ERROR lifetime parameters are not allowed on this type [E0110]
34+
}
35+
36+
struct Fooy;
37+
38+
impl Foo for Fooy {
39+
type A = u32; // Error: parameter expected
40+
type B<'a, T> = Vec<T>; // Error: lifetime param expected
41+
type C<'a> = u32; // Error: no param expected
42+
type D<'a> = u32; // Error: type param expected
43+
type E<T, U> = u32; // Error: lifetime expected as the first param
44+
}
45+
46+
struct Fooer;
47+
48+
impl Foo for Fooer {
49+
type A<T> = u32; // Error: lifetime parameter expected
50+
type B<'a> = u32; // Error: another lifetime param expected
51+
type C<T> = T; // Error: no param expected
52+
type D<'b, T> = u32; // Error: unexpected lifetime param
53+
type E<'a, 'b> = u32; // Error: type expected as the second param
54+
}
55+
56+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
error[E0109]: type parameters are not allowed on this type
2+
--> $DIR/parameter_number_and_kind.rs:26:36
3+
|
4+
LL | type FOk<T> = Self::E<'static, T>;
5+
| ^ type parameter not allowed
6+
7+
error[E0110]: lifetime parameters are not allowed on this type
8+
--> $DIR/parameter_number_and_kind.rs:26:27
9+
|
10+
LL | type FOk<T> = Self::E<'static, T>;
11+
| ^^^^^^^ lifetime parameter not allowed on this type
12+
13+
error[E0110]: lifetime parameters are not allowed on this type
14+
--> $DIR/parameter_number_and_kind.rs:29:26
15+
|
16+
LL | type FErr1 = Self::E<'static, 'static>; // Error
17+
| ^^^^^^^ lifetime parameter not allowed on this type
18+
19+
error[E0109]: type parameters are not allowed on this type
20+
--> $DIR/parameter_number_and_kind.rs:31:38
21+
|
22+
LL | type FErr2<T> = Self::E<'static, T, u32>; // Error
23+
| ^ type parameter not allowed
24+
25+
error[E0110]: lifetime parameters are not allowed on this type
26+
--> $DIR/parameter_number_and_kind.rs:31:29
27+
|
28+
LL | type FErr2<T> = Self::E<'static, T, u32>; // Error
29+
| ^^^^^^^ lifetime parameter not allowed on this type
30+
31+
error: aborting due to 5 previous errors
32+
33+
Some errors occurred: E0109, E0110.
34+
For more information about an error, try `rustc --explain E0109`.

0 commit comments

Comments
 (0)