Closed
Description
Given the following code:
#![allow(unused_braces)]
fn main() {
let _: usize = { {10} - 1 };
}
The current output is:
error[E0308]: mismatched types
--> src/main.rs:4:23
|
4 | let _: usize = { {10} - 1 };
| ^^ expected `()`, found integer
error[E0600]: cannot apply unary operator `-` to type `usize`
--> src/main.rs:4:27
|
4 | let _: usize = { {10} - 1 };
| ^^^
| |
| cannot apply unary operator `-`
| help: you may have meant the maximum value of `usize`: `usize::MAX`
|
= note: unsigned values cannot be negated
Ideally this would give the same diagnostics as {10} + 1
gives:
error: expected expression, found `+`
--> src/main.rs:4:27
|
4 | let _: usize = { {10} + 1 };
| ^ expected expression
|
help: parentheses are required to parse this as an expression
|
4 | let _: usize = { ({10}) + 1 };
| + +
error[E0308]: mismatched types
--> src/main.rs:4:23
|
4 | let _: usize = { {10} + 1 };
| ^^ expected `()`, found integer