Skip to content

Prompted to add #![feature(let_chains)] to code that is unsupported anyway #104868

Closed
@jruderman

Description

@jruderman

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

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsF-let_chains`#![feature(let_chains)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions