rust-lang / rust-lang/rust

Tracking Issue for move expressions (`move(expr)`)

Open
#155,050 0 comments 10 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

B-experimental C-tracking-issue F-move_expr S-tracking-unimplemented T-lang
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

This is a tracking issue for move(expr) in closures.
The feature gate for the issue is #![feature(move_expr)].

RFC: https://github.com/rust-lang/rfcs/pull/3968
Relevant prior discussion / implementation PR: #132290.

About tracking issues

Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g. bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Discussion comments will get marked as off-topic or deleted.
Repeated discussions on the tracking issue may lead to the tracking issue getting locked.

Summary

move_expr adds syntax of the form move(expr) for explicit by-value capture in closures.

The current implementation effort is intentionally starting with plain closures first.
Async / coroutine-related cases are expected to follow separately.

Steps
Unresolved Questions
  • Async and coroutine cases: What should the semantics be for async blocks and coroutine-related lowering?
  • Nested closures: Are the current expected bahavior of nested-closure the right ones in practice, or do they need adjustment?
  • Diagnostics and linting: For accepted but potentially confusing cases, such as shadowing or label-related behavior, should we keep the behavior as-is, improve diagnostics, or add a dedicated lint?
  • Control-flow-sensitive expressions: How should move(expr) interact with expressions like break, where the desugaring evaluates the expression at closure creation time?
Implementation history

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read RFC 3968 and implementation PRs #155023 and #157738 first, then choose one unchecked area rather than treating this as a standalone task. Possible entry points mentioned are UI, borrowck, and nested-closure test coverage, documentation, or the style guide. Done means completing one focused checklist item and its relevant review or validation.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.