# a-mir-formality

> An early-stage, executable model of Rust's type system, trait solver and borrow checker, written as inference rules in Rust and maintained by members of the Rust types team.

The rules are written with formality-core, a Rust library for defining judgments, so the model runs as an ordinary Rust program and its tests check whether small Rust-like programs are accepted or rejected. It works on its own Rust-like grammar (types, traits, impls, functions, ADTs and a MIR-like expression language), not on real Rust source code. Function bodies can be translated to MiniRust, which gives them a run-time meaning. The README says the intention is to propose the model to Rust as an RFC if the experiments succeed.

- Kind: formal semantics
- Models: Rust
- Fragment: Static semantics: well-formedness of types and items, trait solving and associated-type normalization, coherence (overlap and orphan rules), and borrow checking of a MIR-like expression language. Run-time behavior is delegated to MiniRust through a code generator. No list of covered or excluded Rust features is published.
- Written in: Rust (formality-core judgment library)
- Available in: —
- Stage: not yet staged
- Licence: open-source, MIT OR Apache-2.0
- Validation: Snapshot tests in the repository check that example programs type-check or fail with an expected error. No published comparison against rustc was found.
- Latest release: main@b2394ae (2026-11-24) https://github.com/rust-lang/a-mir-formality/commits/main

## Stage

**Stage —: Not yet staged.**

| Stage | Criterion | Met | Evidence / note |
|---|---|---|---|
| 0 | Machine-checked or machine-readable definition | yes | [evidence](https://github.com/rust-lang/a-mir-formality) The judgments are machine-readable Rust code. The model is not available in a proof assistant. |
| 0 | Fragment and version are stated | no | [evidence](https://rust-lang.github.io/a-mir-formality/intro.html) The book describes the layers of the model, but there is no list of covered Rust features and no Rust version. |
| 1 | Can be executed or tested | yes | [evidence](https://rust-lang.github.io/a-mir-formality/intro.html) The model runs with cargo test; judgments are executed directly. |
| 1 | Published results against conformance tests or real implementations | no | [evidence](https://github.com/rust-lang/a-mir-formality/tree/main/tests) Repository tests only; no published differential testing against rustc. |
| 2 | Adopted by the language or ISA owner, or covers the full current version and tracks new ones | no | [evidence](https://github.com/rust-lang/a-mir-formality/blob/main/README.md) Adopted by the owner: no; full coverage: no; tracks new versions: no. Hosted in the rust-lang organization and described as maintained by the Rust types team, but the README calls it an early-stage experiment that may later be proposed as an official part of the language definition through an RFC. Described as early-stage and experimental. No stated policy for following Rust releases. |

Missing for Stage 0: Fragment and version are stated.

## Common features

| Feature | Coverage |
|---|---|
| Machine integers | Unknown |
| Floating point | Unknown |
| Heap and pointers | Unknown |
| Arrays and buffers | Unknown |
| Loops | Unknown |
| Recursion | Unknown |
| Higher-order code | Unknown |
| Threads and shared memory | Unknown |
| I/O and system calls | Unknown |
| Standard library | Unknown |

## Rust-specific features

| Feature | Coverage |
|---|---|
| References and borrowing | Partial — Borrow checking is modeled as judgments over its MIR-like expression language (let, if, loop, break, return and expressions); how much of rustc's borrow checker it matches is not documented. ([source](https://github.com/rust-lang/a-mir-formality/blob/main/book/src/formality_rust/borrow_check.md)) |
| Traits and generics | Partial — Trait solving, associated-type normalization, higher-ranked where clauses and coherence (overlap and orphan checks) are modeled; the project does not claim full coverage of Rust's trait system. ([source](https://github.com/rust-lang/a-mir-formality/blob/main/book/src/formality_rust/coherence.md)) |
| Closures | Unknown |
| unsafe and raw pointers | Unknown |
| Interior mutability | Unknown |
| Trait objects | Unknown |
| Iterators | Unknown |
| Panics | Unknown |
| async / await | Unknown |

## Sources
- [a-mir-formality README](https://github.com/rust-lang/a-mir-formality/blob/main/README.md)
- [Cargo.toml (license; 'Model of the Rust type system maintained by the Rust types team')](https://github.com/rust-lang/a-mir-formality/blob/main/Cargo.toml)
- [a-mir-formality book](https://rust-lang.github.io/a-mir-formality/intro.html)
- [Code generation to MiniRust](https://github.com/rust-lang/a-mir-formality/blob/main/book/src/formality_rust/codegen.md)
- [Releases of the formality-core and formality-macros crates](https://github.com/rust-lang/a-mir-formality/releases)

---
Last checked 2026-11-26. Data: [JSON](/semantics/a-mir-formality.json) · Page: [HTML](/semantics/a-mir-formality/) · Methodology v0.1: [/methodology/](/methodology/) · Corrections: [/contribute/](/contribute/)
