File contents Rust Borrow Checker
Implements Rust-style ownership, borrowing, and lifetime verification.
When to Use
Building memory-safe languages
Implementing borrow checking
Creating safe systems languages
Verifying data race freedom
Implementing affine/linear types
What This Skill Does
Tracks ownership - Each value has single owner
Enforces borrowing - Mutable/immutable references
Verifies lifetimes - Reference validity
Detects data races - At compile time
Key Concepts
Concept
Description
Ownership
Each value has single owner
Borrow
Reference to owned value
Lifetime
Duration reference is valid
Region
Scope where reference valid
Move
Transfer ownership
Borrow Rules
Rule
Description
One mutable
Only one mutable borrow OR many immutable
No dangling
References must not outlive referent
Move vs copy
Copy for Copy types, move otherwise
Drop order
Borrows must be released before drop
Tips
Start with owned values, add borrowing
Implement NLL (non-lexical lifetimes) for better UX
Use lifetime elision rules for ergonomics
Consider async/await lifetime interactions
Handle unsafe blocks with care
Related Skills
ownership-type-system - Basic ownership types
linear-type-implementer - Linear types (generalization)
race-detection-tool - Dynamic race detection
separation-logician - Memory safety proofs
Canonical References
Reference
Why It Matters
Matsakis & Klock, "The Rust Language: Memory Model and Lifetime System" (2014)
Original Rust ownership and borrowing design
Rust Reference, Chapter 4: "Lifetimes and Borrowing"
Official lifetime and borrow specification
N. Matsakis, "A Primer on Rust Lifetimes" (blog series, 2014-2016)
Deep dives on borrow checker design decisions
N. Matsakis & R. Klock, "The Rust Borrow Checker" (Rust Belt Rust 2016)
Overview of borrow checker implementation
Tradeoffs and Limitations
Design Choices
Approach
Pros
Cons
Lexical lifetimes
Simple
Less precise
NLL
Better errors
Complex
Polonius
Most precise
Slow
Limitations
Learning curve for users
Some valid programs rejected (escape analysis)
Unsafe code circumvents guarantees
Complex interactions with async
Borrow checker is complex to implement
Research Tools & Artifacts
Rust borrow checker implementations:
Tool
What to Learn
rustc borrow checker
Production implementation
Polonius
NLL algorithm
Oxide
Reference implementation
Key Papers
Matsakis & Klock - Rust design papers
NLL papers - Non-lexical lifetimes
Research Frontiers
1. Polonius
Goal : More precise borrow checking
Approach : Move errors as dataflow facts
Papers : "Polonius: A New Borrow Checker" (Jung et al., 2018)
Status : Experimental in rustc
2. Async/await and Lifetimes
Goal : Better lifetime handling in async code
Approach : Extended lifetime rules for generators
Papers : "Rust RFC 2394: async/await"
3. Formal Verification of Rust
Goal : Prove memory safety formally
Approach : RustBelt, semantic type system
Papers : Jung et al. "RustBelt: Securing Rust" (POPL 2018)
Implementation Pitfalls
Pitfall
Real Consequence
Solution
NLL complexity
Wrong error messages
Careful dataflow algorithm
Lifetime inference
Overly conservative
Better region inference
Async interactions
Rejected valid code
Extend lifetime rules
Unsafe escape hatch
Lost guarantees
Clear unsafe boundaries
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1 --- 2 name: rainoftime-pl-skills-rust-borrow-checker 3 description: Rust Borrow Checker 4 --- 5 6 # Rust Borrow Checker 7 8 Implements Rust-style ownership, borrowing, and lifetime verification. 9 10 ## When to Use 11 12 - Building memory-safe languages 13 - Implementing borrow checking 14 - Creating safe systems languages 15 - Verifying data race freedom 16 - Implementing affine/linear types 17 18 ## What This Skill Does 19 20 1. **Tracks ownership** - Each value has single owner 21 2. **Enforces borrowing** - Mutable/immutable references 22 3. **Verifies lifetimes** - Reference validity 23 4. **Detects data races** - At compile time 24 25 ## Key Concepts 26 27 | Concept | Description | 28 |---------|-------------| 29 | **Ownership** | Each value has single owner | 30 | **Borrow** | Reference to owned value | 31 | **Lifetime** | Duration reference is valid | 32 | **Region** | Scope where reference valid | 33 | **Move** | Transfer ownership | 34 35 ## Borrow Rules 36 37 | Rule | Description | 38 |------|-------------| 39 | **One mutable** | Only one mutable borrow OR many immutable | 40 | **No dangling** | References must not outlive referent | 41 | **Move vs copy** | Copy for Copy types, move otherwise | 42 | **Drop order** | Borrows must be released before drop | 43 44 ## Tips 45 46 - Start with owned values, add borrowing 47 - Implement NLL (non-lexical lifetimes) for better UX 48 - Use lifetime elision rules for ergonomics 49 - Consider async/await lifetime interactions 50 - Handle unsafe blocks with care 51 52 ## Related Skills 53 54 - `ownership-type-system` - Basic ownership types 55 - `linear-type-implementer` - Linear types (generalization) 56 - `race-detection-tool` - Dynamic race detection 57 - `separation-logician` - Memory safety proofs 58 59 ## Canonical References 60 61 | Reference | Why It Matters | 62 |-----------|----------------| 63 | **Matsakis & Klock, "The Rust Language: Memory Model and Lifetime System" (2014)** | Original Rust ownership and borrowing design | 64 | **Rust Reference, Chapter 4: "Lifetimes and Borrowing"** | Official lifetime and borrow specification | 65 | **N. Matsakis, "A Primer on Rust Lifetimes" (blog series, 2014-2016)** | Deep dives on borrow checker design decisions | 66 | **N. Matsakis & R. Klock, "The Rust Borrow Checker" (Rust Belt Rust 2016)** | Overview of borrow checker implementation | 67 68 ## Tradeoffs and Limitations 69 70 ### Design Choices 71 72 | Approach | Pros | Cons | 73 |----------|------|------| 74 | **Lexical lifetimes** | Simple | Less precise | 75 | **NLL** | Better errors | Complex | 76 | **Polonius** | Most precise | Slow | 77 78 ### Limitations 79 80 - Learning curve for users 81 - Some valid programs rejected (escape analysis) 82 - Unsafe code circumvents guarantees 83 - Complex interactions with async 84 - Borrow checker is complex to implement 85 86 ## Research Tools & Artifacts 87 88 Rust borrow checker implementations: 89 90 | Tool | What to Learn | 91 |------|---------------| 92 | **rustc borrow checker** | Production implementation | 93 | **Polonius** | NLL algorithm | 94 | **Oxide** | Reference implementation | 95 96 ### Key Papers 97 98 - **Matsakis & Klock** - Rust design papers 99 - **NLL papers** - Non-lexical lifetimes 100 101 ## Research Frontiers 102 103 ### 1. Polonius 104 - **Goal**: More precise borrow checking 105 - **Approach**: Move errors as dataflow facts 106 - **Papers**: "Polonius: A New Borrow Checker" (Jung et al., 2018) 107 - **Status**: Experimental in rustc 108 109 ### 2. Async/await and Lifetimes 110 - **Goal**: Better lifetime handling in async code 111 - **Approach**: Extended lifetime rules for generators 112 - **Papers**: "Rust RFC 2394: async/await" 113 114 ### 3. Formal Verification of Rust 115 - **Goal**: Prove memory safety formally 116 - **Approach**: RustBelt, semantic type system 117 - **Papers**: Jung et al. "RustBelt: Securing Rust" (POPL 2018) 118 119 ## Implementation Pitfalls 120 121 | Pitfall | Real Consequence | Solution | 122 |---------|-----------------|----------| 123 | **NLL complexity** | Wrong error messages | Careful dataflow algorithm | 124 | **Lifetime inference** | Overly conservative | Better region inference | 125 | **Async interactions** | Rejected valid code | Extend lifetime rules | 126 | **Unsafe escape hatch** | Lost guarantees | Clear unsafe boundaries | 127 128 --- 129 > Converted and distributed by [TomeVault](https://tomevault.io/claim/rainoftime) — claim your Tome and manage your conversions. 130 <!-- tomevault:4.0:skill_md:2026-04-11 -->
tomevault-io/skills-registry/tree/main/rainoftime--pl-skills--rust-borrow-checker commit 4b45dcd6b9
Frequently asked questions How do I install the Rainoftime Pl Skills Rust Borrow Checker skill? Run npx skillmds@latest add tomevault-io/rainoftime-pl-skills-rust-borrow-checker in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
What does the Rainoftime Pl Skills Rust Borrow Checker skill do? Rust Borrow Checker It is listed under Coding & Dev Tools on SkillMD.
Is Rainoftime Pl Skills Rust Borrow Checker safe to use? This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
Which AI agents work with Rainoftime Pl Skills Rust Borrow Checker? This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Is Rainoftime Pl Skills Rust Borrow Checker free to use? Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
Who published Rainoftime Pl Skills Rust Borrow Checker? tomevault-io (@tomevault-io) published this skill. Their other Agent Skills are listed on their SkillMD profile.