|
| 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() {} |
0 commit comments