Partial Borrows in Rust
Sasha Pak, Richard Willie, Umang Mathur, Fabian Muehlboeck, Alex Potanin
Key points
From the paper's conclusion- We implement view types in rustc and extend the Aeneas interpreter to support partial borrows.
Abstract
Rust ensures memory safety by requiring exclusive access to mutably borrowed data. However, a borrow can prevent access to more data than necessary. For example, a method with an &mut self parameter borrows the entire struct, even when the method uses only some of its fields. Calling the method can therefore conflict with an existing borrow of a field the method never uses, causing Rust to reject the program. Resolving such conflicts can require programmers to compromise useful abstractions, make non-local changes to their programs, or worse, resort to unsafe code. We introduce view types, a backward-compatible refinement of reference types that specifies which fields a reference may access. This allows methods to partially borrow a struct, accessing only the fields they need without blocking access to the rest. We establish the first fully mechanized foundation for Aeneas in Rocq. Along the way, we uncover and fix gaps in the original semantics and proofs. Building on this foundation, we formalize partial borrows and prove the extended borrow checking sound. We implement view types in rustc and extend the Aeneas interpreter to support partial borrows. Our evaluation shows how view types systematically resolve borrowing conflicts across method boundaries at no runtime cost.
Read the paper
Discussion
Science Skim's AI key points, plus readers' public thoughts
Readers' thoughts
No reader thoughts yet.
Related papers
- Verified Implementation of the Next-gen Borrow Checking Algorithm for Rust via Abstract InterpretationarXiv · 2026
- A Calculus for BorrowabilityarXiv · 2026
- Tracking Borrows with Regular ExpressionsProceedings of the ACM on Programming Languages · 2026
- Escape with Your Self: Sound and Expressive Bidirectional Typing with Avoidance for Reachability TypesProceedings of the ACM on Programming Languages · 2026
- Rust’s Type Checker Implementation Is Unsound: An Empirical Study on Soundness Bugs in rustcProceedings of the ACM on Software Engineering · 2026
- Petri Nets-based Methods on Automatically Detecting for Concurrency Bugs in Rust ProgramsACM Transactions on Autonomous and Adaptive Systems · 2026