rust-lang / rust-lang/reference

Panicking while dropping lvalue of assignment

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

Nobody has claimed this yet.

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

Description

Currently the references states that in *x = v, the value contained in x is first dropped before being replaced by v. If that where strictly the case, if the drop panics and that panic is caught, we could then observe an uninitialized x.

Indeed in practice, the generated clean up code moves v into x when unwinding, but this should likely be documented.

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 locating the Rust Reference section covering assignment and drop behavior, then verify the unwinding behavior described in the issue. Update the documentation to explain what happens when dropping the previous value panics and confirm that the resulting behavior is no longer described as exposing an uninitialized place.

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.