arXiv:2610.06003cs.PLOct 2026

Manuscript Offprint

arXiv:2610.06003

A Complete, Formal Semantics for Rust Source Code

Daniel Drodt

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

DANIEL DRODT, Technical University of Darmstadt, Germany

Formally reasoning about Rust programs requires a rigorous formal semantics, especially in the context of deductive verification and concurrent programming. We present a modular, flexible semantics for a significant subset of (close to) source code level Rust, based on the recent locally abstract, globally concrete semantics framework, separating local evaluation of expressions from their composition into concrete traces. The semantics is extended to model Rust’s asynchronous programming features and Rust’s most popular async runtime, Tokio. Based on our more abstract formalization, we establish the fairness of Tokio’s scheduler. Further, we show the applicability of our semantics to deductive verification of Rust by providing soundness proofs for a Rust program logic.

CCS Concepts: • Theory of computation → Program semantics; Programming logic; • Computing methodologies → Concurrent programming languages.

Additional Key Words and Phrases: Rust, denotational semantics, trace semantics, dynamic logic, concurrency, fairness

ACM Reference Format:

Daniel Drodt. 2026. A Complete, Formal Semantics for Rust Source Code. ACM Trans. Program. Lang. Syst. XXX, YYY, Article ZZZ (September 2026), 67 pages. https://doi.org/XXXXXXX.XXXXXXX

1 Introduction

Rust is a modern, flexible, systems-level programming language of growing importance. It is used in many crucial application domains, most notably the Linux kernel [44]. This importance and usage increases the need for formal analysis and formal verification of Rust programs, both of which are well supported by Rust’s language design. Accordingly, several verification tools for Rust are being developed [3, 6, 12, 21, 30, 43]. With its complex ownership model and reference system, Rust provides a powerful yet unusually restrictive type system that ensures memory safety and the absence of data races [42].

The lack of an official, formal, source code level Rust semantics makes validation of these tools problematic. Without such a semantics, interoperability of verification tools is difficult, as tools may not be based on the same, or even compatible, formalisms. Similarly, verification of the Rust compiler needs a formal semantics for each of Rust’s intermediate representations.

The semantics problem is partially addressed by formal models of parts of Rust’s type system or intermediate representations, typically the mid-level intermediate representation (MIR) [13, 28, 36, 39]. These semantics provide usable and rigorous formalizations of Rust’s borrow checker and operational semantics of subsets of the language, each offering different trade-offs and specializations. Nevertheless, they are limited in at least two respects. First, being low-level and focused on the MIR, they offer little for reasoning about Rust programs at a level closer to the source code. A high-level representation crucially allows, e.g., comprehension of the complex proof state [21].

Author's Contact Information: Daniel Drodt, daniel.drodt@tu-darmstadt.de, Technical University of Darmstadt, Darmstadt, Hessen, Germany.

Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from permissions@acm.org.

© 2026 Copyright held by the owner/author(s). Publication rights licensed to ACM.

ACM 1558-4593/2026/9-ARTZZZ

https://doi.org/XXXXXXX.XXXXXXX

ZZZ:2

Daniel Drodt

Second, no formal semantics for Rust’s concurrent features (“async Rust”) has been developed. As “fearless concurrency” is a major feature and promise of Rust [42], this is an unfortunate limitation. Without formal semantics, it remains difficult to reason about concurrent and parallel Rust programs or to prove them correct, free of deadlocks, and similar properties. Furthermore, it remains elusive to model concrete schedulers or runtimes, which is especially relevant as Rust allows different asynchronous runtimes to be used. Here too, a high-level view seems more promising than semantics of lower-level representations.

As Rust has matured and its type system, borrow checking, and memory model have been examined, refined, and formalized, we argue that a sensible next step is to examine the high-level features, building on these closely-studied foundations.

Hence, we see a crucial gap left open: a formal semantics of Rust suitable for formalizing high-level properties of Rust programs. Ideally, such a semantics should (1) be highly flexible and compositional to accommodate future language extensions; (2) formalize Rust at the source code level (or close to it); (3) allow the formalization of asynchronous Rust code; (4) permit modeling of and reasoning about asynchronous runtimes; and (5) ease deductive verification of Rust programs.

To meet these goals, modularity of the semantics is paramount: Extendability is only feasible if adding a new language feature does not require to significantly rewrite the existing semantics rules. Additionally, a modular semantics eases verification effort, as calculus proof rules are also made modular in the sense that it is possible to extend the calculus with new rules and constructs without revising the rest of the calculus.

However, semantics in the style of structural operational semantics (SOS) struggle with modularity. As Peter Mosses put it, “conventional SOS descriptions of programming languages have quite poor modularity,” which leads to complex semantics, as “[w]hen extending a pure functional language with concurrency primitives and/or references, for instance, the SOS rules for all the functional constructs had to be completely reformulated” [50]. While Mosses [50] provides a modification of SOS that improves modularity, recent developments in trace-based semantics offer an even more flexible, complete, and modular path [7, 8, 32, 41].

The present paper remedies this situation by providing a comprehensive, formal semantics for most parts of safe Rust’s high-level intermediate representation (HIR) based on the locally abstract, globally concrete (LAGC) semantics framework [17], which was developed with concurrent and parallel programs and deductive verification in mind. LAGC achieves a modular and flexible semantics by separating the local evaluations of expressions from the global state and concerns such as scheduling. This approach is modular in the sense that each syntactic structure—expressions or statements—have one local rule that is independent of the global context. Adding new language features consists largely of formulating new local rules. Furthermore, the approach is well-suited for concurrency by delegating all scheduling concerns to the global layer and building hybrid traces over states and events for each program execution. These traces contain all relevant information of state changes and scheduling relevant events. Combining these elements, LAGC defines the semantics of a specific program as the set of all well-formed traces generated by the global composition rules.

LAGC has been successfully applied to a number of programming languages and settings, such as ProMeLa and active object languages [10] like ABS [17, 18], demonstrating its flexibility. Further examples include Real-Time ABS [62] and Timed Rebeca [25]. The LAGC approach has also been used, in a slightly different form, in the context of deductive verification [8]. These examples demonstrate that LAGC, with its modular approach, separation of local and global context, and hybrid traces, is more suitable than the traditional SOS semantics for purposes of verification and the modeling of concurrent programming languages.

ZZZ:3

For these reasons, LAGC is a viable semantics framework to achieve the goals outlined above and it allows a semantics of higher-level Rust. Hence, the presented semantics is based on LAGC. Our detailed contributions are:

(1) We provide a semantics for most parts of safe Rust’s HIR in the LAGC framework and demonstrate the semantics’ usability with a number of examples. To demonstrate the applicability of the semantics, we support complex language features and control flows, such as loops with breaks and continues.

(2) We extend this semantics to async Rust, modeling any possible scheduling of async functions. Notably, to our knowledge, this is the first formal semantics of async Rust in the literature.

(3) Based on the asynchronous semantics, we formalize Rust’s most widely-used runtime, the “current thread runtime” of Tokio [64], and prove its fairness. We stress that our approach is straightforwardly adaptable to other runtimes, with the async Rust semantics carrying over.

(4) Finally, we show how our semantics can be used to prove soundness of the calculus for RustyDL, a program logic for Rust [21] based on dynamic logic (DL) [53], demonstrating how the modular rules of LAGC ease such proofs. Thereby, we also highlight the interaction of DL and LAGC.

Section 2 introduces the necessary background and definitions on which our semantics is built, as well as the general LAGC approach. We present the semantics for synchronous Rust in Section 3 and extend it to async Rust in Section 4. Section 5 then builds upon the async semantics to represent one of Tokio's runtimes in LAGC and proves its fairness guarantees. The calculus of the program logic RustyDL [21] is proven sound in Section 6. We present related work in Section 7 and conclude the paper in Section 8.

References (29)