FFORGE//RS
← Roadmap

rust / LEVEL 5

The pointer that remembered the stack

EST.45 MIN
01

THEORY / RETRIEVAL

What to restore

  • Distinguish moving a Pin handle from moving its pointee
  • Use PhantomPinned to opt an address-sensitive type out of Unpin
  • Establish an internal pointer only after allocation at a stable address

Pin protects the pointee, not the pointer handle

An address-sensitive value must remain at one memory address from the moment its invariant is established until drop. `Pin<Box<T>>` can itself be returned, stored in a Vec or moved between variables; those operations move the Box handle while its heap allocation stays put.

Construction order is part of the safety proof

A self-pointer created while the struct is still on the stack becomes stale when the struct moves into a Box. Allocate first, initialize the internal pointer against the boxed field, then convert that same Box into a pin. `PhantomPinned` prevents safe code from treating the pointee as `Unpin`.

CHECKPOINT

Which construction establishes a valid self-pointer without moving the pointee afterward?

ISOLATED RUST 1.96
src/lib.rsEDIT

02 / DEBUGGING

Find and fix the defect

Repair `PinnedMessage::new`. The stored pointer must target the `text` field after construction and remain valid when the `Pin<Box<_>>` handle moves. Keep the public API, keep `PhantomPinned`, and do not dereference the raw pointer.

Initializing editor…
CLOUD SANDBOXnetwork off · 256 MB · 12 s
1 / 64 KB
OUTPUT
Runner is waiting for a submission.