Open
Description
On 1.45.0-nightly (2020-05-29 4bd32c98047a809ba5fd)
fn f() -> usize {
{1usize} - 1usize
}
Intuitively, I would expect these braces to be redundant and also have no influence, but they do. The compiler expects a ()
type and then considers the minus sign a unary operator.
warning: unnecessary braces around block return value
--> src/lib.rs:6:5
|
6 | {1usize} - 1usize
| ^^^^^^^^ help: remove these braces
|
= note: `#[warn(unused_braces)]` on by default
error[E0308]: mismatched types
--> src/lib.rs:6:6
|
6 | {1usize} - 1usize
| ^^^^^^ expected `()`, found `usize`
error[E0600]: cannot apply unary operator `-` to type `usize`
--> src/lib.rs:6:14
|
6 | {1usize} - 1usize
| ^^^^^^^^ cannot apply unary operator `-`
|
= note: unsigned values cannot be negated
It seems to me that either the error message about the braces being redundant is incorrect or misleading, or something more nefarious seems to be going on with scopes, expressions, etc.