Description
cc @Centril
Code first. This code:
fn main() {
let x = (let y = 6);
}
on current stable Rust 1.38, gives this set of error messages:
error[E0658]: `let` expressions in this position are experimental
--> src/main.rs:2:14
|
2 | let x = (let y = 6);
| ^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/53667
error: `let` expressions are not supported here
--> src/main.rs:2:14
|
2 | let x = (let y = 6);
| ^^^^^^^^^
|
= note: only supported directly in conditions of `if`- and `while`-expressions
= note: as well as when nested within `&&` and parenthesis in those conditions
warning: unnecessary parentheses around assigned value
--> src/main.rs:2:13
|
2 | let x = (let y = 6);
| ^^^^^^^^^^^ help: remove these parentheses
|
= note: `#[warn(unused_parens)]` on by default
The part that I'm most concerned about is:
error: `let` expressions are not supported here
Before eRFC "if- and while-let-chains, take 2" (rust-lang/rfcs#2497, #53667, #53668), this code USED to result in this error message:
error: expected expression, found statement (`let`)
--> src/main.rs:2:14
|
2 | let x = (let y = 6);
| ^^^
|
= note: variable declaration using `let` is a statement
The reason I know this is because we have the old error message in the book, in the section where we're trying to explain the difference between statements and expressions. The error message I'm seeing now is muddying the waters by saying "let
expressions".
Based on my reading of the eRFC, it's only supposed to change if let
, but as kind of a side effect let
is now sort-of an expression? The updates to the reference don't clear it up for me, as they only describe if let
, not plain let
s.
What I expected is that even though the eRFC has been accepted and implemented, plain let y = 6
would still be considered a statement and the error message wouldn't talk about "let
expressions".
If my expectation is valid, then the compiler error message is a bug. If my expectation is invalid, please let me know so that I can work on updating the book. Thanks!
This issue has been assigned to @jafern14 via this comment.