Closed
Description
I tried this code:
fn main() {
match 0 {
_ => {
#![allow(unused_variables)]
}
}
}
I expected to see this happen: The code compiles.
Instead, this happened: The code fails to compile with the following error:
error[E0658]: attributes on expressions are experimental
--> test.rs:4:13
|
4 | #![allow(unused_variables)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information
= help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.
The following code compiles as expected:
fn main() {
match 0 {
_ => {{ // <-- double braces
#![allow(unused_variables)]
}}
}
}
Meta
rustc --version --verbose
:
binary: rustc
commit-hash: d3c79346a3e7ddbb5fb417810f226ac5a9209007
commit-date: 2020-02-29
host: x86_64-unknown-linux-gnu
release: 1.43.0-nightly
LLVM version: 9.0