You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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`.
I believe this is working as expected. Attributes can be applied to blocks as statements, but not as expressions. In some cases, attributes can be used in expressions, but those were accidentally stabilized in #36995, and nobody noticed for a long time. The current stable rules are detailed in https://doc.rust-lang.org/reference/expressions/block-expr.html#attributes-on-block-expressions. Stabilization in other expression positions is tracked in the linked issue (#15701).
I tried this code:
I expected to see this happen: The code compiles.
Instead, this happened: The code fails to compile with the following error:
The following code compiles as expected:
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: