Given the following code: [playground]
struct Example
where
(): Sized,
(usize);
The current output is:
error: expected one of `:`, `==`, or `=`, found `;`
--> src/lib.rs:4:8
|
4 | (usize);
| ^ expected one of `:`, `==`, or `=`
What appears to be happening is that we're trying to parse this as a unit struct (which can have a where clause), and thus trying to parse the struct tuple as a type to bound.
With a tuple visibility:
struct Example
where
(): Sized,
(pub usize, usize);
error: expected type, found keyword `pub`
--> src/lib.rs:4:2
|
4 | (pub usize, usize);
| ^^^ expected type
Ideally,
- In the former case (easier?) we can notice that we parsed a tuple type and then got
; instead of : (or a currently-just-for-diagnostics =) and then reinterpret the tuple type as a tuple struct tuple, printing a more useful error;
- In the latter case (harder?) we would likely need to backtrack when seeing a
pub visibility marker and retry to parse as a tuple struct definition tuple in order to provide the nicer error.
Given the following code: [playground]
The current output is:
What appears to be happening is that we're trying to parse this as a unit struct (which can have a
whereclause), and thus trying to parse the struct tuple as a type to bound.With a tuple visibility:
Ideally,
;instead of:(or a currently-just-for-diagnostics=) and then reinterpret the tuple type as a tuple struct tuple, printing a more useful error;pubvisibility marker and retry to parse as a tuple struct definition tuple in order to provide the nicer error.