|
| 1 | +// Check that ordering of errors is correctly reported even with consts preceding types. |
| 2 | + |
| 3 | +#![feature(const_generics)] |
| 4 | +#![allow(incomplete_features)] |
| 5 | + |
| 6 | +struct Example<'a, const N: usize, T=f32> { |
| 7 | + s: &'a T, |
| 8 | +} |
| 9 | + |
| 10 | +type Consts = Example<3, 3, 3>; |
| 11 | +//~^ ERROR missing lifetime specifier |
| 12 | +//~| ERROR wrong number of const arguments |
| 13 | +type Types = Example<f32, f32, f32>; |
| 14 | +//~^ ERROR missing lifetime specifier |
| 15 | +//~| ERROR wrong number of const arguments |
| 16 | +//~| ERROR wrong number of type arguments |
| 17 | +type Lifetimes = Example<'static, 'static, 'static>; |
| 18 | +//~^ ERROR wrong number of const arguments |
| 19 | +//~| ERROR misplaced type arguments |
| 20 | +//~| wrong number of lifetime |
| 21 | + |
| 22 | +type LtConst1 = Example<'static, 3, 3>; |
| 23 | +//~^ ERROR wrong number of const arguments |
| 24 | +type LtConst2 = Example<3, 'static, 3>; |
| 25 | +//~^ ERROR wrong number of const arguments |
| 26 | +type LtConst3 = Example<3, 3, 'static>; |
| 27 | +//~^ ERROR misplaced type arguments |
| 28 | + |
| 29 | +type LtTy1 = Example<'static, f32, f32>; |
| 30 | +//~^ ERROR wrong number of const arguments |
| 31 | +//~| ERROR wrong number of type arguments |
| 32 | +type LtTy2 = Example<f32, 'static, f32>; |
| 33 | +//~^ ERROR wrong number of const arguments |
| 34 | +//~| ERROR wrong number of type arguments |
| 35 | +type LtTy3 = Example<f32, f32, 'static>; |
| 36 | +//~^ ERROR wrong number of const arguments |
| 37 | +//~| ERROR wrong number of type arguments |
| 38 | + |
| 39 | +type ConstTy1 = Example<3, f32, f32>; |
| 40 | +//~^ ERROR missing lifetime specifier |
| 41 | +//~| ERROR wrong number of type arguments |
| 42 | +type ConstTy2 = Example<f32, 3, f32>; |
| 43 | +//~^ ERROR missing lifetime specifier |
| 44 | +//~| ERROR wrong number of type arguments |
| 45 | +type ConstTy3 = Example<f32, f32, 3>; |
| 46 | +//~^ ERROR missing lifetime specifier |
| 47 | +//~| ERROR wrong number of type arguments |
| 48 | + |
| 49 | +type ConstLt1 = Example<3, 'static, 'static>; |
| 50 | +//~^ ERROR wrong number of lifetime |
| 51 | +type ConstLt2 = Example<'static, 3, 'static>; |
| 52 | +//~^ ERROR wrong number of lifetime |
| 53 | +type ConstLt3 = Example<'static, 'static, 3>; |
| 54 | +//~^ ERROR wrong number of lifetime |
| 55 | + |
| 56 | +type TyLt1 = Example<f32, 'static, 'static>; |
| 57 | +//~^ ERROR wrong number of lifetime |
| 58 | +//~| ERROR wrong number of const |
| 59 | +//~| ERROR misplaced type arguments |
| 60 | +type TyLt2 = Example<'static, f32, 'static>; |
| 61 | +//~^ ERROR wrong number of lifetime |
| 62 | +//~| ERROR wrong number of const |
| 63 | +//~| ERROR misplaced type arguments |
| 64 | +type TyLt3 = Example<'static, 'static, f32>; |
| 65 | +//~^ ERROR wrong number of const |
| 66 | +//~| ERROR wrong number of lifetime |
| 67 | + |
| 68 | +type TyConst1 = Example<f32, 3, 3>; |
| 69 | +//~^ ERROR missing lifetime specifier |
| 70 | +//~| ERROR wrong number of const |
| 71 | +//~| ERROR misplaced type arguments |
| 72 | +type TyConst2 = Example<3, f32, 3>; |
| 73 | +//~^ ERROR missing lifetime specifier |
| 74 | +//~| ERROR wrong number of const |
| 75 | +type TyConst3 = Example<3, 3, f32>; |
| 76 | +//~^ ERROR missing lifetime specifier |
| 77 | +//~| ERROR wrong number of const |
| 78 | +//~| ERROR misplaced type arguments |
| 79 | + |
| 80 | +type Intermixed1 = Example<'static, 3, f32>; // ok |
| 81 | + |
| 82 | + |
| 83 | +type Intermixed2 = Example<f32, 'static, 3>; |
| 84 | +//~^ ERROR type provided when a constant was expected |
| 85 | +type Intermixed3 = Example<3, f32, 'static>; |
| 86 | +//~^ ERROR constant provided when a lifetime |
| 87 | + |
| 88 | +fn main() {} |
0 commit comments