# Resources for implementing Rust's borrow checker

**URL:** <https://internals.rust-lang.org/t/resources-for-implementing-rusts-borrow-checker/19041>\
**Category:** compiler\
**Created:** [June 21, 2023, 9:03pm UTC](https://internals.rust-lang.org/t/resources-for-implementing-rusts-borrow-checker/19041 "2023-06-21T21:03:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![camio](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/camio/32/10994_2.png) [@camio](https://internals.rust-lang.org/u/camio)\
**Post date:** [June 21, 2023, 9:03pm UTC](https://internals.rust-lang.org/t/resources-for-implementing-rusts-borrow-checker/19041/1 "2023-06-21T21:03:32Z")

</div>

I'd like to implement Rust's borrow checker, but I haven't found great documentation to get started. The rustc borrow checking code is complicated and I'm worried that formalisms such as [Oxide](https://arxiv.org/pdf/1903.00982.pdf) and [FR](https://dl.acm.org/doi/pdf/10.1145/3443420) will lead me astray. Any recommendations? TIA

---

<div class="post-metadata">

**Author:** ![kornel](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/kornel/32/2711_2.png) [@kornel](https://internals.rust-lang.org/u/kornel)\
**Post date:** [June 21, 2023, 10:19pm UTC](https://internals.rust-lang.org/t/resources-for-implementing-rusts-borrow-checker/19041/2 "2023-06-21T22:19:03Z")

</div>

Rust had a couple — first a simple scope-based borrow checker, then "NLL" (non-lexical lifetimes) borrow checker, and the third not-yet-ready attempt is Polonius.

> **[GitHub - rust-lang/polonius: Defines the Rust borrow checker.](https://github.com/rust-lang/polonius)**
>
> Defines the Rust borrow checker. Contribute to rust-lang/polonius development by creating an account on GitHub.

It's a problem that is simple in simple cases, and gets infinitely complex at edge cases. So I won't be surprised if there aren't any easy guides for it, because for Rust itself it was a multi-year journey.

---

<div class="post-metadata">

**Author:** ![sanxiyn](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/sanxiyn/32/8824_2.png) [@sanxiyn](https://internals.rust-lang.org/u/sanxiyn)\
**Post date:** [June 21, 2023, 11:49pm UTC](https://internals.rust-lang.org/t/resources-for-implementing-rusts-borrow-checker/19041/3 "2023-06-21T23:49:45Z")

</div>

You basically should read rustc source code, but as you said it is complicated. rustc-dev-guide has a chapter on the borrow checker that should help you orient around the source code.

> **[The borrow checker - Rust Compiler Development Guide](https://rustc-dev-guide.rust-lang.org/borrow_check.html)**
>
> A guide to developing the Rust compiler (rustc)

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [September 19, 2023, 11:50pm UTC](https://internals.rust-lang.org/t/resources-for-implementing-rusts-borrow-checker/19041/4 "2023-09-19T23:50:23Z")

</div>

Closed on September 19, 2023, 11:50pm UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
