rust/src/test/ui/suggestions/issue-82566-1.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

22 lines
520 B
Rust

struct T1<const X1: usize>;
struct T2<const X1: usize, const X2: usize>;
struct T3<const X1: usize, const X2: usize, const X3: usize>;
impl T1<1> {
const C: () = ();
}
impl T2<1, 2> {
const C: () = ();
}
impl T3<1, 2, 3> {
const C: () = ();
}
fn main() {
T1<1>::C; //~ ERROR: comparison operators cannot be chained
T2<1, 2>::C; //~ ERROR: expected one of `.`, `;`, `?`, `}`, or an operator, found `,`
T3<1, 2, 3>::C; //~ ERROR: expected one of `.`, `;`, `?`, `}`, or an operator, found `,`
}