Prompted to add #![feature(let_chains)] to code that is unsupported anyway · Issue #104868 · rust-lang/rust (original) (raw)

Given the following code (playground):

fn main() { let _ = let _ = 3; }

The current output is:

error: expected expression, found `let` statement
 --> qlet.rs:2:13
  |
2 |     let _ = let _ = 3;
  |             ^^^

error: `let` expressions are not supported here
 --> qlet.rs:2:13
  |
2 |     let _ = let _ = 3;
  |             ^^^^^^^^^
  |
  = note: only supported directly in conditions of `if` and `while` expressions

error[E0658]: `let` expressions in this position are unstable
 --> qlet.rs:2:13
  |
2 |     let _ = let _ = 3;
  |             ^^^^^^^^^
  |
  = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
  = help: add `#![feature(let_chains)]` to the crate attributes to enable

Adding #![feature(let_chains)] only makes the last error go away: let is not supported in this position even with #![feature(let_chains)].

So it would be better not to show the last error message in this case.

Version

rustc 1.67.0-nightly (b3bc6bf31 2022-11-24)
binary: rustc
commit-hash: b3bc6bf31265ac10946a0832092dbcedf9b26805
commit-date: 2022-11-24
host: x86_64-apple-darwin
release: 1.67.0-nightly
LLVM version: 15.0.4