Skip to main content

Module ownership

Module ownership 

Source
Expand description

Native ownership analysis for use-after-move detection.

Lightweight data-flow analysis that catches the 90% common ownership errors at check-time (milliseconds), before Rust compilation. This pass tracks Owned, Moved, and Borrowed states through control flow.

§State Transitions

         Let x be value
              │
              ▼
          [Owned]
         /        \
   Give x       Show x
       │            │
       ▼            ▼
   [Moved]     [Borrowed]
       │            │
   use x?      use x? ✓
       │
    ERROR: use-after-move

§Control Flow Awareness

The checker handles branches by merging states:

  • Moved in one branch + Owned in other = MaybeMoved
  • Using a MaybeMoved variable produces an error

§Example

Let x be 5.
Give x to y.
Show x to show.  ← Error: Cannot use 'x' after giving it away

Structs§

OwnershipChecker
Ownership checker - tracks variable states through control flow
OwnershipError
Error type for ownership violations

Enums§

OwnershipErrorKind
VarState
Ownership state for a variable