Closed
Description
I got the following code:
struct StructWithCurlyBraces {
_foo: usize
}
impl Iterator for StructWithCurlyBraces {
type Item = ();
fn next(&mut self) -> Option<Self::Item> {
None
}
}
pub fn main() {
// with surrounding parentheses it works
for _ in (StructWithCurlyBraces { _foo: 42 }) { }
// without it doesn't
for _ in StructWithCurlyBraces { _foo: 42 } { }
}
I don't know if the case without surrounding parentheses is intended to work but apart from that the error message is somewhat missleading.
error: expected type, found `42`
--> <anon>:18:44
|
18 | for _ in StructWithCurlyBraces { _foo: 42 } { }
| ^^
error[E0423]: expected value, found struct `StructWithCurlyBraces`
--> <anon>:18:14
|
18 | for _ in StructWithCurlyBraces { _foo: 42 } { }
| ^^^^^^^^^^^^^^^^^^^^^ did you mean `StructWithCurlyBraces { /* fields */ }`?
error: aborting due to 2 previous errors
It seems that the tokenizer doesn't get this right?
Edit: Include error message