rust-lang / rust-lang/rust-analyzer

Ergonomic Clone Support

Open
#20,539 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

B-unstable C-feature
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

The following code errors with rust analyzer, but builds and runs with cargo:

#![feature(ergonomic_clones)]
// ...
let mut y = use || {
    // ...
};

specifically:

1. Syntax Error: expected expression [syntax-error] (on the 'u' in 'use')
2. Syntax Error: expected SEMICOLON [syntax-error] (on the space after 'use')

with nightly (2025-08-24) rust analyzer using rustup and rustaceanvim.

The other x.use syntax also fails as well, but the UseCloned trait works as expected.

It's an incomplete feature, so sorry if this is too early. I have no clue if those are supported or if it makes more sense to wait (couldn't find clear info on this). I thought I'd make this issue anyways in case someone else comes across this.

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

Start by reproducing the reported snippet with rust-analyzer nightly 2025-08-24, rustup, and rustaceanvim, then compare diagnostics for the use || and x.use forms with the working UseCloned trait. Trace the syntax handling for the incomplete ergonomic_clones feature; done means supported forms no longer produce syntax errors, or their unsupported status is clearly established.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.