Closed
Description
When refactoring, I accidentally tried to create an while if let
expression. This caused the parser to give me an error about mismatched brackets. This made it difficult to fix the underlying bug.
Given the following code:
fn main() {
let container = vec![Some(1), Some(2), None];
let mut i = 0;
while if let Some(thing) = container.get(i) {
println!("{:?}", thing);
i += 1;
}
}
The current output is:
error: expected `{`, found `}`
--> src/main.rs:9:1
|
9 | }
| ^ expected `{`
Ideally, the output should indicate that either the if
or while
should be deleted.
p.s. it turns out that the let
is not actually necessary to trigger the same error message:
fn main() {
let container = vec![Some(1), Some(2), None];
let mut i = 0;
while if let Some(thing) = container.get(i) {
println!("{:?}", thing);
i += 1;
}
}