Four limitations of Rust's borrow checker

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

CodeRabbit: AI Code Reviews for Developers
Revolutionize your code reviews with AI. CodeRabbit offers PR summaries, code walkthroughs, 1-click suggestions, and AST-based analysis. Boost productivity and code quality across all major languages with each PR.
coderabbit.ai
featured
Nutrient – The #1 PDF SDK Library, trusted by 10K+ developers
Other PDF SDKs promise a lot - then break. Laggy scrolling, poor mobile UX, tons of bugs, and lack of support cost you endless frustrations. Nutrient’s SDK handles billion-page workloads - so you don’t have to debug PDFs. Used by ~1 billion end users in more than 150 different countries.
www.nutrient.io
featured
  1. rust

    Empowering everyone to build reliable and efficient software.

    At least based on the comments on lobste.rs [0] and /r/rust, these seem to be actively worked on and/or will be solved Soon (TM):

    1. Checking does not take match and return into account: I think this should be addressed by Polonius? https://rust.godbolt.org/z/8axYEov6E

    2. Being async is suffering: I think this is addressed by async closures, due to be stabilized in Rust 2024/Rust 1.85: https://rust.godbolt.org/z/9MWr6Y1Kz

    3. FnMut does not allow reborrowing of captures: I think this is also addressed by async closures: https://rust.godbolt.org/z/351Kv3hWM

    4. Send checker is not control flow aware: There seems to be (somewhat) active work to address this? No idea if there are major roadblocks, though. https://github.com/rust-lang/rust/pull/128846

    [0]: https://lobste.rs/s/4mjnvk/four_limitations_rust_s_borrow_ch...

    [1]: https://old.reddit.com/r/rust/comments/1hjo0ds/four_limitati...

  2. CodeRabbit

    CodeRabbit: AI Code Reviews for Developers. Revolutionize your code reviews with AI. CodeRabbit offers PR summaries, code walkthroughs, 1-click suggestions, and AST-based analysis. Boost productivity and code quality across all major languages with each PR.

    CodeRabbit logo
  3. lobsters-ansible

    Ansible playbook for lobste.rs

    https://github.com/lobsters/lobsters-ansible/issues/45

  4. rust-playground

    The Rust Playground

    What? I think this just works...

    https://play.rust-lang.org/?version=stable&mode=debug&editio...

  5. hecs

    A handy ECS

    > stop using references/lifetimes and start using indexes

    Aren't arenas a nicer suggestion? https://docs.rs/bumpalo/latest/bumpalo/

    Depending on the use case, another pattern that plays very nicely with Rust is the EC part of ECS: https://github.com/Ralith/hecs

  6. Lobsters

    Computing-focused community centered around link aggregation and discussion

    Looks as though it's not currently in effect, however?

    https://github.com/lobsters/lobsters/issues/761

    What a trite cat-and-mouse game, though at least it's entertaining to watch them try.

  7. generational-arena

    Discontinued A safe arena allocator that allows deletion without suffering from the ABA problem by using generational indices.

    I tend to agree w.r.t. managed languages.

    Still, being free from GC is important in some domains. Beyond being able to attach types to scopes via lifetimes, it also provides runtime array bounds checks, reference-counting shared pointers, tagged unions, etc. These are the techniques used by managed languages to achieve memory-safety and correctness!

    For me, Rust occupies an in-between space. It gives you more memory-safe tools to describe your problem domain than C. But it is less colloquially "safe" than managed languages because ownership is hard.

    Your larger point with indices is true: using them throws away some benefits of lifetimes. The issue is granularity. The allocation assigned to the collection as a whole is governed by rust ownership. The structures you choose to put inside that allocation are not. In your user ID example, the programmer of that system should have used a generational arena such as:

    https://github.com/fitzgen/generational-arena

    It solves exactly this problem. When you `free` any index, it bumps a counter which is paired with the next allocated index/slot pair. If you want to avoid having to "free" it manually, you'll have to devise a system using `Drop` and a combination of command queues, reference-counted cells, locks, whatever makes sense. Without a GC you need to address the issue of allocating/freeing slots for objects within in an allocation in some way.

    Much of the Rust ecosystem is libraries written by people who work hard to think through just these types of problems. They ask: "ok, we've solved memory-safety, now how can we help make code dealing with this other thing more ergonomic and correct by default?".

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Lobsters Blocks Brave Browser for Scammy Behavior

    3 projects | news.ycombinator.com | 7 Dec 2024
  • Mozilla Rally to “fight big tech”

    7 projects | news.ycombinator.com | 24 Jan 2022
  • Firefox vs. Brave: Which is the better browser for you? – Mozilla

    2 projects | news.ycombinator.com | 4 Oct 2021
  • Ask HN: Why Google cookies are exempted when blocking third-party cookies?

    2 projects | news.ycombinator.com | 8 May 2021
  • Solving the ABA Problem in Rust with Tagged Pointers

    1 project | news.ycombinator.com | 15 Feb 2025

Did you know that Rust is
the 5th most popular programming language
based on number of references?