3 ms·
Without the borrow checker, how should memory be managed? Just never deallocate?
by vanviegen 10mo ago
Without the borrow checker, how should memory be managed? Just never deallocate?
- flohofwoe 10mo agoIt would be the same as in any language with manual memory management, you'd simply get a dangling pointer access. The 'move-by-default' semantics of Rust just makes this a lot trickier than in a 'copy-by-default' language though. It's actually interesting to me that the Rust borrow checker can 'simply' be disabled (e.g. no language- or stdlib-features really depending on the borrow checker pass) - not that it's very useful in practice though.
- masklinn 10mo agoThe borrow checker does not deal with ownership, which is what rust’s memory management leverages. The borrow checker validates that borrows (references) are valid aka that they don’t outlive their sources and that exclusive borrows don’t overlap. The borrow checker does not influence codegen at all.
- eptcyka 10mo agoThe same as C++, destructors get called when an object goes out of scope.