Skip to content

let expressions in this position are unstable #142111

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
kakserpom opened this issue Jun 6, 2025 · 1 comment
Closed

let expressions in this position are unstable #142111

kakserpom opened this issue Jun 6, 2025 · 1 comment
Labels
C-discussion Category: Discussion or questions that doesn't represent real issues.

Comments

@kakserpom
Copy link

kakserpom commented Jun 6, 2025

Stable Rust:

error[E0658]: `let` expressions in this position are unstable
   --> src/lib.rs:331:24
    |
331 |                     if let Some(&n1) = transitions.get(b.as_ref()) && let Some(&n2) = self.nodes[n1].transitions.get(a.as_ref())
    |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information

error[E0658]: `let` expressions in this position are unstable
   --> src/lib.rs:331:71
    |
331 |                     if let Some(&n1) = transitions.get(b.as_ref()) && let Some(&n2) = self.nodes[n1].transitions.get(a.as_ref())
    |                                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information

Of course I've rewritten this as:

if let Some(&node) = transitions.get(b.as_ref()).and_then(|&x| self.nodes[x].transitions.get(a.as_ref()))

But it still looks like a bug to me, because #53667 is marked as completed and closed.

Meta

rustc --version --verbose:

rustc 1.87.0 (17067e9ac 2025-05-09)
binary: rustc
commit-hash: 17067e9ac6d7ecb70e50f92c1944e545188d2359
commit-date: 2025-05-09
host: aarch64-apple-darwin
release: 1.87.0
LLVM version: 20.1.1

@kakserpom kakserpom added the C-bug Category: This is a bug. label Jun 6, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jun 6, 2025
@hanna-kruppe
Copy link
Contributor

The PR that stabilized let chains (#132833) will be in Rust 1.88, so you’re one version too early.

@saethlin saethlin added C-discussion Category: Discussion or questions that doesn't represent real issues. and removed C-bug Category: This is a bug. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jun 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-discussion Category: Discussion or questions that doesn't represent real issues.
Projects
None yet
Development

No branches or pull requests

4 participants