]> git.lizzy.rs Git - rust.git/blob - src/test/ui/rfc1598-generic-associated-types/parameter_number_and_kind.rs
Auto merge of #54720 - davidtwco:issue-51191, r=nikomatsakis
[rust.git] / src / test / ui / rfc1598-generic-associated-types / parameter_number_and_kind.rs
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 //~^ WARNING the feature `generic_associated_types` is incomplete
13 #![feature(associated_type_defaults)]
14
15 // FIXME(#44265): "lifetime parameters are not allowed on this type" errors will be addressed in a
16 // follow-up PR.
17
18 // FIXME(#44265): Update expected errors once E110 is resolved, now does not get past `trait Foo`.
19
20 trait Foo {
21     type A<'a>;
22     type B<'a, 'b>;
23     type C;
24     type D<T>;
25     type E<'a, T>;
26     // Test parameters in default values
27     type FOk<T> = Self::E<'static, T>;
28     //~^ ERROR type parameters are not allowed on this type [E0109]
29     //~| ERROR lifetime parameters are not allowed on this type [E0110]
30     type FErr1 = Self::E<'static, 'static>; // Error
31     //~^ ERROR lifetime parameters are not allowed on this type [E0110]
32     type FErr2<T> = Self::E<'static, T, u32>; // Error
33     //~^ ERROR type parameters are not allowed on this type [E0109]
34     //~| ERROR lifetime parameters are not allowed on this type [E0110]
35 }
36
37 struct Fooy;
38
39 impl Foo for Fooy {
40     type A = u32; // Error: parameter expected
41     type B<'a, T> = Vec<T>; // Error: lifetime param expected
42     type C<'a> = u32; // Error: no param expected
43     type D<'a> = u32; // Error: type param expected
44     type E<T, U> = u32; // Error: lifetime expected as the first param
45 }
46
47 struct Fooer;
48
49 impl Foo for Fooer {
50     type A<T> = u32; // Error: lifetime parameter expected
51     type B<'a> = u32; // Error: another lifetime param expected
52     type C<T> = T; // Error: no param expected
53     type D<'b, T> = u32; // Error: unexpected lifetime param
54     type E<'a, 'b> = u32; // Error: type expected as the second param
55 }
56
57 fn main() {}