Skip to content

Silencing "let expressions in this position are experimental" errors in case of misplaced parantheses in if let expression #83274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
atsuzaki opened this issue Mar 18, 2021 · 3 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-enhancement Category: An issue proposing an enhancement or a PR with one. D-verbose Diagnostics: Too much output caused by a single piece of incorrect code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@atsuzaki
Copy link
Contributor

atsuzaki commented Mar 18, 2021

Follow-up to #82827, cc: @estebank

Given the following code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=7810898a8a0c0b5d421b4efbd58a4ff8

pub fn main() {
  let x = Some(3);
  if (let Some(y) = x) {
    println!("{}", y)
  } else {
    println!("None")
  }
}

The current output is:

error[E0658]: `let` expressions in this position are experimental
 --> src/main.rs:3:7
  |
3 |   if (let Some(y) = x) {
  |       ^^^^^^^^^^^^^^^
  |
  = 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
  = help: you can write `matches!(<expr>, <pattern>)` instead of `let <pattern> = <expr>`

error: invalid parentheses around `let` expression in `if let`
 --> src/main.rs:3:6
  |
3 |   if (let Some(y) = x) {
  |      ^               ^
  |
help: `if let` needs to be written without parentheses
  |
3 |   if let Some(y) = x {
  |     --             --

error: aborting due to 2 previous errors

Ideally the output should look like:
(Just the invalid parantheses error, and the let expressions in this position is experimental error is silenced)

error: invalid parentheses around `let` expression in `if let`
 --> src/main.rs:3:6
  |
3 |   if (let Some(y) = x) {
  |      ^               ^
  |
help: `if let` needs to be written without parentheses
  |
3 |   if let Some(y) = x {
  |     --             --

error: aborting due to 2 previous errors
@atsuzaki atsuzaki added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 18, 2021
@estebank estebank added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. D-verbose Diagnostics: Too much output caused by a single piece of incorrect code. labels Mar 18, 2021
@JohnTitor JohnTitor added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Mar 18, 2021
@osa1
Copy link
Contributor

osa1 commented Mar 23, 2021

@rustbot claim

@dtolnay
Copy link
Member

dtolnay commented Jan 27, 2022

@rustbot release-assignment

@c410-f3r
Copy link
Contributor

The help note is not showed anymore so this issue can probably be closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-enhancement Category: An issue proposing an enhancement or a PR with one. D-verbose Diagnostics: Too much output caused by a single piece of incorrect code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants