reflect that type and const parameter can be intermixed

Also, add reference id
This commit is contained in:
Tshepang Mbambo 2025-10-29 19:52:26 +02:00
parent 292db4a13c
commit b92ed4e02b
2 changed files with 11 additions and 9 deletions

View file

@ -1,15 +1,17 @@
struct Bad<const N: usize, T> {
//@ reference: items.generics.syntax.decl-order
struct Good<const N: usize, T> {
arr: [u8; { N }],
another: T,
}
struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> {
struct Bad<const N: usize, 'a, T, 'b, const M: usize, U> {
//~^ ERROR lifetime parameters must be declared prior
a: &'a T,
b: &'b U,
}
fn main() {
let _: AlsoBad<7, 'static, u32, 'static, 17, u16>;
let _: Bad<7, 'static, u32, 'static, 17, u16>;
//~^ ERROR lifetime provided when a type was expected
}

View file

@ -1,14 +1,14 @@
error: lifetime parameters must be declared prior to type and const parameters
--> $DIR/argument_order.rs:6:32
--> $DIR/argument_order.rs:8:28
|
LL | struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> {
| -----------------^^-----^^-------------------- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, const N: usize, T, const M: usize, U>`
LL | struct Bad<const N: usize, 'a, T, 'b, const M: usize, U> {
| -----------------^^-----^^-------------------- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, const N: usize, T, const M: usize, U>`
error[E0747]: lifetime provided when a type was expected
--> $DIR/argument_order.rs:13:23
--> $DIR/argument_order.rs:15:19
|
LL | let _: AlsoBad<7, 'static, u32, 'static, 17, u16>;
| ^^^^^^^
LL | let _: Bad<7, 'static, u32, 'static, 17, u16>;
| ^^^^^^^
|
= note: lifetime arguments must be provided before type arguments
= help: reorder the arguments: lifetimes, then type and consts: `<'a, 'b, N, T, M, U>`