rust-lang / rust-lang/reference

unique-immutable-borrows is a misnomer and no longer exists in rustc

Open
#1,959 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-closures
Dominant language
Rust
Stars
1.6k
Forks
607
PR merge metrics
PR metrics pending

Description

https://doc.rust-lang.org/nightly/reference/types/closure.html#unique-immutable-borrows-in-captures

This borrow kind exists to support capturing let x = &mut whatever and mutating through x without triggering the non-soundness critical "missing mut binding" error.

Stating that it's immutable is wrong and for rustc itself, has been actively dangerous: https://github.com/rust-lang/rust/issues/112056

We've since removed this borrow kind in rustc itself: https://github.com/rust-lang/rust/pull/112119. I am not totally sure how to rework this, but "unique immutable" is imo definitely the wrong perspective

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 with the Reference section on unique immutable borrows in closure captures and read rust-lang/rust issues #112056 and pull request #112119 for the rustc context. Rework the terminology and explanation so it no longer describes the borrow as immutable and matches the current rustc behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.