news.volyx.in

Tree Borrows (plf.inf.ethz.ch)

584 points by zdw · 385 days ago · 146 comments on HN

Article summary

The article discusses Tree Borrows, a proposal for defining the boundaries of undefined behavior in Rust's type system, particularly for unsafe code. Tree Borrows aims to overcome the limitations of Stacked Borrows, a previous proposal, by replacing the stack with a tree, allowing for more flexible and accurate definitions of valid and invalid code. The proposal has been evaluated on a large number of Rust crates and has been shown to reject fewer test cases than Stacked Borrows. The authors also provide a proof of the soundness of Tree Borrows in a dialect of Rust.

Main themes

  • Rust type system
  • Affine logic
  • Tree Borrows
  • Stacked Borrows
  • Borrow checker
  • Type system soundness

What commenters say

  • The Rust type system is affine, meaning it does not allow universal contraction, but some types may still have contraction.
  • The Curry-Howard correspondence does not prove that Rust is an affine language, and its application to non-dependently-typed languages is limited.
  • Multiple immutable shared references in Rust are not a form of contraction, but rather an extension of affine logic.
  • The borrow checker is sound, but its soundness relative to Tree Borrows has not been proven yet.
  • Running multiple borrow checker implementations in parallel may not be feasible or reliable due to the risk of accepting invalid programs.
  • The Rust type system allows different forms of contraction, which affine logic strictly prohibits, making it not truly affine.
  • The Tree Borrows proposal is an improvement over Stacked Borrows, but its implications for the Rust language and its users are still being discussed.
  • The definition of affinity in type systems is nuanced and context-dependent, and its application to Rust is still a topic of debate.