Skip to content

if-let guard point to let_chains issue #74232

Closed

Description

@tesuji

I tried this code:

pub fn foo(a: &[u8], b: bool) -> bool {
    match b {
        true if let [1, 2, 3, ..] = a => true,
        _ => false,
    }
}

I expected to see this happen:
The compilation fails and error points out that if-let guard is not implemented
and being tracked at #51114

Instead, this happened:
The error points to let_chains feature, which is wrong and adding that feature gate
doesn't make the code compile.

error[E0658]: `let` expressions in this position are experimental
 --> <source>:3:17
  |
3 |         true if let [1, 2, 3, ..] = a => true,
  |                 ^^^^^^^^^^^^^^^^^^^^^
  |
  = 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

Meta

rustc --version --verbose:

rustc 1.46.0-nightly (8aa18cbdc 2020-07-08)
binary: rustc
commit-hash: 8aa18cbdc5d4bc33bd61e2d9a4b643d87f5d21de
commit-date: 2020-07-08
host: x86_64-unknown-linux-gnu
release: 1.46.0-nightly
LLVM version: 10.0
Compiler returned: 0

Activity

  1. changed the title [-]if-let arm point to let_chains issue[/-] [+]if-let guard point to let_chains issue[/+] on Jul 11, 2020
  2. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Jul 14, 2020
  3. added a commit that references this issue on Aug 22, 2020
    5528caf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.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