rust/src/test/ui/suggestions/issue-82566-2.rs
Ömer Sinan Ağacan 992b914b6b Recover from X<Y,Z> when parsing const expr
This adds recovery when in array type syntax user writes

    [X; Y<Z, ...>]

instead of

    [X; Y::<Z, ...>]

Fixes #82566

Note that whenever we parse an expression and know that the next token
cannot be `,`, we should be calling
check_mistyped_turbofish_with_multiple_type_params for this recovery.
Previously we only did this for statement parsing (e.g. `let x = f<a,
b>;`). We now also do it when parsing the length field in array type
syntax.
2021-02-27 14:06:57 +03:00

32 lines
780 B
Rust

struct Foo1<const N1: usize>;
struct Foo2<const N1: usize, const N2: usize>;
struct Foo3<const N1: usize, const N2: usize, const N3: usize>;
impl<const N1: usize> Foo1<N1> {
const SUM: usize = N1;
}
impl<const N1: usize, const N2: usize> Foo2<N1, N2> {
const SUM: usize = N1 + N2;
}
impl<const N1: usize, const N2: usize, const N3: usize> Foo3<N1, N2, N3> {
const SUM: usize = N1 + N2 + N3;
}
fn foo1() -> [(); Foo1<10>::SUM] { //~ ERROR: comparison operators cannot be chained
todo!()
}
fn foo2() -> [(); Foo2<10, 20>::SUM] {
//~^ ERROR: expected one of `.`, `?`, `]`, or an operator, found `,`
todo!()
}
fn foo3() -> [(); Foo3<10, 20, 30>::SUM] {
//~^ ERROR: expected one of `.`, `?`, `]`, or an operator, found `,`
todo!()
}
fn main() {}